In [8]:
exit
In [1]:
#Testing Pi Estimation Functions
#Below imports necessary functions
import pi_estimate.plots as plots
import pi_estimate.sims as sims
In [2]:
#Part 1:
#Below estimates pi for 100, 1000, 10000, and 1e6 points
est1e2 = sims.simdarts(1e2)['estpi']
est1e3 = sims.simdarts(1e3)['estpi']
est1e4 = sims.simdarts(1e4)['estpi']
est1e6 = sims.simdarts(1e6)['estpi']
#Below prints the estimates
print('The resulting estimates:')
print('At 1e2 Points: {:f}'.format(est1e2))
print('At 1e3 Points: {:f}'.format(est1e3))
print('At 1e4 Points: {:f}'.format(est1e4))
print('At 1e6 Points: {:f}'.format(est1e6))
In [3]:
#Part 2 and 5:
#Below plots the time taken for different numbers of points
import numpy as np
#Below generates the sequence of point amounts to use
numpoints = np.linspace(10, 1e5, 100)
#Below passes in the array and shows plots of time and precision
plots.plottime(numpoints)
plots.plotacc(numpoints)
In [3]:
#Part 3:
#Below draws the darts for a particular dart-throwing simulation
#NOTE: Also draws outline of circular portion of unit square
simdict = sims.simdarts(100) #Simulates throwing 100 darts
xs = simdict['xs']
ys = simdict['ys']
plots.drawdarts(x=xs, y=ys) #Draws the simulated darts
In [4]:
#Part 4:
#Below draws a histogram for a particular number of simulations,
#Where each simulation has a given number of darts
#NOTE: See top of graph for mean and standard deviation information
dartnum = 1000
simnum = 1000
plots.histdarts(numdarts=dartnum, numsims=simnum)
In [4]:
In [ ]: