#!/usr/bin/python
import math, random
num_points=50000
origin=(0.0,0.0)
def random_point():
# Return a random point from the first quadrant inside the
# square with corners at (0,0) to (1,1).
return (random.random(), random.random())
def distance(a,b):
# Return the distance between points (a,b) in a Cartesian
# plane. (This should be generalized to n dimensions.)
delta_x=b[0]-a[0]
delta_y=b[1]-a[1]
return math.sqrt(delta_x*delta_x+delta_y*delta_y)
def inside_curve(point):
# Tell whether the point in question is inside (beneath?)
# the curve we are trying to integrate.
#
# For a general Monte Carlo method to integrate any function f,
# we would want something closer to
#
# return f(point[0])