📜  np 置信区间 - Python 代码示例

📅  最后修改于: 2022-03-11 14:46:37.601000             🧑  作者: Mango

代码示例1
import numpy as np
import scipy.stats


def mean_confidence_interval(data, confidence=0.95):
    a = 1.0 * np.array(data)
    n = len(a)
    m, se = np.mean(a), scipy.stats.sem(a)
    h = se * scipy.stats.t.ppf((1 + confidence) / 2., n-1)
    return m, m-h, m+h