statsmodels.distributions.empirical_distribution.ECDFDiscrete

class statsmodels.distributions.empirical_distribution.ECDFDiscrete(x, freq_weights=None, side='right')[source]

返回数组的加权经验累积分布函数作为一个阶梯函数。

Parameters:
xarray_like

数据值。如果 freq_weights 为 None,则 x 被视为观测值,并且使用 nunpy.unique 计算唯一值的频率计数来计算经验累积分布函数(ecdf)。 如果 freq_weights 不为 None,则 x 将被视为质量点分布的支持,freq_weights 作为 x 值的计数。 x 值可以是任意可排序的值,不需要是整数。

freq_weightsarray_like

观测值的权重。sum(freq_weights) 被解释为 confint 的 nobs。 如果 freq_weights 为 None,则将从数据 x 中计算唯一值的频率计数。

side{‘left’, ‘right’}, optional

默认值为‘right’。定义构成步骤的区间的形状。‘right’对应于[a, b)区间,‘left’对应于(a, b]区间。

方法

__call__(时间)

将自身作为函数调用。

Returns:
Weighted ECDF as a step function.

示例

>>> import numpy as np
>>> from statsmodels.distributions.empirical_distribution import (
>>>     ECDFDiscrete)
>>>
>>> ewcdf = ECDFDiscrete([3, 3, 1, 4])
>>> ewcdf([3, 55, 0.5, 1.5])
array([0.75, 1.  , 0.  , 0.25])
>>>
>>> ewcdf = ECDFDiscrete([3, 1, 4], [1.25, 2.5, 5])
>>>
>>> ewcdf([3, 55, 0.5, 1.5])
array([0.42857143, 1., 0. , 0.28571429])
>>> print('e1 and e2 are equivalent ways of defining the same ECDF')
e1 and e2 are equivalent ways of defining the same ECDF
>>> e1 = ECDFDiscrete([3.5, 3.5, 1.5, 1, 4])
>>> e2 = ECDFDiscrete([3.5, 1.5, 1, 4], freq_weights=[2, 1, 1, 1])
>>> print(e1.x, e2.x)
[-inf  1.   1.5  3.5  4. ] [-inf  1.   1.5  3.5  4. ]
>>> print(e1.y, e2.y)
[0.  0.2 0.4 0.8 1. ] [0.  0.2 0.4 0.8 1. ]

方法


Last update: Oct 16, 2024