mardi 28 novembre 2017

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 (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 ?




Aucun commentaire:

Enregistrer un commentaire