(self,times, N= 1, return_normals = False)
the parameter Normals = 0 is used for the Integrated OU Process
the parameter Normals = 0 is used for the Integrated OU Process
the parameter Normals = 0 is used for the Integrated OU Process
def sample_path(self,times, N= 1, return_normals = False):
        "the parameter Normals = 0 is used for the Integrated OU Process"
        if not self.conditional:
            path=np.zeros( (N,len(times)) )
            times = np.insert( times, 0,self.startTime)
            path[ :, 0] = self.startPosition
            
            deltas = np.diff(times )
            normals = np.random.randn( N, len(times)-1 )
            x = self.startPosition*np.ones( N) 
            sigma = np.sqrt(self.sigma**2*(1-np.exp(-2*self.theta*deltas))/(2*self.theta))
            for i, delta in enumerate(deltas):
                mu = self.mu + np.exp(-self.theta*delta)*(x-self.mu)
                path[:, i] = mu + sigma[i]*normals[:,i] 
                x = path[:,i]
                """
                It would be really cool if there was a numpy func like np.cumf( func, array )
                that applies func(next_x, prev_x) to each element. For example, lambda x,y: y + x
                is the cumsum, and lambda x,y: x*y is the cumprod function.
                """
            if return_normals:
                return (path, normals )
            else:
                return path
        
        else:
            #TODO
            path = bridge_creation(self,times)
            return path
def sample_path ( self , times , N = 1 , return_normals = False ) : if not self . conditional : path = np . zeros ( ( N , len ( times ) ) ) times = np . insert ( times , 0 , self . startTime ) path [ : , 0 ] = self . startPosition deltas = np . diff ( times ) normals = np . random . randn ( N , len ( times ) - 1 ) x = self . startPosition * np . ones ( N ) sigma = np . sqrt ( self . sigma ** 2 * ( 1 - np . exp ( - 2 * self . theta * deltas ) ) / ( 2 * self . theta ) ) for i , delta in enumerate ( deltas ) : mu = self . mu + np . exp ( - self . theta * delta ) * ( x - self . mu ) path [ : , i ] = mu + sigma [ i ] * normals [ : , i ] x = path [ : , i ] """
                It would be really cool if there was a numpy func like np.cumf( func, array )
                that applies func(next_x, prev_x) to each element. For example, lambda x,y: y + x
                is the cumsum, and lambda x,y: x*y is the cumprod function.
                """ if return_normals : return ( path , normals ) else : return path else : #TODO path = bridge_creation ( self , times ) return path