In [6]:
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))


The resulting estimates:
At 1e2 Points: 3.040000
At 1e3 Points: 3.148000
At 1e4 Points: 3.145600
At 1e6 Points: 3.144256

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 [4]:
#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 [5]:
#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)


---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-5-8da94326ad9b> in <module>()
      5 dartnum = 1000
      6 simnum = 1000
----> 7 plots.histdarts(numdarts=dartnum, numsims=simnum)

C:\Users\Silver\Documents\GitHub\BI-Demo\day2\exercises\Jamila\pi_estimate\plots.py in histdarts(numdarts, numsims)
     47         stdstring = 'St. Dev: {:.4f}'.format(np.std(estpis))
     48         graph.hist(estpis, histtype='step', alpha=.6, bins=50)
---> 49         graph.title('Histogram of Pi Estimations: '+numdarts+' Darts Each')
     50         graph.suptitle(meanstring+stdstring)
     51         graph.xlabel('Estimated Pi Values')

TypeError: cannot concatenate 'str' and 'int' objects

In [ ]:


In [5]:


In [5]:


In [ ]: