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

10,837

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."

Share:
10,837
muazfaiz
Author by

muazfaiz

Updated on July 10, 2022

Comments

  • muazfaiz
    muazfaiz almost 2 years

    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 ?