from scipy.stats import uniform
import numpy

def incircle(xyvalue):
    if numpy.linalg.norm(xyvalue)<1:
        return 1.
    else:
        return 0.

#The area of a square is x^2, the area of a quarter of a circle is (1/4)*pi*x^2
#Thus by looking at the number of points evenly distributed in the area of a 
#square and looking at the ratio of those which are in the circle over those 
#that are in the square will give you one fourth the value of pi

xsamples=uniform.rvs(loc=0,scale=1,size=100000)
ysamples=uniform.rvs(loc=0,scale=1,size=100000)
samples=numpy.dstack((xsamples,ysamples))[0]
#dstack puts things together as if they were similar depth elements in an array
samplesincircle=[incircle(sample) for sample in samples]
ratio=numpy.sum(samplesincircle)/len(samplesincircle)
print("My estimated value of pi is "+str(4*ratio))
