All problems
Cluster Sampling Variance
Problem
Return the cluster sampling variance of the mean estimator sum((mean_j - grand)^2) / (M*(M-1)) for M cluster means. Return 0.0 when fewer than two clusters are given.
Hint
Clusters act as the independent units.
Test cases
case 1
in: [[1,2,3,4]]
expected: 0.4166666666666667
case 2
in: [[5,5,5]]
expected: 0
case 3
in: [[1,5]]
expected: 4
case 4
in: [[1]]
expected: 0
case 5
in: [[]]
expected: 0
Starter codePython
def cluster_sampling_variance(cluster_means):
# Your code here
pass5 test cases · run your code against them in the editor