Combining signals
In this tutorial, you'll learn how to combine signals and how to perform scalar operations.
As a reminder, timeseries are often expressed as a combination of 3 components: trend, seasonality and noise.
If the interaction is additive the formula is: , with the seasonal component, the trend-cycle component and the Noise component, at period .
Alternatively, if the interaction is multiplicative, the relation is: .
The point is: to combine signals, you add or multiply them.
It's easy in mockseries: just use the standard operators +
and *
!
You can write complex signals mixing additive and multiplicative interactions, such as:
#
Simple examplesLets add a linear trend and a sinusoidal signal:
Now if we multiply them:
#
Complex exampleLet's implement the example in the introduction:
.
To give more context, it could represent something like the temperature on Earth:
- the temperature has an average value ()
- the temperature is rising
- the yearly pattern is multiplicative with the trend: this means global warming results in bigger yearly patterns
- the daily pattern is additive: it's not impacted by the trend.
- a noise is multiplicative by all of the above: this means it tends to get bigger when temperatures are bigger
NB: This model is an un-documented simulation, it is not linked to any research and is obviously incorrect.
NB: For the sake of simplicity, we'll use sinusoidal signals for seasonalities. Check out the next tutorial for more realistic patterns !
#
Scalars operations:mockseries also supports simple scalar operations:
- negate a signal:
-my_signal
- add a constant to a signal:
3 + my_signal
- multiply a signal:
3 * my_signal
You're now able to combine timeseries and use scalar broadcasting!
You should be able to build all kinds of timeseries with this simple primitives.
Go to the next page to learn how to create periodic signals based on (time, value)
constraints. This is helpful when you simulate real life timeseries.