Skip to content
DeepForgeby svx
All problems
MediumStatisticsst-359

Wald Interval Proportion

Problem

The Wald confidence interval for a proportion is p_hat +/- z * sqrt(p_hat (1 - p_hat) / n).

Given p_hat, the sample size, and the critical z, return [lower, upper].

Hint

Center the interval on the sample proportion.

Test cases

case 1
in: [0.5,100,1.96]
expected: [0.402,0.598]
case 2
in: [0.9,50,1.645]
expected: [0.8302085606968878,0.9697914393031123]
case 3
in: [0,10,1.96]
expected: [0,0]
Starter codePython
def wald_interval_proportion(p_hat, n, z):
    # Your code here
    pass

3 test cases · run your code against them in the editor