简体   繁体   中英

Python: Generate random time series data with trends (e.g. cyclical, exponentially decaying etc)

I am trying to generate some random time series with trends like cyclical (eg sales), exponentially decreasing (eg facebook likes on a post), exponentially increasing (eg 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 ?

You may want to evaluate 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."

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM