# PHYCS 3730/6720 Lab Exercise

In assignment 6 you created a Monte Carlo model of radioactive decay with your code decay.py. In this exercise, you are asked to use the scipy.optimize curve_fit function to fit your results from exercise 2 for decays vs time to determine the best fit lifetime and initial number of atoms. (You know what input values were used when you ran the model, but the exercise here is to pretend you don't know them, and see how well you could have estimated them by fitting the curve.)

To use curve_fit you need a list of times, number of decays at those times, and a standard deviation for the number of decays. You have the first two from the exercise. We know the probability distribution is Poisson, and when the number of counts is high enough, the Poisson distribution looks somewhat Gaussian and has a standard deviation approximately equal to the square root of the number of counts. On the other hand, when the number of counts is small, as we have seen, the Poisson is not symmetric like a Gaussian. For a better approximation, we add 1 to the number of decays at every point. Also, we use the square root of the new number to estimate the standard deviation of that point. Finally, let's avoid having too many decay values close to zero, where this approximation is worst. so fit only the first 60 values in your data.

Write a short Python script that reads the decay results from assignment 6, exercise 2, computes the standard deviations, and then fits the function, See the Scipy curve fitting handout linked above for a similar example. Note, however, that here you are not creating artificial data. You are using your results from Assignment 6. And your function is for the number of decays versus time, not the number of surviving atoms versus time, as in the handout.

def f(t,N,tau):
return dt*N/tau*np.exp(-t/tau)

for the best values of N and tau. (Here dt = 5.) Choose initial values for the fit parameters that are not too far from the values that you know.

In the answer file, paste your Python script and the result from your fit, identifying the best fit values.

#### Exercise 2. Interpreting the covariance matrix

Use the covariance matrix to determine the standard deviations in the best fit values of N and tau. How close did you get to the true values? Answer by saying by how many standard deviations you miss them for each value. Then determine the correlation coefficient between N and tau. What does a positive correlation mean?