Skip to content
DeepForgeby svx
All problems
MediumProbabilitypr-083

Multinomial Covariance

Problem

Covariance between the counts of two distinct categories in a multinomial experiment with n trials and category probabilities p_i and p_j:

Cov = -n * p_i * p_j.

Inputs are assumed to describe two different categories.

Hint

More successes in one category force fewer in the others.

Test cases

case 1
in: [10,0.2,0.3]
expected: -0.6
case 2
in: [5,0.5,0.5]
expected: -1.25
case 3
in: [100,0.1,0.1]
expected: -1
Starter codePython
def multinomial_covariance(n, p_i, p_j):
    # Your code here
    pass

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