Option Pricing, Numerical Methods, Monte Carlo, Monte Carlo Simulation.
vm[i, j+1] if option_type == "call": vm[i+1, j] = max(vm[i+1, j], u[j] - u[M-i]) else: vm[i+1, j] = max(vm[i+1, j], u[0] - u[M-i-j]) # Return the option value at the current time return vm[0, M/2] # Example usage: S = 50 X = 45 r = 0.05 T = 0.5 sigma = 0.2 N = 20 M = 50 option_type = "call"