- Hands-On Data Science and Python Machine Learning
- Frank Kane
- 278字
- 2021-07-15 17:15:11
Population variance versus sample variance
There is a little nuance to standard deviation and variance, and that's when you're talking about population versus sample variance. If you're working with a complete set of data, a complete set of observations, then you do exactly what I told you. You just take the average of all the squared variances from the mean and that's your variance.
However, if you're sampling your data, that is, if you're taking a subset of the data just to make computing easier, you have to do something a little bit different. Instead of dividing by the number of samples, you divide by the number of samples minus 1. Let's look at an example.
We'll use the sample data we were just studying for people standing in a line. We took the sum of the squared variances and divided by 5, that is the number of data points that we had, to get 5.04.
σ2 = (11.56 + 0.16 + 0.36 + 0.16 + 12.96) / 5 = 5.04
If we were to look at the sample variance, which is designated by S2, it is found by the sum of the squared variances divided by 4, that is (n - 1). This gives us the sample variance, which comes out to 6.3.
S2 = (11.56 + 0.16 + 0.36 + 0.16 + 12.96) / 4 = 6.3
So again, if this was some sort of sample that we took from a larger dataset, that's what you would do. If it was a complete dataset, you divide by the actual number. Okay, that's how we calculate population and sample variance, but what's the actual logic behind it?
- Mastering ServiceStack
- INSTANT FreeMarker Starter
- Hands-On Data Structures and Algorithms with JavaScript
- 實戰Java程序設計
- FLL+WRO樂高機器人競賽教程:機械、巡線與PID
- Python圖形化編程(微課版)
- INSTANT Yii 1.1 Application Development Starter
- HTML+CSS+JavaScript編程入門指南(全2冊)
- Sails.js Essentials
- 遠方:兩位持續創業者的點滴思考
- Building a Media Center with Raspberry Pi
- ANSYS FLUENT 16.0超級學習手冊
- 讓Python遇上Office:從編程入門到自動化辦公實踐
- Spring Boot 3:入門與應用實戰
- 虛擬現實:引領未來的人機交互革命