let number_of_iterations = 25;
let number_of_samples = 500;
let radius = 200;
let radius_squared = power(radius, 2);
let sample_space = linspace(0, radius, 10000);
let pi = 0;
for(let i = 0; i < number_of_iterations; i = i + 1) {
let x_array = random_choose(sample_space, number_of_samples);
let y_array = random_choose(sample_space, number_of_samples);
let count = 0;
for(let k = 0; k < number_of_samples; k = k + 1) {
let distance_squared = power(x_array[k], 2) + power(y_array[k], 2);
if (distance_squared <= radius_squared) {
// Inside circle
count = count + 1;
}
}
pi = pi + count / number_of_samples;
println 4 * pi /number_of_iterations;
}