[英]How to generate noisy mock time series or signal (in Python)
Quite often I have to work with a bunch of noisy, somewhat correlated time series. 我常常需要处理一堆嘈杂的,有点相关的时间序列。 Sometimes I need some mock data to test my code, or to provide some sample data for a question on Stack Overflow.
有时我需要一些模拟数据来测试我的代码,或者为Stack Overflow上的问题提供一些示例数据。 I usually end up either loading some similar dataset from a different project, or just adding a few sine functions and noise and spending some time to tweak it.
我通常最终会从不同的项目中加载一些类似的数据集,或者只是添加一些正弦函数和噪声并花一些时间来调整它。
What's your approach? 你的方法是什么? How do you generate noisy signals with certain specs?
如何使用某些规格生成噪声信号? Have I just overlooked some blatantly obvious standard package that does exactly this?
我是否只是忽略了一些明显明显的标准包装呢?
The features I would generally like to get in my mock data: 我通常希望在我的模拟数据中获得的功能:
I would like to get a time series similar to the two below [A]: 我想得到一个类似下面两个[A]的时间序列:
I usually end up creating a time series with a bit of code like this: 我通常最终创建一个时间序列,其代码如下:
import numpy as np
n = 1000
limit_low = 0
limit_high = 0.48
my_data = np.random.normal(0, 0.5, n) \
+ np.abs(np.random.normal(0, 2, n) \
* np.sin(np.linspace(0, 3*np.pi, n)) ) \
+ np.sin(np.linspace(0, 5*np.pi, n))**2 \
+ np.sin(np.linspace(1, 6*np.pi, n))**2
scaling = (limit_high - limit_low) / (max(my_data) - min(my_data))
my_data = my_data * scaling
my_data = my_data + (limit_low - min(my_data))
Which results in a time series like this: 这会产生如下时间序列:
Which is something I can work with, but still not quite what I want. 这是我可以使用的东西,但仍然不是我想要的。 The problem here is mainly that:
这里的问题主要是:
[A]: For those wondering, the time series depicted in the first two images is the traffic intensity at two points along one road over three days (midnight to 6 am is clipped) in cars per second (moving hanning window average over 2 min). [A]:对于那些想知道的人来说,前两张图片中描绘的时间序列是每秒车辆在三天(午夜到早上6点被修剪)的两条路上的两个点的交通强度(移动汉宁窗平均超过2分钟) )。 Resampled to 1000 points.
重新采样到1000点。
Have you looked into TSimulus ? 你看过TSimulus了吗? By using
Generators
, you should be able generate data with specific patterns, periodicity, and cycles. 通过使用
Generators
,您应该能够生成具有特定模式,周期性和周期的数据。
The TSimulus project provides tools for specifying the shape of a time series (general patterns, cycles, importance of the added noise, etc.) and for converting this specification into time series values.
TSimulus项目提供了用于指定时间序列形状(一般模式,周期,增加的噪声的重要性等)以及将此规范转换为时间序列值的工具。
Otherwise, you can try "drawing" the data yourself and exporting those data points using Time Series Maker . 否则,您可以尝试自己“绘制”数据并使用Time Series Maker导出这些数据点。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.