MATH 314 Quiz 19
Given on 2025-11-02
Please submit a Jupyter notebook to the Quiz 19 repository by the end of class today.
-
Generate
N = 10random numbers from a Poisson distribution of your choice (you pick a value) store the data into a variable named x. -
Write Python function with the following signature that calculates the negative log-likelihood for the Poisson distribution.
ll_poisson(theta, data):
...
-
Use the numpy function
linspaceto generate a linearly spaced array ofvalues for , named ls, that at least captures within its range the value you chose forabove. -
Use
ls,ll_poisson, andx(as your data) to make a plot of the functionll_poisson. -
Repeat 3. and 4. above for a linearly spaced array of values for
of values and again for . What does the effect of this array have on the plot? Explain. -
Randomly initialize a starting value for
within it's proper range. -
Use Scipy's funciton
sp.optimize.minimize(...)to find the most likely value ofgiven the data you generated (but without knowledge of the true value of ). Use the initial value generated in 6. and the data
xfrom 1. Use the method"L-BFGS-B". Don't forget to adjust the bounds appropriately. You can set a bound asnp.inf. -
Calculate the mean of
xand compare it to your answer for 6. They all should match. -
Assuming you don't know the answer in advance, how many values would need to be in your grid from part 3. to find the exact answer found in 7.?
-
Repeat 1. with
N = 1000and the same value of, 3. and 4. When doing 4 again, overlay both log-likelihood functions, one for N = 10and one foreN = 1000. Given them distinct labels withplt.plot(..., label = "...")and callplt.legend()after your twoplt.plot()calls. What is the effect of more data on the log-likelihood function? -
Repeat 7. and 8. with your
N = 1000data from 10.