All problems
Variance of a Rate Estimate
Problem
Return the variance p * (1 - p) / n of a binomial rate estimate. Return 0.0 when n <= 0.
Test cases
case 1
in: [0.5,100]
expected: 0.0025
case 2
in: [0.8,0]
expected: 0
case 3
in: [1,50]
expected: 0
case 4
in: [0,10]
expected: 0
Starter codePython
def rate_variance(p, n):
# Your code here
pass4 test cases · run your code against them in the editor