pandas /scipy/numpy是否提供累积标准偏差函数? [英] Does pandas/scipy/numpy provide a cumulative standard deviation function?
本文介绍了 pandas /scipy/numpy是否提供累积标准偏差函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个熊猫系列.我需要得到sigma_i,这是直到索引i的序列的标准偏差.是否有任何现有功能可以有效地进行计算?
I have a pandas series. I need to get sigma_i, which is the standard deviation of a series up to index i. Is there any existing function which efficiently calculates that?
我注意到有cummax,cummin函数.
I noticed that there are cummax, cummin functions.
推荐答案
请参见pandas.expanding_std
.
例如:
import numpy as np
import matplotlib.pyplot as plt
import pandas
%matplotlib inline
data = pandas.Series(np.random.normal(size=37))
full_std = np.std(data)
expand_std = pandas.expanding_std(data, min_periods=1)
fig, ax = plt.subplots()
expand_std.plot(ax=ax, color='k', linewidth=1.5, label='Expanded Std. Dev.')
ax.axhline(y=full_std, color='g', label='Full Value')
ax.legend()
糟糕,忘记了图片:
这篇关于 pandas /scipy/numpy是否提供累积标准偏差函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文