Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何计算sem()?_Python_Python 3.x_Pandas - Fatal编程技术网

Python 如何计算sem()?

Python 如何计算sem()?,python,python-3.x,pandas,Python,Python 3.x,Pandas,首先导入熊猫并创建具有完美正态分布的系列: import pandas as pd lst = [[5 for x in range(5)], [4 for x in range(4)], [3 for x in range(3)], [2 for x in range(2)], [1 for x in range(1)], [2 for x in range(2)], [3 for x in range(3)], [4 for x in range(4)], [5

首先导入熊猫并创建具有完美正态分布的系列:

import pandas as pd

lst = [[5 for x in range(5)], [4 for x in range(4)], [3 for x in range(3)],
       [2 for x in range(2)], [1 for x in range(1)], [2 for x in range(2)],
       [3 for x in range(3)], [4 for x in range(4)], [5 for x in range(5)]]

lst = [item for sublists in lst for item in sublists]

series = pd.Series(lst)
让我们检查一下,分布是否正常:

print(round(sum(series - series.mean()) / series.count(), 1) == 0)
# if distribution is normal we'll see True
现在让我们打印宇宙的sem():

print(series.sem(ddof=0))
# 0.21619987017
现在查看示例:

print(series.sem()) # ddof=1
# 0.220026713637
但我不明白熊猫如何计算标准误差的平均值,若它和宇宙。它有用吗

se_x = sd_x / sqrt(len(x))
还是创建样本?如果它创建了样本,我可以设置它们的数量和方式

如果计数<30,熊猫如何计算样本的sem?

:

您可能还希望检查模块中可用的方法

    cls.sem = _make_stat_function_ddof(
        cls, 'sem', name, name2, axis_descr,
        "Return unbiased standard error of the mean over requested "
        "axis.\n\nNormalized by N-1 by default. This can be changed "
        "using the ddof argument",
        nanops.nansem)
@disallow('M8', 'm8')
def nansem(values, axis=None, skipna=True, ddof=1):
    var = nanvar(values, axis, skipna, ddof=ddof)

    mask = isnull(values)
    if not is_float_dtype(values.dtype):
        values = values.astype('f8')
    count, _ = _get_counts_nanvar(mask, axis, ddof, values.dtype)
    var = nanvar(values, axis, skipna, ddof=ddof)

    return np.sqrt(var) / np.sqrt(count)