Scipy - z 值的两个尾部 ppf 函数? [英] Scipy - two tail ppf function for a z value?

查看:41
本文介绍了Scipy - z 值的两个尾部 ppf 函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 scipy.stat.norm 中的 ppf 函数,我得到一个单尾结果,例如,ppf(.95) 给出 1.644... 而不是 1.96... 应该得到一个双尾分布.

Using the ppf function from scipy.stat.norm, I get a one-tail result, for example, ppf(.95) gives off 1.644... rather than 1.96... a two-tail distribution should get.

scipy 中是否有基于 p 值给出双尾 z 分数的函数?

Is there a function in scipy that gives off a two-tailed z-score based on the p-value?

推荐答案

您要找的很简单

In [12]: def normz(val):
   ....:     return scipy.stats.norm.ppf((1+val)/2)
   ....: 
In [13]: normz(0.95)
Out[13]: 1.959963984540054

这是因为正态分布的对称性质.95% 的置信区间覆盖了 95% 的正态曲线,因此获得 95% 之外的值的概率小于 5%(由于其形状).那么回忆一下正态曲线是对称的,每条尾部的面积相当于

This is because of the symmetric nature of the normal distribution. A 95% confidence interval covers 95% of the normal curve, and as a result the probability of acquiring a value outside this 95% is less than 5% (due to its shape). Then recalling that the normal curve is symmetric, the area in each tail is equivalent to

所以在你的情况下,每个尾部的面积是 0.025.

so in your case, the area in each tail is 0.025.

因此,为了将 scipy.stats.normal.ppf()C 一起使用,您必须使用 对称em> 正态分布的性质和

As a result, in order to use scipy.stats.normal.ppf() with C, you must use the symmetric nature of the normal distribution and

获得合适的下/上尾概率 0.975scipy.stats.norm.ppf() 一起使用.此图可以帮助您将概念形象化.

to obtain a suitable lower/upper tail probability 0.975 to use with scipy.stats.norm.ppf(). This graph could help you visualize the concept.

这篇关于Scipy - z 值的两个尾部 ppf 函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