Machine learning / Variance Calculation Using Numpy

It is the expectation of the squared deviation of a random variable from its mean in the data set.

Variance =[ (x1 - mean)2 + (x2 - mean)2 + (x3 - mean)2 + ... + (xn - mean)2 ] / [n - 1]

Example: Let us take a data set of some numbers
Ds= [40,10,20,25,24,40,40,14,16]
Number of points in the data set = 9
Variance value =[ (x1 - mean)2 + (x2 - mean)2 + (x3 - mean)2 + ... + (xn - mean)2 ] / [n - 1] = 125.135802

Statistical Calculation Python Program Output
Variance import numpy
ds = [40,10,20,25,24,40,40,14,16]
variancecal = numpy.var(ds)
print(variancecal)
125.135802


Home     Back