PHYCS 3730/6720 Lab Exercise
Reading and references:
Answer file Mylab16.txt.
Exercise 1. Random numbers
Write a Python code for generating 1000 random numbers on the interval
[0,10]. Generate a histogram of the values and plot it. Make
the histogram have bins of width 0.5. In the same plot, plot a
horizontal line showing the expected average height of each bin. (This
is just the number of samples divided by the number of bins.) You may
use hist and gnuplot or try your hand with
matplotlib.pyplot.hist . Copy your Python code to the
answer file. Also put either your Gnuplot command or your pyplot
command in the answer file.
Exercise 2. Poisson distribution
This is a warmup exercise for assignment 6. Use Python to calculate
the values of the Poisson distribution (times M):
N(k) = M dke-d/k!
with M = 20, d = 5, for integer k from 0 to 20.
Note that math.factorial(k) evaluates the factorial. Plot the
result with either gnuplot or pyplot.
Put your Python commands for generating the table in the answer file.
Also put the table of your k, N(k) numbers in the answer file.
Finally, include either your gnuplot or pyplot commands.