Skip to content
DeepForgeby svx
All problems
MediumStatisticsst-388

Method of Moments Gamma Parameters

Problem

Matching the first two moments of a Gamma distribution gives shape = mean^2 / variance and scale = variance / mean.

Given the sample mean and variance, return [shape, scale].

Hint

Gamma mean is shape * scale and variance is shape * scale^2.

Test cases

case 1
in: [2,4]
expected: [1,2]
case 2
in: [10,5]
expected: [20,0.5]
case 3
in: [1,0.25]
expected: [4,0.25]
Starter codePython
def method_of_moments_gamma_parameters(mean, variance):
    # Your code here
    pass

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