Assignment Excercise 8. p-value calculation?

It should be the easiest thing but following line is not returning correct answer.

solution removed

this is returning value of 1.9998843285256882 which is incorrect. It should be less than 0.05 as the answer shows we are rejecting null hypothesis. Can anyone guide me what am I doing wrong here?


Hi @hamad!

I have removed your solution, even though it doesn’t look right, we do not allow sharing direct solutions, as this goes against our community guidelines.

As I could see in your solution, it is not completely correct.

This is an example image I got from Google, so please ignore the specific values there. Only the shape is important:


Note that, due to symmetry, both purple areas are the same, so we must only find one, and the value stats.norm.cdf(x) returns P(Z \leq x), this is not exactly what you need, because you will get the complement of what you want, in fact. Looking at the purple value in the left hand side, the closer to the \bar x. How can you compute it in terms of P(Z \leq x)?