Skip to content
DeepForgeby svx
All problems
EasyStatisticsst-053

Margin of Error

Problem

Return the margin of error z * sigma / sqrt(n) for a mean with known sigma. Return 0.0 when n <= 0.

Hint

It is the half-width of the confidence interval.

Test cases

case 1
in: [1.96,2,100]
expected: 0.392
case 2
in: [1.645,10,25]
expected: 3.29
case 3
in: [2,0,10]
expected: 0
case 4
in: [1.96,5,0]
expected: 0
case 5
in: [1,1,1]
expected: 1
Starter codePython
def margin_of_error(z_crit, sigma, n):
    # Your code here
    pass

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