C3-W4 Assignment: Exercise 9: confidence_interval_proportion

In this section the task is to calculate P^ z1-alpha/2 …

I am having trouble calculating correct Z1. I have to go back and check all the videos (in the absence of course pdf) to see what it means. if someone can help me how to calculate this part or point me to the lecture where it is mentioned how to do it.
image

1 Like

Stuck here as well, it seems like you shouldn’t be able to calculate this without knowing the data array itself.

1 Like

Is the group still stuck on this ?

1 Like

Maybe you are misreading the formula. I dont read Z1 but Z1-alpha/2.
Sometimes its hard to see what is subscript.

1 Like

@Nomank_Khan

I figured it out, make sure to watch the video “Confidence Intervals for Proportion”, the last video of Lesson 1, especially the second half of the video. You should get everything from that to proceed.

Also, per @Jos comment, yes, the formula as written is confusing to look at, but it is Z and the subscript is (1 - alpha / 2), which is in fact a formula to passed into the function call, and then that is used to compute the upper and lower values.

Hope that helps.

1 Like

Just to write what others have written, if you think of z(subscript x) as Z(x), then the value multiplied by the square root is Z((1-(alpha/2)).

This means that if p^ = phat, the given formula is phat plus or minus Z((1-(alpha/2)) * sqrt((phat * (1 - phat))/n).

2 Likes

The trouble I’m having with #9 is not with the formulas, but with the variables…

Is p-hat the same as ‘pp’ from Exercise 7?

And is z the same as ‘z’ from Exercise 7?

And is ‘n’ the same n=len(data) we’ve been using all along?

The output I’m getting is the same for both control_metrics and variation_metrics, which leads me to believe that at least p-hat is not the same as pp.

1 Like

The p-hat from exercise 9 is not the same as the one from exercise 7. The ‘pp’ variable from exercise 7 was a probability combination of the control and variation metrics, whereas the p-hat from exercise 9 is calculated separately for each of those metrics. I hope it makes sense.

1 Like

Thanks. I understand that p-hat = x/n mathematically, but I can’t figure out how to code it for this assignment.

1 Like

You don’t need to calculate p-hat for exercise 9, just retrieve it like you did for p1, p2 in previous exercises. Good luck!

2 Likes


Output values are correct for this question, but I got 0 points on grading…does anybody know why?

1 Like

The values are slightly different between Expected and Got, but rounded up, they are the correct in the assignment. Does anybody know why the values are slightly different?

1 Like

I think more context would be helpful for us to troubleshoot. If you use the provided hint of the z function stats.norm.ppf and the square root function np.sqrt, I don’t see how there could be rounding errors.

1 Like

yes i used stats.norm.ppf and np.sqrt, and the values I get are extremely close to test values, close enough to round correctly, but not exact so the answer is wrong. Very strange…anyway everything else is correct so I passed the assignment.

1 Like

Congratulations on passing the assignment! I was thinking about a possibility that the way p and n were retrieved might’ve caused this issue. Please give us an update if you ever solved this issue.

1 Like

Having trouble finding this one out, the available attributes for metrics are ‘n’, ‘s’, ‘xbar’ according to dir(metrics)
How do i retrieve phat?

1 Like

Just like you did with p1 or p2 from the previous exercise.

1 Like

Thank you got it. Was my error, I must have ran the cells out of order. I was able to submit!

1 Like