test_list=[26,33,65,28,34,55,25,44,50,36,26,37,43,62,35,38,45,32,28,34] test_value=10 avg=numpy.mean(test_list) stdd=numpy.std(test_list) print(stdd)
#计算test_value这个值落入的是正态分布的哪个区间 probability=norm.cdf(x=test_value, loc=avg, scale=stdd) print(probability) if test_value < avg and probability < 0.003: print("异常点!") elif test_value > avg and probability> 0.997: print("异常点!") else: print("正常点!")
#计算0.997这个概率在这个正常分布里对应的是什么值 print(norm.ppf(0.997,loc=avg, scale=stdd)) print(norm.cdf(x=norm.ppf(0.997,loc=avg, scale=stdd), loc=avg, scale=stdd))