All problems
Geometric Moments Mean Variance
Problem
For the trial-count geometric distribution, mean = 1 / p and variance = (1 - p) / p^2.
Given p in (0, 1], return [mean, variance].
Hint
The variance grows as success becomes rare.
Test cases
case 1
in: [0.5]
expected: [2,2]
case 2
in: [0.1]
expected: [10,89.99999999999999]
case 3
in: [1]
expected: [1,0]
Starter codePython
def geometric_mean_and_variance(p):
# Your code here
pass3 test cases · run your code against them in the editor