How to generate noise 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 check my code or to provide some sample data for the stack overflow question. Usually I either load some kind of similar dataset from another project, or just add some sine functions and noise and spend some time setting it up.

What is your approach? How do you generate noisy signals with certain characteristics? I just forgot some obviously obvious standard package that does just that?

Functions that I would usually like to get in my breadboard data:

  • Noise levels change over time
  • Some story in the signal (e.g. random wandering?)
  • Signal frequency
  • Ability to create another time series with similar (but not exactly the same) functions
  • Possibly a bunch of weird dips / peaks / plateaus
  • Ability to reproduce it (some seeds and several parameters?)

I would like to get a time series similar to the two below [A]:

Real Time Rows 1 Real Time Rows 2

I usually create time series with this code:

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)) 

The result is a time series:

Mock Time Series

With whom I can work, but still not quite what I want. The problem here is basically this:

  • he has no aspect of history / random walk
  • this is quite a bit of code and customization (this is especially a problem if I want to share a sample time series)
  • I need to cancel the values ​​(sine frequency, etc.) in order to create another similar, but not quite the same series of time.

[A]: for those who are wondering, the time series shown in the first two images are the traffic at two points along the same road for three days (from midnight to 6 am cut off) in wagons per second (average average window for courtship for more than 2 minutes). Reinstalled up to 1000 points.

+9
source share
1 answer

Have you looked at Tsimulus ? Using Generators , you can generate data with specific patterns, frequency and cycles.

The TSimulus project provides tools for determining the shape of a time series (general patterns, cycles, the importance of added noise, etc.) and for converting this specification into time series values.


Otherwise, you can try to β€œdraw” the data yourself and export these data points using the Time Series Maker .

0
source

Source: https://habr.com/ru/post/1245991/


All Articles