Question: PYTHON Suppose you needed to generate a Gaussian ( normal ) distribution ( , | ) = 1 2 2 e - ( x -
PYTHON
Suppose you needed to generate a Gaussian normal distribution
of random variates, but the only random number generator you know about
is numpy.random.uniform However, assume you do know about the central
limit theorem. Create a Python script
gengauss.py which does the following:
Reads and from the command line. Be sure that your script checks that
it has the proper inputs, and prompts the user if not.
Uses the central limit theorem to generate values of having the proper
distribution, using only random numbers from numpy. random. uniform
Creates a plot in the file gengauss.png showing a histogram of values with
the PDF superimposed.
Be sure the distribution you generate has mean and width as specified on the command
line.
The distribution of decay times for elementary particles is wellmodeled by the expo
nential distribution, with PDF given by:
is the decay time and is the lifetime parameter of the elementary particle.
The file muons dat contains data from an experiment to measure the life
time of the elementary particle known as the muon. A similar experiment lives in
South Physics, and if you take PHYS you may have an opportunity to perform
this experiment. The file contains a single column with the decay time, in microsec
onds, of a set of cosmic ray muons recorded on November
For this problem, you are to determine the muon lifetime, with uncertainties and
goodnessoffit using the minimization method. You should create a Python script
muonchipy to perform the following:
Open the data file and sort decay times into bins. I recommend using bins
between and
Create independent variable from the central value of the bins, and dependent
variable from the number of entries in each bin. Use the square root of the
number of entries as the assumed Gaussian random error in the dependent
variable.
Use scipy.optimize.curvefit to extract the best fit value for Compute
and goodness of fit. Print your results to standard output.
Submit your Python script
muonchipy
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
