Home > AI > Language > Python >

(interview) Population Variance from Subpopulation Variance


Given a list of numpy arrays, where each array is a subpopulation and the entire list is the population, calculate the variance of the entire population from the variance of the subpopulations.

```py
import numpy as np

def pop_var_from_subpop_var(groups):
    pass

groups = [np.array([1,2,3,4]), np.array([5,6])]
print(pop_var_from_subpop_var(groups))
# 2.9166666666666665
```

Leave a Reply