nimble.calculate.variance

nimble.calculate.variance(values, sample=True)

The variance of the values in a vector.

This function requires numeric data and ignores any NaN values. Non-numeric values will results in NaN being returned.

Parameters:
  • values (nimble Base object) – Must be one-dimensional.

  • sample (bool) – If True, the default, the sample standard deviation is returned. If False, the population standard deviation is returned.

Examples

>>> lst = [1, 2, 3, 4, 5, 6, float('nan')]
>>> vector = nimble.data(lst)
>>> variance(vector)
3.5
>>> variance(vector, sample=False)
2.9166666666666665