All problems
Standard Deviation of Discrete RV
Problem
Standard deviation of a discrete random variable with the given values and probabilities.
Var(X) = sum((v_i - E[X])^2 * p_i) and the result is sqrt(Var(X)).
Test cases
case 1
in: [[1,2,3,4,5,6],[0.16666666666666666,0.16666666666666666,0.16666666666666666,0.16666666666666666,0.16666666666666666,0.16666666666666666]]
expected: 1.707825127659933
case 2
in: [[0,1],[0.5,0.5]]
expected: 0.5
case 3
in: [[5,5,5],[0.3333333333333333,0.3333333333333333,0.3333333333333333]]
expected: 0
Starter codePython
import math
def standard_deviation_discrete(values, probs):
# Your code here
pass3 test cases · run your code against them in the editor