MCPcopy Index your code
hub / github.com/clips/pattern / variance

Function variance

pattern/metrics.py:556–563  ·  view source on GitHub ↗

Returns the variance of the given list of values. The variance is the average of squared deviations from the mean.

(list, sample=True)

Source from the content-addressed store, hash-verified

554 return s[n/2]
555
556def variance(list, sample=True):
557 """ Returns the variance of the given list of values.
558 The variance is the average of squared deviations from the mean.
559 """
560 # Sample variance = E((xi-m)^2) / (n-1)
561 # Population variance = E((xi-m)^2) / n
562 m = mean(list)
563 return sum((x-m)**2 for x in list) / (len(list)-int(sample) or 1)
564
565def standard_deviation(list, *args, **kwargs):
566 """ Returns the standard deviation of the given list of values.

Callers 1

standard_deviationFunction · 0.70

Calls 3

sumFunction · 0.85
lenFunction · 0.85
meanFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…