1. Exercise 1.
Looking again at the posterior joint distribution of
mu and sigma, it seems like the standard deviation of the treated group might be lower; if so, that would suggest that the treatment is more effective for students with lower scores.
But before we speculate too much, we should estimate the size of the difference and see whether it might actually be 0.
Extract the marginal posterior distributions of
sigma for the two groups. What is the probability that the standard deviation is higher in the control group?
Compute the distribution of the difference in
sigma between the two groups. What is the mean of this difference? What is the 90% credible interval?
Solution.
pmf_std_control = marginal(posterior_control, 1)
pmf_std_treated = marginal(posterior_treated, 1)
pmf_std_control.plot(label='Control')
pmf_std_treated.plot(label='Treated')
decorate(xlabel='Population standard deviation',
ylabel='PDF',
title='Posterior distributions of sigma')

Pmf.prob_gt(pmf_std_control, pmf_std_treated)
0.9685103375300469
pmf_diff2 = Pmf.sub_dist(pmf_std_control, pmf_std_treated)
pmf_diff2.mean()
6.41717132817218
pmf_diff2.credible_interval(0.9)
array([ 1. , 12.5])
kde_from_pmf(pmf_diff2).plot()
decorate(xlabel='Difference in population standard deviation',
ylabel='PDF',
title='Posterior distributions of difference in sigma')



















