python正太分布概率计算
#numpy库的标准正太分布概率分布(针对连续性概率事件)
#rand 针对离散型概率事件
a=np.random.randn(500000) #标准正太分布
pos_min = (a>=-1) #下限
pos_max = (a<=1) #上限
pos_rst = pos_min & pos_max #布尔类型(与逻辑应用)
b=np.where(pos_rst == True) #取数
print(len(b[0])/500000) #分布概率
print(b[0]) #索引位置
print(a[b[0]]) #索引数值
print(len(a[b[0]])/500000) #分布概率
0.683502
[ 0 2 3 … 499997 499998 499999]
[ 0.71831471 -0.72231127 -0.13830229 … 0.15320099 0.18143176
-0.09009111]
0.683502
#numpy库的标准正太分布概率分布(针对连续性概率事件)
#rand 针对离散型概率事件
a=np.random.rand(500000) #标准正太分布
pos_min = (a>=0) #下限
pos_max = (a<0.1) #上限
pos_rst = pos_min & pos_max #布尔类型(与逻辑应用)
b=np.where(pos_rst == True) #取数
print(len(b[0])/500000) #分布概率
print(b[0]) #索引位置
print(a[b[0]]) #索引数值
print(len(a[b[0]])/500000) #分布概率
0.099926
[ 14 27 48 … 499970 499983 499996]
[0.01381421 0.09086238 0.07473726 … 0.05464653 0.04296445 0.09926393]
0.099926