This python 2 code generates random time series data with a certain noise:
from common import arbitrary_timeseries
from commonrandom import generate_trendy_price
from matplotlib.pyplot import show
ans=arbitrary_timeseries(generate_trendy_price(Nlength=180, Tlength=30, Xamplitude=10.0, Volscale=0.1))
ans.plot()
show()
Does someone know how I can generate this data in python 3?
You can use simple Markov process like this one:
import random
def random_timeseries(initial_value: float, volatility: float, count: int) -> list:
time_series = [initial_value, ]
for _ in range(count):
time_series.append(time_series[-1] + initial_value * random.gauss(0, 1) * volatility)
return time_series
ts = random_timeseries(1.2, 0.15, 100)
Now you have list with random values which can be zipped with any timestamps.
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.