using Distributions u = 0.2 d = -0.1 r = 0.05 T = 100 S0 = 100.0 K = 110.0 N = 10^7 # We will use the binomial distribution from the Distributions package # without this package the numbers could have been generated by e.g. # sum(randbool(N, T), 2) which requires around 5 times more time. distribution = Binomial(T, (r - d)/(u - d)) ups = rand(distribution, N) S = S0 * (1 + u).^ups .* (1 + d).^(T - ups) C = max(S - K, 0) sum(C)/(N * (1 + r)^T)