def sample_size_cal(interval, N, alpha=0.05):
    '调研样本量的计算\n    参考：https://www.surveysystem.com/sscalc.htm\n    sample_size_cal(interval,N,alpha=0.05)\n    输入：\n    interval: 误差范围,例如0.03\n    N: 总体的大小,一般1万以上就没啥差别啦\n    alpha：置信水平，默认95%\n    '
    import scipy.stats as stats
    p = stats.norm.ppf((1 - (alpha / 2)))
    if (interval > 1):
        interval = (interval / 100)
    samplesize = (((p ** 2) / 4) / (interval ** 2))
    if N:
        samplesize = ((samplesize * N) / (samplesize + N))
    samplesize = int(round(samplesize))
    return samplesize
调研样本量的计算
参考：https://www.surveysystem.com/sscalc.htm
sample_size_cal(interval,N,alpha=0.05)
输入：
interval: 误差范围,例如0.03
N: 总体的大小,一般1万以上就没啥差别啦
alpha：置信水平，默认95%
def sample_size_cal(interval, N, alpha=0.05):
    '调研样本量的计算\n    参考：https://www.surveysystem.com/sscalc.htm\n    sample_size_cal(interval,N,alpha=0.05)\n    输入：\n    interval: 误差范围,例如0.03\n    N: 总体的大小,一般1万以上就没啥差别啦\n    alpha：置信水平，默认95%\n    '
    import scipy.stats as stats
    p = stats.norm.ppf((1 - (alpha / 2)))
    if (interval > 1):
        interval = (interval / 100)
    samplesize = (((p ** 2) / 4) / (interval ** 2))
    if N:
        samplesize = ((samplesize * N) / (samplesize + N))
    samplesize = int(round(samplesize))
    return samplesize