For the Black-Scholes stock price process is defined as

where is the volatility, is a Brownian Motion and is the interest rate. Then for a for , we have for the price at time of a European call option with payoff at maturity

where is a filtration. From this follows the following possible Monte Carlo pricing engine:

Input: S0, r, σ, T, payoff function g, number of simulations N  
  
for i in 1,...,N:  
    Sample $Z_{i}$ ~ N(0,1)  
  
    Compute terminal stock price
    
    $S_T^{(i)} = S0 * \exp((r - 1/2 σ^2)T + σ√T Z_i)$
  
    Compute payoff  
    
	$P_i = g(S_T^{(i)})$
  
Compute sample mean of payoffs  
    $\overline{P}= \sum_{i=0}^{N} P_{i}$   
  
Discount expected payoff  
    $\widehat{V}_{0 }= \exp(-rT) * \overline{P}$ 
  
Return $\widehat{V}_{0}$ 

This algorithm approximates the conditional expectation appearing in the pricing formula by the empirical average of simulated payoffs.