# 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: **$y_t = S_t + T_t + N_t$**, with $S_t$ the seasonal component, $T_t$ the trend-cycle component and $N_t$ the Noise component, at period $t$.

Alternatively, if the interaction is **multiplicative**, the relation is: **$y_t = S_t * T_t * N_t$**.

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:

$y_t = noise * (flat\_trend + (seasonal\_1 * linear\_trend) + seasonal\_2)$.

To give more context, it could represent something like the temperature on Earth:

- the temperature has an average value ($flat\_trend$)
- the temperature is rising $linear\_trend$
- the yearly pattern $seasonal\_1$ 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.