Python:生成具有趋势的随机时间序列数据(例如周期性、指数衰减等)

2022-01-11 00:00:00 python numpy pandas time-series random

问题描述

我正在尝试生成一些随机时间序列,其趋势包括周期性(例如销售)、指数下降(例如 Facebook 帖子上的点赞数)、指数增加(例如比特币价格)、普遍增加(股票行情)等.我可以生成一般递增/递减的时间序列,如下

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

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 ?


解决方案

你可能想要评估 TimeSynth

You may want to evaluate TimeSynth

TimeSynth 是一个开源库,用于为*模型测试*生成合成时间序列.该库可以生成规则和不规则时间序列.该架构允许用户将不同的*信号*与不同的架构匹配,从而允许要生成的大量信号.下面列出了可用的 *signals* 和 *noise* 类型."

相关文章