40.4. Exercises#
Exercise 40.1 (Scipy.stats)
Use scipy.stats to
Find and print the mean and the variance;
Find and print the 68% credible region (equal-tail interval);
Draw and print 5 random samples;
Plot the pdf (including at least 90% of the probability mass);
for
A student-t distribution with \(\nu=2\) degrees-of-freedom;
A student-t distribution with \(\nu=100\) degrees-of-freedom;
A standard normal distribution;
in all cases with the mode at 0.0.
Exercise 40.2 (Bivariate pdf)
Consider the following (multimodal) bivariate pdf
with \(A_1=4.82033\), \(x_1=0.5\), \(y_1=0.5\), \(\sigma_1=0.2\), and \(A_2=4.43181\), \(x_2=0.65\), \(y_2=0.75\), \(\sigma_2=0.04\).
Consider the domain \(x,y \in [0,1]\) and use relevant python modules / methods to
Plot contour levels of this pdf (useful methods:
np.meshgridandplt.contour);Make a three-dimensional plot of the pdf (useful methods:
plt.subplots(subplot_kw={"projection": "3d"})andplt.plot_surface);Compute and plot the marginal pdf \(\p{y}\) (useful method:
scipy.integrate.quad)
Solutions#
Solution to Exercise 40.1 (Scipy.stats)
See the code example in the hidden code block below.
Solution to Exercise 40.2 (Bivariate pdf)
See the code example in the hidden code block below.