pandas Python:生成具有趋势的随机时间序列数据(例如周期性、指数衰减等)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/47542752/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Python: Generate random time series data with trends (e.g. cyclical, exponentially decaying etc)
提问by muazfaiz
I am trying to generate some random time series with trends like cyclical (e.g. sales), exponentially decreasing (e.g. facebook likes on a post), exponentially increasing (e.g. bitcoin prices), generally increasing (stock tickers) etc. I can generate generally increasing/decreasing time series with the following
我正在尝试生成一些随机时间序列,其趋势有周期性(例如销售)、呈指数下降(例如 Facebook 喜欢帖子)、呈指数增长(例如比特币价格)、普遍增加(股票行情)等。我可以生成普遍增加/减少时间序列如下
import numpy as np
import pandas as pd
from numpy import sqrt
import matplotlib.pyplot as plt
vol = .030
lag = 300
df = pd.DataFrame(np.random.randn(100000) * sqrt(vol) * sqrt(1 / 252.)).cumsum()
plt.plot(df[0].tolist())
plt.show()
But I don't know how to generate cyclical trends or exponentially increasing or decreasing trends. Is there a way to do this ?
但我不知道如何产生周期性趋势或指数增加或减少的趋势。有没有办法做到这一点 ?
回答by SemanticBeeng
You may want to evaluate TimeSynth
你可能想评估 TimeSynth
"TimeSynth is an open source library for generating synthetic time series for *model testing*. The library can generate regular and irregular time series. The architecture allows the user to match different *signals* with different architectures allowing a vast array of signals to be generated. The available *signals* and *noise* types are listed below."
“TimeSynth 是一个开源库,用于为*模型测试*生成合成时间序列。该库可以生成规则和不规则的时间序列。该架构允许用户将不同的*信号*与不同的架构相匹配,从而允许大量的信号被生成。可用的*信号*和*噪声*类型如下所列。”