Difference: MonteCarloLab (21 vs. 22)

Revision 222021-12-18 - JorgeRodriguez

Line: 1 to 1
 
META TOPICPARENT name="PHY4821L"
-- JorgeRodriguez - 2012-01-09
Line: 7 to 7
 This lab is to be completed mostly on a computer. You can use the python tools you installed on your PC or Mac. In this lab there are four related parts all designed to introduce you to Monte Carlo techniques, essential tools in the analysis of data in all modern scientific endeavors, build familiarity with the three basic statistical distributions important in data analysis, and to further your computing skills.
  1. Part A: Here you will first employ the Monte Carlo acceptance/rejection method to compute the value of π and its statistical uncertainty. You may use any programming language you want as long as it is C, C++, Python, MATLAB, or FORTRAN. Since all have deployed an IDE and have been encouraged to use it to develop python scripts and Dr. Boeglin's excellent set of python wrapper tools in his <a data-wikiword="LabTools3" href="http://wanda.fiu.edu/boeglinw/LabTools3/" target="_blank" title="LabTools3"> LabTools3 </a> encourage you to continue to use that for this and all of the computing projects assigned in this class.
Changed:
<
<
  1. Part B: Here you will apply what you learned to compute the volume of an n-dimensional sphere, and its error, essentially compute integrals using the MC acceptance/rejection method.
>
>
  1. Part B: Here you will apply what you learned to compute the volume of an n-dimensional sphere, and its error, essentially computing integrals using the MC acceptance/rejection method.
 
  1. Part C: Here the goal is to generate data drawn from normal or Gaussian distribution. You then histogram the data and fit the histogram to a Gaussian probability distribution function and discuss the results.
  2. Part D: Now you will use the transformation method to now generate data drawn from a Poisson distribution. As above you will histogram the data but do not need to do a fit.
Line: 18 to 18
 Suggested Reading for this lab:
  • Bevington & Robison: Probability and Distributions, Binomial, Poisson, and Gaussian distributions all of chapter 2 pgs 17-31.
  • Bevington & Robison: Monte Carlo Techniques, The acceptance-rejection method you'll use, and most aspects of this lab are spelled out in chapter 5 pgs 75-94.
Changed:
<
<
  • Bevington & Robison: Testing the Fit, you will be fitting your data in part three to a Gaussian function for a discussion on this topic check chapter 9-11
>
>
  • Bevington & Robison: Testing the Fit, you will be fitting your data in part three to a Gaussian function for a discussion on this topic check chapters 9-11
 

Part A. Calculate the value of π (pi) using Monte Carlo methods

Line: 33 to 33
 
    1. Compute π by taking the ratio of your counter to the number of iterations. As this is proportional to π you have completed the computation of the central value of π.
    2. Finally, calculate the statistical uncertainty of π given that the process used to determine π is a binomial one the uncertainty will thus be proportional but not equal to the binomial uncertainty.
  • Also part of the assignment is to find the number of events needed to obtain statistical uncertainties of 1%, 0.01%, and 0.00001%. One way to do this is the brute force way and use the program changing the number of iterations until you get the desired result. This could take a while at least for the smallest uncertainties. There is an analytic method that involves solving for N using the value of pi from your calculator. Make sure you include these estimates in your paper.

Changed:
<
<

Part B. Calculate the Volume of an N-dimensional spheres

>
>

