Shift in frequency (sine waves)¶
Description¶
This function simulates a sum-of-sine signal \(y_t=\sin(2\pi f_1 t)+\sin(2\pi f_2 t)\) where \(t=0,\dots,T-1\). The frequency vector \([f_1, f_2]\) alternates between \([0.075, 0.1]\) and \([0.1, 0.125]\) at each change point index. Gaussian white noise can be added to the signal.
Usage¶
Start with the usual imports and create a signal.
import numpy as np
import matplotlib.pylab as plt
import ruptures as rpt
# creation of data
n, dim = 500, 3 # number of samples, dimension
n_bkps, sigma = 3, 5 # number of change points, noise standart deviation
signal, bkps = rpt.pw_wavy(n, n_bkps, noise_std=sigma)
rpt.display(signal, bkps)
Code explanation¶
-
ruptures.datasets.pw_wavy.
pw_wavy
(n_samples=200, n_bkps=3, noise_std=None)[source]¶ Return a 1D piecewise wavy signal and the associated changepoints.
- Parameters
n_samples (int, optional) – signal length
n_bkps (int, optional) – number of changepoints
noise_std (float, optional) – noise std. If None, no noise is added
- Returns
signal of shape (n_samples, 1), list of breakpoints
- Return type
tuple