CamDavidsonPilon / Probabilistic-Programming-and-Bayesian-Methods-for-Hackers

aka "Bayesian Methods for Hackers": An introduction to Bayesian methods + probabilistic programming with a computation/understanding-first, mathematics-second point of view. All in pure Python ;)
http://camdavidsonpilon.github.io/Probabilistic-Programming-and-Bayesian-Methods-for-Hackers/
MIT License
26.55k stars 7.85k forks source link

Chapter 1 Exercise 1.7.2 #401

Open Timothysit opened 5 years ago

Timothysit commented 5 years ago

In exercise 1.7.2: "What is the expected percentage increase in text-message rates?" hint: compute the mean of lambda_1_samples/lambda_2_samples. Note that this quantity is very different from lambda_1_samples.mean()/lambda_2_samples.mean().

The hint noted that I should compute the expected increase by taking the mean after dividing individual samples, but it seems that the answer is the same (0.28) if I divide the obtained sample means of lambda_1 and lambda_2, but the hint noted that the quantity should be different.

Did I do something wrong?

Example code:

relative_increase_samples_1 = (lambda_2_samples - lambda_1_samples) / lambda_1_samples
print('Relative increase: %.2f' % np.mean(relative_increase_samples_1))

# Alterantive way of calculating this
relative_increase_samples_2 = (lambda_2_samples.mean() - lambda_1_samples.mean()) / lambda_1_samples.mean()
print('Relative increase: %.2f' % relative_increase_samples_2)
CatChenal commented 5 years ago

I agree with @Timothysit I have done the calculation two-way as well, i.e. ratio of the means and mean of the ratio. While the results are not identical, they only differ by 0.12% (<1%), so these quantities are definitely NOT "very different".

star-yar commented 4 years ago

Whats the idea of point-wise quotient of two sample sets? How is this described from probabilistic of view?