医药统计项目联系QQ:231469242
目录
0.概念
1.绘制单个正太分布
2.比较多个正态分布
2.1偏态和峰态
3.应用
4. z分数
5.中心极限定理
6.大数定理
7. 二项式分布与正态分布图比较
8.你的数据是正态分布吗
0.概念
正态分布的函数(又称密度函数)为
![](https://i-blog.csdnimg.cn/blog_migrate/c972ee5432b66a070f81c0f2898ec06a.png)
标准正态分布这两个参数分别为0与1。
标准正态分布的密度函数可写作:
![](https://i-blog.csdnimg.cn/blog_migrate/cdde77634a5f48baff67c8d3fd77e993.png)
![图片](https://i-blog.csdnimg.cn/blog_migrate/7685b29fa20f811d4c9ba80d0bc344c4.png)
所有正太分布都可以转化成标准正态分布
![图片](https://i-blog.csdnimg.cn/blog_migrate/b65788e2a032adfa9a2c4d8a0f44fcd4.png)
![图片](https://i-blog.csdnimg.cn/blog_migrate/554fc1231cb0f7b4e0262aebf3976e7c.png)
![图片](https://i-blog.csdnimg.cn/blog_migrate/21014cf7e7f867ddd599336d884f624d.png)
4.图形特点
![](https://i-blog.csdnimg.cn/blog_migrate/9b162f6579d2e956ee2de6ff3e9e2980.jpeg)
期望值μ决定了其位置,其 标准差σ决定了分布的幅度
![图片](https://i-blog.csdnimg.cn/blog_migrate/7d1d0515b95862b7fc114d8c72df9a06.png)
服从正态分布的随机变量的概率规律为取与μ邻近的值的概率大,而取离μ越远的值的概率越小;σ越小,分布越集中在μ附近,σ越大,分布越分散。
![](https://i-blog.csdnimg.cn/blog_migrate/3fd97e32d24483935bc87ade36b81795.jpeg)
![](https://i-blog.csdnimg.cn/blog_migrate/56d141ce6dc6aa48179ce9fd2b63ea16.jpeg)
# -*- coding: utf-8 -*-
import numpy as np
import matplotlib.pyplot as plt
import scipy.stats as stats
import seaborn as sns
import math,pylab,matplotlib,numpy
mean=0
std=1
normalDistribution=stats.norm(mean,std)
x=np.arange(-5,5,0.1)
y=normalDistribution.pdf(x)
significanceLevel=0.05
normalDistribution.ppf([0.025,0.975])
'''
Out[5]: array([-1.95996398, 1.95996398])
'''
plt.plot(x,y)
plt.xlabel("x")
plt.ylabel("probability density")
plt.title("Normal distribution:mean=%.1f,standard deviation=%.1f"%(mean,std))
plt.show()
比教科书计算还准确,精确到6位小数
比教科书计算还准确,精确到6位小数
![图片](https://i-blog.csdnimg.cn/blog_migrate/ae177f99643ea82382ba2e9b427ce6b4.png)
# -*- coding: utf-8 -*-
import numpy as np
import matplotlib.pyplot as plt
import scipy.stats as stats
import seaborn as sns
import math,pylab,matplotlib,numpy
from matplotlib.font_manager import FontProperties
#设置中文字体
font=FontProperties(fname=r"c:\windows\fonts\simsun.ttc",size=15)
mean=0
std=1
#标准正太分布
normalDistribution=stats.norm(mean,1)
#方差较大正态分布
normalDistribution1=stats.norm(mean,2)
#方差较小正态分布
normalDistribution2=stats.norm(mean,0.5)
x=np.arange(-5,5,0.1)
y=normalDistribution.pdf(x)
y1=normalDistribution1.pdf(x)
y2=normalDistribution2.pdf(x)
'''
significanceLevel=0.05
normalDistribution.ppf([0.025,0.975])
'''
'''
Out[5]: array([-1.95996398, 1.95996398])
'''
plt.plot(x,y,label="standard deviation")
plt.plot(x,y1,'ro',label="std=2")
plt.plot(x,y2,'b--',label="std=0.5")
plt.xlabel("x")
plt.ylabel("probability density")
#plt.title("Normal distribution:mean=%.1f,standard deviation=%.1f"%(mean,std))
plt.title("Normal distribution")
plt.legend()
plt.show()
skewness/ˈskjuːnɪs/偏态
the quality or condition of being skew 偏斜
skew n/vt
If something is skewed, it is changed or affected to some extent by a new or unusual factor, and so is not correct or normal. 曲解; 歪曲
kurtosis[kɜː'təʊsɪs]峰态
N a measure of the concentration of a distribution around its mean, esp the statistic B2 = m4/m2² where m2 and m4 are respectively the second and fourth moment of the distribution around the mean. In a normal distribution B2 =
![图片](https://i-blog.csdnimg.cn/blog_migrate/6f92754e765adb94821ccbad0cfb5332.png)
#coding=utf-8
测试结果和spss一样
如果数据的分布是对称的,平均数,中位数和众数必然相等。
如果数据是明显偏左分布,说明数据存在极小值,必然拉动平均值向极小值一边考
众数和中位数不受极值影响。
如果数据是明显右偏分布,说明数据存在极大值,必然拉动平均数向极大值一方靠。
一般,分布对称或接近对称时,建议使用平均数,数据分布明显偏态时,可考虑使用中位数或众数。
如果数据分布对称,偏态系数等于0,
如果偏态系数明显不等于0,表面分布非对称
若偏态系数大于1或小于-1,视为严重偏态分布;
若偏态系数在0.5-1或-1至-0.5,视为中等偏态分布;
左偏态:负值表示左偏态(分布的左侧有长尾)
右偏态:正值表示右偏态(在分布的右侧有长尾)
峰态:数据分布峰值的高低,峰态系数coefficient of kurtosis记作K。
标准的峰态系数=0,当K>0时为尖峰分布,,数据分布相对集中
当K<0时为扁平分布,数据的分布相对分散。
正态分布也称常态分布或常态分配,是连续随机变量概率分.布的一种,是在数理统计的理论与实际应用中占有重要地位的一,种理论分布。自然界,人类社会,心理与教育中大量现象均按正·态形式分布。例如能力的高低,学生成绩的好坏,人们的社会态·度,行为表现以及身高、体重等身体状态。
正态分布是由阿伯拉罕·德莫弗尔(Abraham de Moivre)1733年发现的。其他几位学者如拉普拉斯(Marquis de Laplace)、高斯 (Carl Friedrich Gauss)对正态分布的研究也做出了贡献,故有时称正态分布为高斯分布。
医学意义
正态分布的应用某些医学现象,如同质群体的身高、红细胞数、血红蛋白量、胆固醇等,以及实验中的随机误差,呈现为正态或近似正态分布;有些资料虽为偏态分布,但经数据变换后可成为正态或近似正态分布,故可按正态分布规律处理
医学参考值范围亦称医学正常值范围。它是指所谓“正常人”的解剖、生理、生化等指标的波动范围。制定正常值范围时,首先要确定一批样本含量足够大的“正常人”,所谓“正常人”不是指“健康人”,而是指排除了影响所研究指标的疾病和有关因素的同质人群;其次需根据研究目的和使用要求选定适当的百分界值,如80%,90%,95%和99%,常用95%;根据指标的实际用途确定单侧或双侧界值,如白细胞计数过高过低皆属不正常须确定双侧界值,又如肝功中转氨酶过高属不正常须确定单侧上界,肺活量过低属不正常须确定单侧下界。另外,还要根据资料的分布特点,选用恰当的计算方法。
心理学
模特卡洛模拟身高概率问题
1.如果男性身高175cm,标准差6cm,那么随机抽一个183cm的男孩概率多少?
# -*- coding: utf-8 -*-
import numpy as np
import matplotlib.pyplot as plt
import scipy.stats as stats
import seaborn as sns
import math,pylab,matplotlib,numpy
mean=175
std=6
normalDistribution=stats.norm(mean,std)
x=183
#x=np.arange(20,220,0.1)
y=normalDistribution.pdf(x)
'''
身高183的随机概率为百分之2
normalDistribution.pdf(183)
Out[28]: 0.027335012445998941
身高175的随机概率为0.06
normalDistribution.pdf(175)
Out[29]: 0.066490380066905455
'''
2.男性平均身高175,标准差6
女性平均身高168, 标准差3
随机抽取一个女性和男性,女性高于男性概率多高?
,
# -*- coding: utf-8 -*-
import numpy as np
import matplotlib.pyplot as plt
import scipy.stats as stats
import seaborn as sns
import math,pylab,matplotlib,numpy
from matplotlib.font_manager import FontProperties
#设置中文字体
font=FontProperties(fname=r"c:\windows\fonts\simsun.ttc",size=15)
#测试n次
n=100000
#标准正太分布
normalDistribution=stats.norm(175,6)
#方差较大正态分布
normalDistribution1=stats.norm(168,3)
#一次随机
def Random_single():
array_male=normalDistribution.rvs(1)
array_female=normalDistribution1.rvs(1)
male=array_male[0]
female=array_female[0]
if female>male:
return True
else:
return False
#n次随机,返回count(女性高于男性的次数)
def Multiple_random(n):
count=0
for i in range(n):
value=Random_single()
if value==True:
count+=1
return count
# 计算女性高于男性概率
def Probability(n):
count=Multiple_random(n)
p=count*1.0/n
return p
probability=Probability(n)
print '随机次数',n
print '女性高于男性概率:',probability
#绘图
x=np.arange(60,220)
y=normalDistribution.pdf(x)
y1=normalDistribution1.pdf(x)
plt.plot(x,y,label="male")
plt.plot(x,y1,'r',label="female")
plt.xlabel("x")
plt.ylabel("probability density")
#plt.title("Normal distribution:mean=%.1f,standard deviation=%.1f"%(mean,std))
plt.title("Normal distribution")
plt.legend()
plt.show()
平均数一致,但两组数据离散程度不同,第一组数据离散程度更大,分布更广
Z分数成为所有单位的规则,英里,米,千克,分钟等等,Z分数统一了测量单位
Z分数公式
注意总体Z分数和样本Z分数公式有差异
Z分数计算例子
Z分数表格就是标准正态分布表格
Types of tables
Z tables use at least three different conventions:
-
Cumulative from mean
- gives a probability that a statistic is between 0 (mean) and Z. Example: Prob(0 ≤ Z ≤ 0.69) = 0.2549
-
Cumulative
- gives a probability that a statistic is less than Z. This equates to the area of the distribution below Z. Example: Prob(Z ≤ 0.69) = 0.7549.
-
Complementary cumulative
- gives a probability that a statistic is greater than Z. This equates to the area of the distribution above Z.
- Example: Find Prob(Z ≥ 0.69). Since this is the portion of the area above Z, the proportion that is greater than Z is found by subtracting Z from 1. That is Prob(Z ≥ 0.69) = 1 - Prob(Z ≤ 0.69) or Prob(Z ≥ 0.69) = 1 - 0.7549 = 0.2451.
Table examples[edit]
Cumulative from mean (0 to Z)[edit]
This table gives a probability that a statistic is between 0 (the mean) and Z.
z | +0.00 | +0.01 | +0.02 | +0.03 | +0.04 | +0.05 | +0.06 | +0.07 | +0.08 | +0.09 | |
---|---|---|---|---|---|---|---|---|---|---|---|
0.0 | 0.00000 | 0.00399 | 0.00798 | 0.01197 | 0.01595 | 0.01994 | 0.02392 | 0.02790 | 0.03188 | 0.03586 | |
0.1 | 0.03980 | 0.04380 | 0.04776 | 0.05172 | 0.05567 | 0.05966 | 0.06360 | 0.06749 | 0.07142 | 0.07535 | |
0.2 | 0.07930 | 0.08317 | 0.08706 | 0.09095 | 0.09483 | 0.09871 | 0.10257 | 0.10642 | 0.11026 | 0.11409 | |
0.3 | 0.11791 | 0.12172 | 0.12552 | 0.12930 | 0.13307 | 0.13683 | 0.14058 | 0.14431 | 0.14803 | 0.15173 | |
0.4 | 0.15542 | 0.15910 | 0.16276 | 0.16640 | 0.17003 | 0.17364 | 0.17724 | 0.18082 | 0.18439 | 0.18793 | |
0.5 | 0.19146 | 0.19497 | 0.19847 | 0.20194 | 0.20540 | 0.20884 | 0.21226 | 0.21566 | 0.21904 | 0.22240 | |
0.6 | 0.22575 | 0.22907 | 0.23237 | 0.23565 | 0.23891 | 0.24215 | 0.24537 | 0.24857 | 0.25175 | 0.25490 | |
0.7 | 0.25804 | 0.26115 | 0.26424 | 0.26730 | 0.27035 | 0.27337 | 0.27637 | 0.27935 | 0.28230 | 0.28524 | |
0.8 | 0.28814 | 0.29103 | 0.29389 | 0.29673 | 0.29955 | 0.30234 | 0.30511 | 0.30785 | 0.31057 | 0.31327 | |
0.9 | 0.31594 | 0.31859 | 0.32121 | 0.32381 | 0.32639 | 0.32894 | 0.33147 | 0.33398 | 0.33646 | 0.33891 | |
1.0 | 0.34134 | 0.34375 | 0.34614 | 0.34849 | 0.35083 | 0.35314 | 0.35543 | 0.35769 | 0.35993 | 0.36214 | |
1.1 | 0.36433 | 0.36650 | 0.36864 | 0.37076 | 0.37286 | 0.37493 | 0.37698 | 0.37900 | 0.38100 | 0.38298 | |
1.2 | 0.38493 | 0.38686 | 0.38877 | 0.39065 | 0.39251 | 0.39435 | 0.39617 | 0.39796 | 0.39973 | 0.40147 | |
1.3 | 0.40320 | 0.40490 | 0.40658 | 0.40824 | 0.40988 | 0.41149 | 0.41308 | 0.41466 | 0.41621 | 0.41774 | |
1.4 | 0.41924 | 0.42073 | 0.42220 | 0.42364 | 0.42507 | 0.42647 | 0.42785 | 0.42922 | 0.43056 | 0.43189 | |
1.5 | 0.43319 | 0.43448 | 0.43574 | 0.43699 | 0.43822 | 0.43943 | 0.44062 | 0.44179 | 0.44295 | 0.44408 | |
1.6 | 0.44520 | 0.44630 | 0.44738 | 0.44845 | 0.44950 | 0.45053 | 0.45154 | 0.45254 | 0.45352 | 0.45449 | |
1.7 | 0.45543 | 0.45637 | 0.45728 | 0.45818 | 0.45907 | 0.45994 | 0.46080 | 0.46164 | 0.46246 | 0.46327 | |
1.8 | 0.46407 | 0.46485 | 0.46562 | 0.46638 | 0.46712 | 0.46784 | 0.46856 | 0.46926 | 0.46995 | 0.47062 | |
1.9 | 0.47128 | 0.47193 | 0.47257 | 0.47320 | 0.47381 | 0.47441 | 0.47500 | 0.47558 | 0.47615 | 0.47670 | |
2.0 | 0.47725 | 0.47778 | 0.47831 | 0.47882 | 0.47932 | 0.47982 | 0.48030 | 0.48077 | 0.48124 | 0.48169 | |
2.1 | 0.48214 | 0.48257 | 0.48300 | 0.48341 | 0.48382 | 0.48422 | 0.48461 | 0.48500 | 0.48537 | 0.48574 | |
2.2 | 0.48610 | 0.48645 | 0.48679 | 0.48713 | 0.48745 | 0.48778 | 0.48809 | 0.48840 | 0.48870 | 0.48899 | |
2.3 | 0.48928 | 0.48956 | 0.48983 | 0.49010 | 0.49036 | 0.49061 | 0.49086 | 0.49111 | 0.49134 | 0.49158 | |
2.4 | 0.49180 | 0.49202 | 0.49224 | 0.49245 | 0.49266 | 0.49286 | 0.49305 | 0.49324 | 0.49343 | 0.49361 | |
2.5 | 0.49379 | 0.49396 | 0.49413 | 0.49430 | 0.49446 | 0.49461 | 0.49477 | 0.49492 | 0.49506 | 0.49520 | |
2.6 | 0.49534 | 0.49547 | 0.49560 | 0.49573 | 0.49585 | 0.49598 | 0.49609 | 0.49621 | 0.49632 | 0.49643 | |
2.7 | 0.49653 | 0.49664 | 0.49674 | 0.49683 | 0.49693 | 0.49702 | 0.49711 | 0.49720 | 0.49728 | 0.49736 | |
2.8 | 0.49744 | 0.49752 | 0.49760 | 0.49767 | 0.49774 | 0.49781 | 0.49788 | 0.49795 | 0.49801 | 0.49807 | |
2.9 | 0.49813 | 0.49819 | 0.49825 | 0.49831 | 0.49836 | 0.49841 | 0.49846 | 0.49851 | 0.49856 | 0.49861 | |
3.0 | 0.49865 | 0.49869 | 0.49874 | 0.49878 | 0.49882 | 0.49886 | 0.49889 | 0.49893 | 0.49896 | 0.49900 |
Cumulative[edit]
This table gives a probability that a statistic is less than Z (i.e. between negative infinity and Z).
z | +0.00 | +0.01 | +0.02 | +0.03 | +0.04 | +0.05 | +0.06 | +0.07 | +0.08 | +0.09 | |
---|---|---|---|---|---|---|---|---|---|---|---|
0.0 | 0.50000 | 0.50399 | 0.50798 | 0.51197 | 0.51595 | 0.51994 | 0.52392 | 0.52790 | 0.53188 | 0.53586 | |
0.1 | 0.53980 | 0.54380 | 0.54776 | 0.55172 | 0.55567 | 0.55966 | 0.56360 | 0.56749 | 0.57142 | 0.57535 | |
0.2 | 0.57930 | 0.58317 | 0.58706 | 0.59095 | 0.59483 | 0.59871 | 0.60257 | 0.60642 | 0.61026 | 0.61409 | |
0.3 | 0.61791 | 0.62172 | 0.62552 | 0.62930 | 0.63307 | 0.63683 | 0.64058 | 0.64431 | 0.64803 | 0.65173 | |
0.4 | 0.65542 | 0.65910 | 0.66276 | 0.66640 | 0.67003 | 0.67364 | 0.67724 | 0.68082 | 0.68439 | 0.68793 | |
0.5 | 0.69146 | 0.69497 | 0.69847 | 0.70194 | 0.70540 | 0.70884 | 0.71226 | 0.71566 | 0.71904 | 0.72240 | |
0.6 | 0.72575 | 0.72907 | 0.73237 | 0.73565 | 0.73891 | 0.74215 | 0.74537 | 0.74857 | 0.75175 | 0.75490 | |
0.7 | 0.75804 | 0.76115 | 0.76424 | 0.76730 | 0.77035 | 0.77337 | 0.77637 | 0.77935 | 0.78230 | 0.78524 | |
0.8 | 0.78814 | 0.79103 | 0.79389 | 0.79673 | 0.79955 | 0.80234 | 0.80511 | 0.80785 | 0.81057 | 0.81327 | |
0.9 | 0.81594 | 0.81859 | 0.82121 | 0.82381 | 0.82639 | 0.82894 | 0.83147 | 0.83398 | 0.83646 | 0.83891 | |
1.0 | 0.84134 | 0.84375 | 0.84614 | 0.84849 | 0.85083 | 0.85314 | 0.85543 | 0.85769 | 0.85993 | 0.86214 | |
1.1 | 0.86433 | 0.86650 | 0.86864 | 0.87076 | 0.87286 | 0.87493 | 0.87698 | 0.87900 | 0.88100 | 0.88298 | |
1.2 | 0.88493 | 0.88686 | 0.88877 | 0.89065 | 0.89251 | 0.89435 | 0.89617 | 0.89796 | 0.89973 | 0.90147 | |
1.3 | 0.90320 | 0.90490 | 0.90658 | 0.90824 | 0.90988 | 0.91149 | 0.91308 | 0.91466 | 0.91621 | 0.91774 | |
1.4 | 0.91924 | 0.92073 | 0.92220 | 0.92364 | 0.92507 | 0.92647 | 0.92785 | 0.92922 | 0.93056 | 0.93189 | |
1.5 | 0.93319 | 0.93448 | 0.93574 | 0.93699 | 0.93822 | 0.93943 | 0.94062 | 0.94179 | 0.94295 | 0.94408 | |
1.6 | 0.94520 | 0.94630 | 0.94738 | 0.94845 | 0.94950 | 0.95053 | 0.95154 | 0.95254 | 0.95352 | 0.95449 | |
1.7 | 0.95543 | 0.95637 | 0.95728 | 0.95818 | 0.95907 | 0.95994 | 0.96080 | 0.96164 | 0.96246 | 0.96327 | |
1.8 | 0.96407 | 0.96485 | 0.96562 | 0.96638 | 0.96712 | 0.96784 | 0.96856 | 0.96926 | 0.96995 | 0.97062 | |
1.9 | 0.97128 | 0.97193 | 0.97257 | 0.97320 | 0.97381 | 0.97441 | 0.97500 | 0.97558 | 0.97615 | 0.97670 | |
2.0 | 0.97725 | 0.97778 | 0.97831 | 0.97882 | 0.97932 | 0.97982 | 0.98030 | 0.98077 | 0.98124 | 0.98169 | |
2.1 | 0.98214 | 0.98257 | 0.98300 | 0.98341 | 0.98382 | 0.98422 | 0.98461 | 0.98500 | 0.98537 | 0.98574 | |
2.2 | 0.98610 | 0.98645 | 0.98679 | 0.98713 | 0.98745 | 0.98778 | 0.98809 | 0.98840 | 0.98870 | 0.98899 | |
2.3 | 0.98928 | 0.98956 | 0.98983 | 0.99010 | 0.99036 | 0.99061 | 0.99086 | 0.99111 | 0.99134 | 0.99158 | |
2.4 | 0.99180 | 0.99202 | 0.99224 | 0.99245 | 0.99266 | 0.99286 | 0.99305 | 0.99324 | 0.99343 | 0.99361 | |
2.5 | 0.99379 | 0.99396 | 0.99413 | 0.99430 | 0.99446 | 0.99461 | 0.99477 | 0.99492 | 0.99506 | 0.99520 | |
2.6 | 0.99534 | 0.99547 | 0.99560 | 0.99573 | 0.99585 | 0.99598 | 0.99609 | 0.99621 | 0.99632 | 0.99643 | |
2.7 | 0.99653 | 0.99664 | 0.99674 | 0.99683 | 0.99693 | 0.99702 | 0.99711 | 0.99720 | 0.99728 | 0.99736 | |
2.8 | 0.99744 | 0.99752 | 0.99760 | 0.99767 | 0.99774 | 0.99781 | 0.99788 | 0.99795 | 0.99801 | 0.99807 | |
2.9 | 0.99813 | 0.99819 | 0.99825 | 0.99831 | 0.99836 | 0.99841 | 0.99846 | 0.99851 | 0.99856 | 0.99861 | |
3.0 | 0.99865 | 0.99869 | 0.99874 | 0.99878 | 0.99882 | 0.99886 | 0.99889 | 0.99893 | 0.99896 | 0.99900 |
Complementary cumulative[edit]
This table gives a probability that a statistic is greater than Z.
z | +0.00 | +0.01 | +0.02 | +0.03 | +0.04 | +0.05 | +0.06 | +0.07 | +0.08 | +0.09 | |
---|---|---|---|---|---|---|---|---|---|---|---|
0.0 | 0.50000 | 0.49601 | 0.49202 | 0.48803 | 0.48405 | 0.48006 | 0.47608 | 0.47210 | 0.46812 | 0.46414 | |
0.1 | 0.46020 | 0.45620 | 0.45224 | 0.44828 | 0.44433 | 0.44034 | 0.43640 | 0.43251 | 0.42858 | 0.42465 | |
0.2 | 0.42070 | 0.41683 | 0.41294 | 0.40905 | 0.40517 | 0.40129 | 0.39743 | 0.39358 | 0.38974 | 0.38591 | |
0.3 | 0.38209 | 0.37828 | 0.37448 | 0.37070 | 0.36693 | 0.36317 | 0.35942 | 0.35569 | 0.35197 | 0.34827 | |
0.4 | 0.34458 | 0.34090 | 0.33724 | 0.33360 | 0.32997 | 0.32636 | 0.32276 | 0.31918 | 0.31561 | 0.31207 | |
0.5 | 0.30854 | 0.30503 | 0.30153 | 0.29806 | 0.29460 | 0.29116 | 0.28774 | 0.28434 | 0.28096 | 0.27760 | |
0.6 | 0.27425 | 0.27093 | 0.26763 | 0.26435 | 0.26109 | 0.25785 | 0.25463 | 0.25143 | 0.24825 | 0.24510 | |
0.7 | 0.24196 | 0.23885 | 0.23576 | 0.23270 | 0.22965 | 0.22663 | 0.22363 | 0.22065 | 0.21770 | 0.21476 | |
0.8 | 0.21186 | 0.20897 | 0.20611 | 0.20327 | 0.20045 | 0.19766 | 0.19489 | 0.19215 | 0.18943 | 0.18673 | |
0.9 | 0.18406 | 0.18141 | 0.17879 | 0.17619 | 0.17361 | 0.17106 | 0.16853 | 0.16602 | 0.16354 | 0.16109 | |
1.0 | 0.15866 | 0.15625 | 0.15386 | 0.15151 | 0.14917 | 0.14686 | 0.14457 | 0.14231 | 0.14007 | 0.13786 | |
1.1 | 0.13567 | 0.13350 | 0.13136 | 0.12924 | 0.12714 | 0.12507 | 0.12302 | 0.12100 | 0.11900 | 0.11702 | |
1.2 | 0.11507 | 0.11314 | 0.11123 | 0.10935 | 0.10749 | 0.10565 | 0.10383 | 0.10204 | 0.10027 | 0.09853 | |
1.3 | 0.09680 | 0.09510 | 0.09342 | 0.09176 | 0.09012 | 0.08851 | 0.08692 | 0.08534 | 0.08379 | 0.08226 | |
1.4 | 0.08076 | 0.07927 | 0.07780 | 0.07636 | 0.07493 | 0.07353 | 0.07215 | 0.07078 | 0.06944 | 0.06811 | |
1.5 | 0.06681 | 0.06552 | 0.06426 | 0.06301 | 0.06178 | 0.06057 | 0.05938 | 0.05821 | 0.05705 | 0.05592 | |
1.6 | 0.05480 | 0.05370 | 0.05262 | 0.05155 | 0.05050 | 0.04947 | 0.04846 | 0.04746 | 0.04648 | 0.04551 | |
1.7 | 0.04457 | 0.04363 | 0.04272 | 0.04182 | 0.04093 | 0.04006 | 0.03920 | 0.03836 | 0.03754 | 0.03673 | |
1.8 | 0.03593 | 0.03515 | 0.03438 | 0.03362 | 0.03288 | 0.03216 | 0.03144 | 0.03074 | 0.03005 | 0.02938 | |
1.9 | 0.02872 | 0.02807 | 0.02743 | 0.02680 | 0.02619 | 0.02559 | 0.02500 | 0.02442 | 0.02385 | 0.02330 | |
2.0 | 0.02275 | 0.02222 | 0.02169 | 0.02118 | 0.02068 | 0.02018 | 0.01970 | 0.01923 | 0.01876 | 0.01831 | |
2.1 | 0.01786 | 0.01743 | 0.01700 | 0.01659 | 0.01618 | 0.01578 | 0.01539 | 0.01500 | 0.01463 | 0.01426 | |
2.2 | 0.01390 | 0.01355 | 0.01321 | 0.01287 | 0.01255 | 0.01222 | 0.01191 | 0.01160 | 0.01130 | 0.01101 | |
2.3 | 0.01072 | 0.01044 | 0.01017 | 0.00990 | 0.00964 | 0.00939 | 0.00914 | 0.00889 | 0.00866 | 0.00842 | |
2.4 | 0.00820 | 0.00798 | 0.00776 | 0.00755 | 0.00734 | 0.00714 | 0.00695 | 0.00676 | 0.00657 | 0.00639 | |
2.5 | 0.00621 | 0.00604 | 0.00587 | 0.00570 | 0.00554 | 0.00539 | 0.00523 | 0.00508 | 0.00494 | 0.00480 | |
2.6 | 0.00466 | 0.00453 | 0.00440 | 0.00427 | 0.00415 | 0.00402 | 0.00391 | 0.00379 | 0.00368 | 0.00357 | |
2.7 | 0.00347 | 0.00336 | 0.00326 | 0.00317 | 0.00307 | 0.00298 | 0.00289 | 0.00280 | 0.00272 | 0.00264 | |
2.8 | 0.00256 | 0.00248 | 0.00240 | 0.00233 | 0.00226 | 0.00219 | 0.00212 | 0.00205 | 0.00199 | 0.00193 | |
2.9 | 0.00187 | 0.00181 | 0.00175 | 0.00169 | 0.00164 | 0.00159 | 0.00154 | 0.00149 | 0.00144 | 0.00139 | |
3.0 | 0.00135 | 0.00131 | 0.00126 | 0.00122 | 0.00118 | 0.00114 | 0.00111 | 0.00107 | 0.00104 | 0. |
5.中心极限定理
中心极限定理目录
1.计算机模拟-中心极限理论
2.中心极限理论与中性突变(进化论)
3.中心极限理论与职场 面试
简易教程
https://www.youtube.com/watch?v=LVFC2f9kHq4
测试随机数的网站
https://www.random.org/dice/?num=6
概念
随机扔6个骰子
把数据存入excel表格
绘制成图,呈现正态分布
1.计算机模拟-中心极限理论
灵感来源于两颗骰子 中心极限理论是数学和概率学的基石,今天有机会能计算机模拟和辅助证明,是我荣幸。
用两颗骰子建模,是中心极限定理最简单模型,可以这样解释,中间数出现频率最高,因为多个因素可随机组合成大数,例如投掷两颗骰子,7可以由6+1,2+5,4+3组成, 3只能由1+2组成,11只能由5+6组成
![图片](https://i-blog.csdnimg.cn/blog_migrate/da5cba8d5feec91d7244b31f6531ffca.png)
![图片](https://i-blog.csdnimg.cn/blog_migrate/e376a2f4d3133df7d0600b322ca587cd.png)
![图片](https://i-blog.csdnimg.cn/blog_migrate/cdf8dca7ac3a5fea4f034f86f38397c8.png)
![图片](https://i-blog.csdnimg.cn/blog_migrate/004972ab8a80c28141474f85826cb555.png)
![图片](https://i-blog.csdnimg.cn/blog_migrate/79d5bfee3322ca3300a47dd5cbdd585a.png)
![图片](https://i-blog.csdnimg.cn/blog_migrate/9582ba290fba66cbf1dc2dc25834dd3b.png)
![图片](https://i-blog.csdnimg.cn/blog_migrate/cb2bf63590f5564ff5f9ba3b3cde5464.png)
![图片](https://i-blog.csdnimg.cn/blog_migrate/6840e55baeb3f579302c7d3c894311e2.png)
![图片](https://i-blog.csdnimg.cn/blog_migrate/0f2523cd120312d584e5d60508115c8a.png)
![图片](https://i-blog.csdnimg.cn/blog_migrate/f19fbe7bd8cf075bcc1af13821e45dbe.png)
![图片](https://i-blog.csdnimg.cn/blog_migrate/a3d5797f8f9ceef094249fa54f3513f3.png)
![图片](https://i-blog.csdnimg.cn/blog_migrate/dda669ec3953f6578bcb83a7250201a8.png)
![图片](https://i-blog.csdnimg.cn/blog_migrate/9f4d208822485b2d4eb5ef4ab7bb8da4.png)
#coding=utf-8
import random,os,statistics
import matplotlib.pyplot as plt
from matplotlib.font_manager import FontProperties
plt.figure(20)
#设置中文字体
font=FontProperties(fname=r"c:\windows\fonts\simsun.ttc",size=15)
#骰子选数范围从1-6
number_list=[1,2,3,4,5,6]
#n试验次数
n=1000
#length 表示样本数
length=2
def Random_number(number_list):
r=random.SystemRandom()
random_number=r.choice(number_list)
return random_number
#生成一个包含随机数的列表
#length样本数
def Random_list(length):
random_list=[]
for i in range(length):
random_number=Random_number(number_list)
random_list.append(random_number)
return random_list
'''
Random_list(10)
Out[22]: [3, 1, 2, 3, 4, 6, 4, 4, 2, 1]
'''
#n试验次数
#length样本数
def Mean_list(length,n1):
mean_list=[]
for i in range(n1):
random_list=Random_list(length)
mean=statistics.mean(random_list)
mean_list.append(mean)
return mean_list
'''
Mean_list(10)
Out[26]: [4.0, 3.5, 6.0, 4.5, 4.0, 4.0, 5.0, 4.0, 5.0, 2.0]
'''
#生成一组样本平均数
#n试验次数
#length样本数
mean_list=Mean_list(30,10000)
#绘图
plt.hist(mean_list)
titleValue="central limit theorem\n n=%d,length=%d" %(n,length)
plt.xlabel("平均值",fontproperties=font)
plt.ylabel("频率",fontproperties=font)
plt.title(titleValue)
#plt.xlabel("mean")
plt.show()
样本乘积不符合中心极限定理,图像不是正太分布
![图片](https://i-blog.csdnimg.cn/blog_migrate/f5555deb3cafe1755ae04b5411f32e11.png)
#coding=utf-8
import random,os,statistics
import matplotlib.pyplot as plt
from matplotlib.font_manager import FontProperties
plt.figure(20)
#设置中文字体
font=FontProperties(fname=r"c:\windows\fonts\simsun.ttc",size=15)
#骰子选数范围从1-6
number_list=[1,2,3,4,5,6]
#n试验次数
n=100
#length 表示样本数
length=5
def Random_number(number_list):
r=random.SystemRandom()
random_number=r.choice(number_list)
return random_number
#生成一个包含随机数的列表
#length样本数
def Random_list(length):
random_list=[]
for i in range(length):
random_number=Random_number(number_list)
random_list.append(random_number)
return random_list
'''
Random_list(10)
Out[22]: [3, 1, 2, 3, 4, 6, 4, 4, 2, 1]
'''
#n试验次数
#length样本数
#样本平均数
def Mean_list(length,n1):
mean_list=[]
for i in range(n1):
random_list=Random_list(length)
mean=statistics.mean(random_list)
mean_list.append(mean)
return mean_list
'''
Mean_list(10)
Out[26]: [4.0, 3.5, 6.0, 4.5, 4.0, 4.0, 5.0, 4.0, 5.0, 2.0]
'''
def Multiply(list1):
value=1
for i in list1:
value=value*i
return value
#n试验次数
#length样本数
#样本乘积
def Multiply_list(length,n1):
multiply_list=[]
for i in range(n1):
random_list=Random_list(length)
multiply=Multiply(random_list)
multiply_list.append(multiply)
return multiply_list
#生成一组样本乘积
#n试验次数
#length样本数
multiply_list=Multiply_list(length,n)
#绘图
plt.hist(multiply_list)
titleValue="central limit theorem\n n=%d,length=%d" %(n,length)
plt.xlabel("平均值",fontproperties=font)
plt.ylabel("频率",fontproperties=font)
plt.title(titleValue)
#plt.xlabel("mean")
plt.show()
样本总和分布也呈现中心极限定理,这可以推断多个基因值叠加,也符合正态分布,进一步支持中性突变定理
![图片](https://i-blog.csdnimg.cn/blog_migrate/41345dfef7015b1f186a909e9a0ad58a.png)
#coding=utf-8
import random,os,statistics
import matplotlib.pyplot as plt
from matplotlib.font_manager import FontProperties
plt.figure(20)
#设置中文字体
font=FontProperties(fname=r"c:\windows\fonts\simsun.ttc",size=15)
#骰子选数范围从1-6
number_list=[1,2,3,4,5,6]
#n试验次数
n=10000
#length 表示样本数
length=30
def Random_number(number_list):
r=random.SystemRandom()
random_number=r.choice(number_list)
return random_number
#生成一个包含随机数的列表
#length样本数
def Random_list(length):
random_list=[]
for i in range(length):
random_number=Random_number(number_list)
random_list.append(random_number)
return random_list
'''
Random_list(10)
Out[22]: [3, 1, 2, 3, 4, 6, 4, 4, 2, 1]
'''
#n试验次数
#length样本数
def Add_list(length,n1):
total_list=[]
for i in range(n1):
random_list=Random_list(length)
total=sum(random_list)
total_list.append(total)
return total_list
'''
Mean_list(10)
Out[26]: [4.0, 3.5, 6.0, 4.5, 4.0, 4.0, 5.0, 4.0, 5.0, 2.0]
'''
#生成一组样本平均数
#n试验次数
#length样本数
total_list=Add_list(length,n)
#绘图
plt.hist(total_list)
titleValue="central limit theorem\n n=%d,length=%d" %(n,length)
plt.xlabel("平均值",fontproperties=font)
plt.ylabel("频率",fontproperties=font)
plt.title(titleValue)
#plt.xlabel("mean")
plt.show()
达尔文进化论有局限性,在分子层面发生的突变,如果不考虑对生殖不利的话,基本上都是无所谓有利还是不利的“中性突变”,有利的突变其实非常少,简直可以忽略不计。
Neutral mutations are changes in DNA sequence that are neither beneficial nor detrimental to the ability of an organism to survive and reproduce.
![图片](https://i-blog.csdnimg.cn/blog_migrate/851dca35b4344b13dae5c3fabdb52874.png)
![图片](https://i-blog.csdnimg.cn/blog_migrate/291720f0d7d98317c414b24df0edc4f0.png)
3.中心极限理论与职场 面试
中心极限理论同样适用于职场面试。(排除关系户和考试排名算分因素)
假如一个部门经理招1个人,有10个面试者。部门经理要从10个面试者中选取1位。
能力太差的不能胜任工作,pass。 能力太强的他hold不住,担心以后饭碗被翘或担心此人嫌弃此岗位而跳槽,也pass。
面试概率最大的能力居中的面试者,平庸的人部门经理既能把控,又能胜任工作。
所以我推测,大多数公司里能力超强的人和能力超弱的人不会太多,只占正态分布两端(低概率)。能力居中的人占大多数。不相信的可以去做调查问卷。
所以想去社工一个公司,就装得能力一般但又能胜任工作,这样混过面试官概率最高。。。。。
当然实际情况中众多因素需要考虑,不能一概而论。例如长相,关系户,考试分数排名,家住地址等等。。。。。
总结
万物皆有数,自然现象皆可建模,近似推导,但又不能准确模拟,因为参与因素实在太多了。且众多因素相互交错影响,不停变化,这造成了不可预测性。这就是说数字即可推算也不可预测。听起来是不是有点矛盾。。。吃饭去了。。。
![图片](https://i-blog.csdnimg.cn/blog_migrate/ffecefed1fcefd9ad86a95b56fde6098.png)
一位数学家调查发现,欧洲各地男婴与女婴的出生比例是22:21,只有巴黎是25:24,这极小的差别使他决心去查个究竟。最后发现,当时的巴黎的风尚是重女轻男,有些人会丢弃生下的男婴,经过一番修正后,依然是22:21。中国的历次人口普查的结果也是22:21。
人口比例所体现的,就是大数法则。
大数法则(Lawoflargenumbers)又称“大数定律”或“平均法则”。在随机事件的大量重复出现中,往往呈现几乎必然的规律,这类规律就是大数法则。在试验不变的条件下,重复试验多次,随机事件的概率近似于它的概率。
大数法则反映了这世界的一个基本规律:在一个包含众多个体的大群体中,由于偶然性而产生的个体差异,着眼在一个个的个体上看,是杂乱无章、毫无规律、难于预测的。但由于大数法则的作用,整个群体却能呈现某种稳定的形态。
花瓶是由分子组成,每个分子都不规律地剧烈震动。你可曾见过一只放在桌子上的花瓶,突然自己跳起来?
电流是由电子运动形成的,每个电子的行为杂乱而不可预测,但整体看呈现一个稳定的电流强度。
一个封闭容器中的气体,它包含大量的分子,它们各自在每时每刻的位置、速度和方向,都以一种偶然的方式在变化着,但容器中的气体仍能保有一个稳定的压力和温度。
某个人乘飞机遇难,概率不可预料,对于他个人来说,飞机失事具有随机性。
但是对每年100万人次所有乘机者而言,这里的100万人可以理解这100万次的重复试验,其中,总有10人死于飞行事故。那么根据大数法则,乘飞机出事故的概率大约为十万分之一。
这就为保险公司收取保险费提供了理论依据。对个人来说,出险是不确定的,对保险公司来说,众多的保单出险的概率是确定的。
根据大数法则的定律,承保危险的单位越多,损失概率的偏差越小,反之,承保危险的单位越少,损失概率的偏差越大。因此,保险公司运用大数法则就可以比较精确地预测危险,合理保险费率。
2、小刀锯大树
赌客久赌必输的另一个秘密,即大数法则。
赌王何鸿燊刚刚接手葡京赌场的时候,业务蒸蒸日上。
赌王居安思危,请教“赌神”叶汉:“为什么这些赌客总是输,长此以往他们不来赌怎么办?”
叶汉笑道:“这世界每天都死人,你可见这世上少人?”
叶汉的回答甚妙,道出了一条无论是保险公司、赌场还是骗徒,都信仰的法则:大数法则。
赌场本质上是一种温和的“概率场”,概率法则非常明显。一直玩下去,大数法则的作用就会日益显现出来。
庄家在规则上占有少许优势,玩的次数越多,这种优势越能显现出来。
久赌神仙输,赌圣也不行。
一天,一位沙特王子入住葡京酒店。
王子找到赌王,说:我就和你玩一把掷硬币。出正面我给你50亿美元,出反面你的赌场归我。
赌王呵呵一笑:这个游戏固然公平,但不符合我们博彩业的行事法则。
我们开赌场不做一锤子买卖,而是小刀锯大树。如果你真的想玩,我们就玩掷骰子,1000下定输赢。你赢了,可以把我的产业拿走,我赢了,只收你20亿。
沙特王子无奈,只好退出赌局。
这个故事是虚构的,旨在说明大数法则之于赌场的意义。
开赌场不做一锤子买卖,而是“小刀锯大树”。
所以,赌场最欢迎的是斤斤计较、想碰一下运气的散客,他们虽然下注谨慎,却构成了庞大的行为基数。
这种客人会给赌场老板带来几乎线性的稳定收益,是赌场最稳定的收入来源,这是大数法则在起作用。
还有一种是一掷千金、豪气干云的大赌客,他们的下注额若在赌场的风险控制范围,也很难从赌场赢钱,会成为赌场的VIP客户。
假如有一个超级赌客,比如上面虚构故事中的沙特王子。他的赌注超过了普通赌客的千倍万倍,这会导致赌场收益的大幅震荡,极端情况下可能导致赌场破产。
因此,全世界所有赌场都会设定最高的投注限额。赌场设最低及最高的投注限额,即便“新郎行运一条龙”的事故发生,也不至于让赌场亏太多。这样,赌场老板就可以安心睡觉了。
所有的VIP加起来,等于庄家和客人玩了一场长期游戏,大数法则依然有效。
3、“撞骗”的数理依据
你是否收到过这类短信:
请直接把钱打到工商银行卡号6220219 ***
这叫“撞骗”,是一种传统骗术。版本甚多,比如寄中奖信、打中奖电话、发电子邮件。
也就是骗子像没头苍蝇一样乱撞,“有枣没枣打一杆子”或许能“瞎猫捡个死老鼠”。
是不是觉得骗子很蠢?但骗徒的行为却是合乎统计原理的,在数理上是被支持的。
只要发出的短信足够多,其成功率非常稳定,合乎大数法则。
福建的某个小镇,众多乡亲都从事这个行当,短信群发器在这个偏远小镇非常普及。
当警察抓获了这批刁民后,奇怪的是,过了很长时间了,居然还有人不断地往查获的卡上汇钱。
有人曾做过统计,类似这种垃圾短信,每发出一万条,上当的人有七到八个,成功率非常稳定。人过一百,形形色色。一万个人里面,总会有几个“人精”,几个笨蛋,这是可以确定的。
究其根源,都是由于大数法则的作用。在社会、经济领域中,群体中个体的状况千差万别,变化不定。但一些反映群体的平均指针,在一定时期内能保持稳定或呈现规律性的变化。
大数法则是保险公司、赌场、撞骗的骗徒,赖以存在的基础
#大数定理模拟
![图片](https://i-blog.csdnimg.cn/blog_migrate/3f0e782790ceb3467b6374a13a7d8316.png)
![图片](https://i-blog.csdnimg.cn/blog_migrate/31f7d3e3c9f8ae3ea80cffe6585f1bac.png)
实验次数越多,概率越接近平均概率(期望值)
![图片](https://i-blog.csdnimg.cn/blog_migrate/665e299ae63969569884fb697b125581.png)
8.你的数据是正态分布吗
统计很多分析是基于正态分布数据,如果数据不呈现正态分布就要出错
为了避免出错,首先让你的数据可视化
符合正态分布的箱型图
符合正态分布的p-p图
不符合正态分布的箱型图
不符合正态分布的Q-Q图