官术网_书友最值得收藏!

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.

主站蜘蛛池模板: 兴仁县| 南召县| 盐池县| 乌恰县| 镇赉县| 林芝县| 自治县| 鲁甸县| 镇赉县| 宣化县| 新巴尔虎左旗| 合水县| 横山县| 双辽市| 屯昌县| 综艺| 巴马| 岳阳县| 奈曼旗| 连城县| 阜南县| 松原市| 南通市| 米脂县| 全椒县| 张北县| 宜章县| 扎兰屯市| 扎赉特旗| 靖州| 包头市| 玛曲县| 公安县| 疏勒县| 晋江市| 冀州市| 元谋县| 苗栗市| 嘉鱼县| 石景山区| 天水市|