(self,f,t,N)
uses a monte carlo approach to evaluate the expected value of the process f(X_t). N is the number of iterations. The parameter f\
        is a univariate python function.
uses a monte carlo approach to evaluate the expected value of the process f(X_t). N is the number of iterations. The parameter f\
        is a univariate python function.
uses a monte carlo approach to evaluate the expected value of the process f ( X_t ) . N is the number of iterations . The parameter f \ is a univariate python function .
def expected_value(self,f,t,N):
        "uses a monte carlo approach to evaluate the expected value of the process f(X_t). N is the number of iterations. The parameter f\
        is a univariate python function."
        print "Attn: performing a Monte Carlo simulation..."
        self._check_time(t)
        if not self.conditional:
            sum=0
            for i in xrange(N):
                sum+=f(self.generate_position_at(t))
            return sum/N
        else:
            #This uses a change of measure technique.
            sum=0
            self.conditional=False
            for i in xrange(N):
                X = self.generate_position_at(t)
                sum+=self._transition_pdf(X,self.endTime-t,self.endPosition)*f(X)
            self.conditional=True
            return sum/(N*self._transition_pdf(self.startPosition, self.endTime-self.startTime, self.endPosition))
def expected_value ( self , f , t , N ) : print "Attn: performing a Monte Carlo simulation..." self . _check_time ( t ) if not self . conditional : sum = 0 for i in xrange ( N ) : sum += f ( self . generate_position_at ( t ) ) return sum / N else : #This uses a change of measure technique. sum = 0 self . conditional = False for i in xrange ( N ) : X = self . generate_position_at ( t ) sum += self . _transition_pdf ( X , self . endTime - t , self . endPosition ) * f ( X ) self . conditional = True return sum / ( N * self . _transition_pdf ( self . startPosition , self . endTime - self . startTime , self . endPosition ) )