[英]How to generate random time series data with noise in python 3?
This python 2 code generates random time series data with a certain noise:此 python 2 代码生成具有一定噪声的随机时间序列数据:
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?有人知道我如何在 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.现在你有随机值的列表,可以用任何时间戳压缩。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.