本文介绍了numpy/scipy 等效于 R ecdf(x)(x) 函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在 numpy 或 scipy 中,Python 中 R 的 ecdf(x)(x)
函数的等价物是什么?ecdf(x)(x)
与:
What is the equivalent of R's ecdf(x)(x)
function in Python, in either numpy or scipy? Is ecdf(x)(x)
basically the same as:
import numpy as np
def ecdf(x):
# normalize X to sum to 1
x = x / np.sum(x)
return np.cumsum(x)
还是需要其他东西?
EDIT 如何控制 ecdf
使用的 bin 数量?
EDIT how can one control the number of bins used by ecdf
?
推荐答案
试试这些链接:
示例代码
import numpy as np
from statsmodels.distributions.empirical_distribution import ECDF
import matplotlib.pyplot as plt
data = np.random.normal(0,5, size=2000)
ecdf = ECDF(data)
plt.plot(ecdf.x,ecdf.y)
这篇关于numpy/scipy 等效于 R ecdf(x)(x) 函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!