Sinusoid
timecave.data_generation.time_series_functions.sinusoid_ts(number_samples, max_interval_size, amplitude=1, frequency=1, phase=0)
Generate a time series of a sinusoidal signal.
This function generates a time series of a sinusoidal signal with the specified parameters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
number_samples |
int
|
The number of samples in the generated time series. |
required |
max_interval_size |
float
|
The maximum interval size (time duration) of the generated time series. |
required |
amplitude |
float
|
The amplitude of the sinusoidal signal. |
1
|
frequency |
float
|
The frequency of the sinusoidal signal in cycles per unit time. |
1
|
phase |
float
|
The phase offset of the sinusoidal signal in radians. |
0
|
Returns:
| Type | Description |
|---|---|
ndarray
|
The generated sinusoidal time series. |
See also
frequency_varying_sinusoid_ts: Generate a time-varying sinusoid.
Examples:
>>> import numpy as np
>>> import matplotlib.pyplot as plt
>>> from timecave.data_generation.time_series_functions import sinusoid_ts
>>> ts = sinusoid_ts(1000, 10, amplitude=3, frequency=0.5);
>>> _ = plt.plot(np.arange(0, ts.shape[0]), ts);
>>> plt.show();

Higher frequency sinusoids can be generated as well:
>>> ts2 = sinusoid_ts(1000, 10, amplitude=3, frequency=5);
>>> _ = plt.plot(np.arange(0, ts2.shape[0]), ts2);
>>> plt.show();

Phase shifts can be added too:
>>> ts3 = sinusoid_ts(1000, 10, amplitude=3, frequency=0.5, phase=0.3);
>>> _ = plt.plot(np.arange(0, ts2.shape[0]), ts3);
>>> plt.show();
