[英]Python: Scipy confidence interval
I am new to Python and i wanted to programm a confidence intervall.我是 Python 的新手,我想编写一个置信区间。 This is the code i used:
这是我使用的代码:
conf= st.t.interval(alpha=0.95, df=len(df)-1, loc=np.mean(df_efw).mean(), scale=st.sem(df.stack()))
There is actually no problem with the code, it works.代码实际上没有问题,它可以工作。 However, i found it somewhere but i simply dont understand it.
但是,我在某个地方找到了它,但我根本不明白。 I am using 95% confidence interval, therefore my alpha is 5%.
我使用的是 95% 的置信区间,因此我的 alpha 为 5%。 Why do i have to write
alpha = 0.95
?.为什么我必须写
alpha = 0.95
? And why do i have to write -1
in the len(df)
.以及为什么我必须在
len(df)
中写-1
。 What i also dont understand is the loc
and scale
.我也不明白的是
loc
和scale
。
I bet the first df
in df=len(df)-1
stands for degrees of freedom rather than dataframe.我敢打赌
df=len(df)-1
中的第一个df
代表自由度,而不是 dataframe。 Degrees of freedom is n (the number of observations) - 1 in almost all cases, so that tracks.在几乎所有情况下,自由度都是 n(观察次数)- 1,因此可以跟踪。
I'd recommend going directly to the source and searching the scipy documentation if that's what you're using.我建议您直接访问源代码并搜索scipy 文档(如果您正在使用该文档)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.