All problems
Method of Moments for Uniform
Problem
Method of moments estimate of the upper endpoint theta of Uniform(0, theta) from samples. Since the mean is theta / 2:
theta_hat = 2 * sample mean.
Return 0.0 for an empty sample.
Hint
Match the sample mean to the theoretical mean.
Test cases
case 1
in: [[0,1]]
expected: 1
case 2
in: [[0.5,1.5]]
expected: 2
case 3
in: [[0,0,1,1]]
expected: 1
case 4
in: [[]]
expected: 0
Starter codePython
def method_of_moments_uniform(samples):
# Your code here
pass4 test cases · run your code against them in the editor