Python 计算置信区间
来源:互联网 发布:网络空间拟态防御 编辑:程序博客网 时间:2024/05/17 02:10
Python 计算置信区间
用Python实现http://vassarstats.net/prop1.html 所计算的置信区间
import math#计算置信区间的函数def calc(r,n):if n < r :print ('r cannot be greater than n.')return if math.floor(r) < r :print ('r must be an integer value.')return if math.floor(n) < n :print ('n must be an integer value.')returnp = round((r/n)*10000)/10000print ('p',p)q = 1-pp = round(p*10000)/10000print ('p',p)z=1.95996zsq = z*z# l95anum = (2*n*p)+zsq-(z*math.sqrt(zsq+(4*n*p*q)))denom = 2*(n+zsq)l95a = num/denomif p == 0 :l95a = 0l95a = round(l95a*10000)/10000# u95anum = (2*n*p)+zsq+(z*math.sqrt(zsq+(4*n*p*q)))denom = 2*(n+zsq)u95a = num/denomprint ('u95a',u95a)if p == 1 :u95a = 1u95a = round(u95a*10000)/10000print('no continuity correction',l95a,'-',u95a)# l95bnum = (2*n*p)+zsq-1-(z*math.sqrt(zsq-2-(1/n)+4*p*((n*q)+1)))denom = 2*(n+zsq)l95b = num/denomif p==0 :l95b = 0l95b = round(l95b*100000000)/100000000# u95bnum = (2*n*p)+zsq+1+(z*math.sqrt(zsq+2-(1/n)+4*p*((n*q)-1)))denom = 2*(n+zsq)u95b = num/denomif p==1 :u95b = 1u95b = round(u95b*100000000)/100000000print('including continuity correction',l95b,'-',u95b)return#测试k = 12 n = 40calc(12,40)print('THE END')
0 0
- Python 计算置信区间
- 参数估计--置信区间计算
- 二项分布比例的置信区间计算
- 置信区间
- 置信区间
- 置信区间
- python t分布的双侧置信区间
- 求置信区间
- 统计分析:置信区间
- Greedy Match学习笔记二 —— 安慰剂检验与置信区间计算
- 置信区间(confidence interval)
- 参数估计与置信区间
- 如何理解 95% 置信区间?
- 理解置信区间和置信水平
- 置信区间、置信水平、边际误差
- 概率统计基础-置信区间
- 置信区间的总结
- MATLAB对置信区间绘制
- 【OSG】初识OSG
- android 滑动侧边栏 SlideMenu 源码分析 以及使用手册
- Python实现KNN算法
- 写论文与做菜的比较
- C异常处理机制:setjmp和longjmp
- Python 计算置信区间
- Android的sdk、api及工程目录说明
- Android学习笔记之Theme主题的修改设置
- ZOJ 3793 First Digit (逗比题)
- 数据库Sharding的基本思想和切分策略
- mysql命令行修改字符编码
- oracle 最新patch补丁号
- C++4种类型转换
- Android Camera 架构