- Hands-On Data Science and Python Machine Learning
- Frank Kane
- 258字
- 2021-07-15 17:15:11
Analyzing standard deviation and variance on a histogram
Let's write some code here and play with some standard deviation and variances. So If you pull up the StdDevVariance.ipynb file IPython Notebook, and follow along with me here. Please do, because there's an activity at the end that I want you to try. What we're going to do here is just like the previous example, so begin with the following code:
%matplotlib inline import numpy as np import matplotlib.pyplot as plt incomes = np.random.normal(100.0, 20.0, 10000) plt.hist(incomes, 50) plt.show()
We use matplotlib to plot a histogram of some normally distributed random data, and we call it incomes. We're saying it's going to be centered around 100 (hopefully that's an hourly rate or something and not annual, or some weird denomination), with a standard deviation of 20 and 10,000 data points.
Let's go ahead and generate that by executing that above code block and plotting it as shown in the following graph:

We have 10,000 data points centered around 100. With a normal distribution and a standard deviation of 20, a measure of the spread of this data, you can see that the most common occurrence is around 100, and as we get further and further from that, things become less and less likely. The standard deviation point of 20 that we specified is around 80 and around 120. You can see in the histogram that this is the point where things start to fall off sharply, so we can say that things beyond that standard deviation boundary are unusual.
- Building Modern Web Applications Using Angular
- Linux C/C++服務(wù)器開發(fā)實(shí)踐
- 信息可視化的藝術(shù):信息可視化在英國
- Cocos2d-x學(xué)習(xí)筆記:完全掌握Lua API與游戲項(xiàng)目開發(fā) (未來書庫)
- Webpack實(shí)戰(zhàn):入門、進(jìn)階與調(diào)優(yōu)(第2版)
- 零代碼實(shí)戰(zhàn):企業(yè)級(jí)應(yīng)用搭建與案例詳解
- Illustrator CS6設(shè)計(jì)與應(yīng)用任務(wù)教程
- PHP與MySQL權(quán)威指南
- Node.js區(qū)塊鏈開發(fā)
- Groovy 2 Cookbook
- 例解Python:Python編程快速入門踐行指南
- Less Web Development Cookbook
- Access 2016數(shù)據(jù)庫應(yīng)用與開發(fā):實(shí)戰(zhàn)從入門到精通(視頻教學(xué)版)
- Eclipse開發(fā)(學(xué)習(xí)筆記)
- 開源心法