Python statistics variance Method

📔 : Python Statistics 🔗

python में statistics module का variance() method का use sample variance calculate करने के लिए किया जाता है।

What is Variance?

variance , variability का एक measure है जिसे mean / average से squared deviations का average लेकर calculate किया जाता है।

Variability ?

Variability बताती है कि किसी data set में data points आपस में और center of a distribution से कितने दूर हैं।

variance (σ2) हमें बताता है कि किसी specific population में data points कैसे फैले हुए हैं। यह population में प्रत्येक data point से mean ,square तक की दूरी का average है।

Sample Variance Formula

Sample Variance = Σ(x-x¯)2/n-1

Difference Between Sample Variance and Population Variance

बैसे तो sample variance , population variance का estimate है , इसे तब use करते हैं जब population variance ज्यादा problematic हो। इसके अलावा मैं difference है कि population variance में sum of squared deviation को n से divide किया जाता है , जबकि sample variance में n-1 से। जहाँ n = number of data points in data set.

Python statistics variance() Method Syntax

statistics.variance(data)
Parameters
  1. data | required : data जिसका हमें Sample Variance calculate करना है , आप इसमें values की (list, tuple) pass कर सकते हैं।

  2. Return value : pass की गयी values के according value (Integer/float) return होती है।

Python statistics variance() Method Example

Copy Fullscreen Close Fullscreen Run
# Import statistics Library.
# Import statistics Library.
import statistics
#using list.
print(statistics.variance([2,3,4,5,6,7,7,5,12]))
print(statistics.variance([11,22,23,1,23]))
print(statistics.variance([23,2,12,23,3]))
Output
C:\Users\Rahulkumar\Desktop\python>python test_variance.py
8.5
96
105.30000000000001

Related Topics :

Rahul Kumar

Rahul Kumar

Hi ! My name is Rahul Kumar Rajput. I'm a back end web developer and founder of learnhindituts.com. I live in Uttar Pradesh (UP), India and I love to talk about programming as well as writing technical tutorials and tips that can help to others.

Get connected with me. :) LinkedIn Twitter Instagram Facebook

b2eprogrammers