Skip to content
DeepForgeby svx
All problems
EasyOptimizationop-110

Population Diversity Metric

Problem

Measure population diversity as the mean per-coordinate standard deviation.

For each coordinate compute the population standard deviation (dividing by n), then average across coordinates. Return 0.0 for fewer than 2 individuals or an empty population.

Hint

Compute a standard deviation per coordinate, then average them.

Test cases

case 1
in: [[[1,2],[1,2]]]
expected: 0
case 2
in: [[[0,0],[2,0]]]
expected: 0.5
case 3
in: [[[0,0],[0,2],[0,4]]]
expected: 0.816496580927726
case 4
in: [[]]
expected: 0
Starter codePython
def population_diversity(population):
    # Your code here
    pass

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