Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 ?

like image 781
muazfaiz Avatar asked Nov 28 '17 23:11

muazfaiz


People also ask

How do you find the trend in data in Python?

In python, we can plot these trend graphs by using matplotlib. pyplot library. It is used for plotting a figure for the given data.

What is a time series in python?

Practical Data Science using Python Time series is a series of data points in which each data point is associated with a timestamp. A simple example is the price of a stock in the stock market at different points of time on a given day.


1 Answers

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

like image 192
SemanticBeeng Avatar answered Oct 13 '22 01:10

SemanticBeeng