Part B. Calculate the Volume of N-dimensional spheres

  Modify your program, or write a new one, to determine the volumes of N-dimensional spheres (N=1,2,3,4,5 but you've already done the 2D one) with radius=1.0. Use 10,000 tries and make sure you quote your uncertainties. You should also compare your results with analytic values that you can compute by some other means. Please include the means used to compute the analytic values.
Changed:
<
<

Part C: Generate Poisson deviates, histogram and plot the distribution

>
>

Part C: Generate Poisson deviates, histogram, and plot the distribution

  In Part C the assignment is to generate a sample of Poisson deviates using Monte Carlo methods, specifically the transformation method. The method depends on the conservation of probabilities which stipulates that a draw from a uniform random distribution is equivalent to a draw from any other distribution, including the Poisson. Symbolically,
Changed:
<
<
LaTeX: \int_{0}^r{u(r)dr} =\int_0^x{P(x)dx}
>
>
LaTeX: \int_{0}^r{u(r)dr} =\int_0^x{P(x)dx}
  where LaTeX: u(r) is the uniform distribution defined on the interval LaTeX: [0,1]and LaTeX: P(x)is, in this case, the Poisson distribution function, a discrete distribution,
Changed:
<
<
LaTeX: P(x) =\sum\limits_{x=0}^x\frac{\mu^x}{x!}e^{-\mu},
>
>
LaTeX: P(x) =\sum\limits_{x=0}^x\frac{\mu^x}{x!}e^{-\mu},
  with x an integer and mean μ.
Line: 53 to 53
 
  1. now compute the Poisson probability, the argument of the summation above, for integers LaTeX: xx starting at 0 and continuing on to some n. Each time add terms to form the summation as required by the equality above.
  2. Compare the summation as the integers increase and compare to the random number LaTeX: rr drawn from the uniform distribution above.
  3. Once you have a summation that is greater than the LaTeX: rr, which corresponds to the LHS, write the integer in the previous iteration LaTeX: xx into a table and that will be your Poisson deviate that corresponds to LaTeX: rr,
Changed:
<
<
The prescription above is a computational evaluation of the above equation to determine the variable LaTeX: xx which is the Poisson deviate.
>
>
The prescription above is a computational evaluation of the above equation to determine the variable LaTeX: xx which is the Poisson deviates.
  Repeat this process N = 10,000 times to obtain 10,000 Poisson deviates.
Changed:
<
<
You will need as an input parameter the mean LaTeX: \mu of the distribution. You will then histogram the deviates and plot the histograms, include these in your report. Remember that histogram binning is important. If you don't get this right the plots will look funny, either there will be spaces between bins of some bins will be much larger than their neighbors, indicating overflow. Given that you are plotting Poisson distributions that are discrete the bin width is = 1.Please repeat the generation of Poisson deviates 3 times: one with LaTeX: \mu = 1.0, \mu = 10.3 \text{   and   } \mu = 102.1.
>
>
You will need as an input parameter the mean LaTeX: \mu of the distribution. You will then histogram the deviates and plot the histograms, include these in your report. Remember that histogram binning is important. If you don't get this right the plots will look funny, either there will be spaces between bins of some bins will be much larger than their neighbors, indicating overflow. Given that you are plotting Poisson distributions that are discrete the bin width is = 1. Please repeat the generation of Poisson deviates 3 times: one with μ = 1.0, μ = 10.3 and μ = 102.1.
 

Part D. Generate and Fit a Gaussian

In this exercise, you employ the Monte Carlo technique to generate data distributed as a normal or Gaussian distribution. Then you will fit the generated data sample to a Gaussian Probability Distribution Function (PDF), determine the fit parameters and their errors, and discuss the goodness of the fit via the reduced chi2.

Changed:
<
<
There are many ways to generate a normally distributed set of data. One way is to start off with a uniform (flat) distribution of data points, generated between 0 to 1, and transform them to a normally distributed set of data via the Box-Muller 2D Gaussian transformation described in Bevington and Robinson or here<a href:http://pdg.lbl.gov/2011/reviews/rpp2011-rev-monte-carlo-techniques.pdf > http://pdg.lbl.gov/2011/reviews/rpp2011-rev-monte-carlo-techniques.pdf </a> This clever algorithm is both efficient and easy to implement. There are many sources you can read about it, there is even a Wikipedia article on it. There is an easier way but one I do not want you to use. It turns out that given the usefulness of having random numbers drawn from a Gaussian are, every programming language has normal or Gaussian deviate generators in standard libraries. For example, numerical Python has a built-in normal random number generator in NumPy and probably all other math libraries. Again please do not use a built-in method or any functions that invoke a normal random number generator. The assignment calls for you "coding up" the Box-Muller procedure yourself.
>
>
There are many ways to generate a normally distributed set of data. One way is to start off with a uniform (flat) distribution of data points, generated between 0 to 1, and transform them to a normally distributed set of data via the Box-Muller 2D Gaussian transformation described in Bevington and Robinson or here<a href:http://pdg.lbl.gov/2011/reviews/rpp2011-rev-monte-carlo-techniques.pdf > http://pdg.lbl.gov/2011/reviews/rpp2011-rev-monte-carlo-techniques.pdf </a> This clever algorithm is both efficient and easy to implement. There are many sources you can read about it, there is even a Wikipedia article on it. There is an easier way but one I do not want you to use. It turns out that given the usefulness of having random numbers drawn from a Gaussian area, every programming language has normal or Gaussian deviate generators in standard libraries. For example, numerical Python has a built-in normal random number generator in NumPy and probably all other math libraries. Again please do not use a built-in method or any functions that invoke a normal random number generator. The assignment calls for you "coding up" the Box-Muller procedure yourself.
  Here is how to do it:
  • Use uniform random number generators to generate random numbers drawn from the Gaussian centered at 0 with a variance of 1.0 using the Box-Muller transform as described in the references above.
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback