(self,t, f= lambda x:x, N=1e6)
This function calculates the expected value of  E[ X_t | F ] where F includes start conditions and possibly end conditions.
This function calculates the expected value of  E[ X_t | F ] where F includes start conditions and possibly end conditions.
This function calculates the expected value of E [ X_t | F ] where F includes start conditions and possibly end conditions .
def expected_value(self,t, f= lambda x:x, N=1e6):
        """
        This function calculates the expected value of  E[ X_t | F ] where F includes start conditions and possibly end conditions.
        
        
        """
        warnings.warn( "Performing Monte Carlo with %d simulations."%N)
        self._check_time(t)
        if not self.conditional:
            return f( self.sample_position(t, N) ).mean() 
        else:
            #This uses a change of measure technique.
            """
            sum=0
            self.conditional=False
            for i in range(N):
                X = self.generate_position_at(t)
                sum+=self._transition_pdf(X,self.endTime-t,self.endPosition)*f(X)
            self.conditional=True
            """
            x = self.sample_position(t, N)
            mean = (self._transition_pdf(x,self.endTime-t,self.endPosition)*f(x)).mean()
            return mean/self._transition_pdf(self.startPosition, self.endTime-self.startTime, self.endPosition)
def expected_value ( self , t , f = lambda x : x , N = 1e6 ) : warnings . warn ( "Performing Monte Carlo with %d simulations." % N ) self . _check_time ( t ) if not self . conditional : return f ( self . sample_position ( t , N ) ) . mean ( ) else : #This uses a change of measure technique. """
            sum=0
            self.conditional=False
            for i in range(N):
                X = self.generate_position_at(t)
                sum+=self._transition_pdf(X,self.endTime-t,self.endPosition)*f(X)
            self.conditional=True
            """ x = self . sample_position ( t , N ) mean = ( self . _transition_pdf ( x , self . endTime - t , self . endPosition ) * f ( x ) ) . mean ( ) return mean / self . _transition_pdf ( self . startPosition , self . endTime - self . startTime , self . endPosition )