Question: Please use python to solve this question, and follow the skeleton code template provided, do NOT use any extra python package. 11. The value of

Please use python to solve this question, and follow the skeleton code template provided, do NOT use any extra python package.Please use python to solve this question, and follow the skeleton code

11. The value of 7t can be estimated using a Monte-Carlo simulation, by throwing 'darts' at a 'dartboard'. Specifically, we throw darts in a square centered around the origin and measure their distance to the center. If the darts are thrown uniformly in the square from (-1,-1) to (1,1), this distance is less than 1 with a probability of /4 (a) You have been provided with Python code that can throw such uniform darts Adapt this code to throw 1000 darts and estimate 7t, by counting how many have a Euclidean distance of less than 1 to the origin (b) What is the 95% confidence interval for your estimate of ? (c) The code also contains a method to throw darts that are normally distributed (with a mean of 0 and a standard deviation of 0.6 in both dimensions). Throw 1000 normally distributed darts and compute 7t by counting how many have a Euclidean distance of less than 1 to the origin. Is this estimate of significantly different to the estimate made in part (a)? # # DO NO IMPORT AND USE ANY OTHER PACKAGES. ### Import the uniform and gauss (for normally distributed ### numbers) methods from the random pacakage from random import uniform, gauss ### Representation of a dart, with X and Y coordinates. class Dart: def init (self, x, y): self.x= x self.y -y def str (self): return " ((0:.3f).. ,(l: .3f>.. )".format (self.x, self.y) def repr (self): return self. str_() # # Euclidean distance of a given Dart object to the origin (0,0) def distanceToOrigin (dart): return (dart.x**2dart.y**2)0.5 ### Generate and throw a dart in a uniform square from (-1,-1) to (1,1) def throwUniformDart(): return Dart (uniform(-1,1), uniform(-1,1)) ### Generate and throw a dart normally distributed about the origin (std-0.6) def throwNormalDart (): sigma - 0.6 return Dart (gauss (mu, sigma) ,gauss (mu, sigma)) if namemain": ### Throw and print a 'uniform' dart dart-throwUniformDart() print("Uniform dart's coordinates: f0\.format (dart)) ### Compute and print the dart's distance to the origin distance-distanceToorigin(dart) print("Distance of dart to origin: t0)".format (distance))

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!