Skip to content

Scaled Right Indicator

timecave.data_generation.time_series_functions.scaled_right_indicator_ts(number_samples, idx, constant=1)

Generate a time series array based on a indicator function that is 1 in the interval [idx, + inf[ and 0 otherwise.

This function creates a time series array of given length where the segment starting from the specified index to the end is marked as 1 and the rest as 0. The binary array is then scaled by a constant factor.

Parameters:

Name Type Description Default
number_samples int

The total number of samples in the time series array.

required
idx int

The index from which the segment starts to be marked as 1.

required
constant float

A scaling constant to multiply the array by, by default 1.

1

Returns:

Type Description
ndarray

A scaled time series array where the segment starting from the specified index to the end is marked as 1 and the rest as 0.

See also

indicator_ts: Indicator time series.

Examples:

>>> import numpy as np
>>> import matplotlib.pyplot as plt
>>> from timecave.data_generation.time_series_functions import scaled_right_indicator_ts
>>> ts = scaled_right_indicator_ts(100, 30, 5);
>>> _ = plt.plot(np.arange(0, ts.shape[0]), ts);
>>> plt.show();

indicator

Source code in timecave/data_generation/time_series_functions.py
def scaled_right_indicator_ts(
    number_samples: int, idx: int, constant: float = 1
) -> np.ndarray:
    """
    Generate a time series array based on a indicator function that is 1 in the interval [idx, + inf[ and 0 otherwise.

    This function creates a time series array of given length where the segment starting from the specified index to the end is marked as 1 and the rest as 0.
    The binary array is then scaled by a constant factor.

    Parameters
    ----------
    number_samples : int
        The total number of samples in the time series array.

    idx : int
        The index from which the segment starts to be marked as 1.

    constant : float, optional
        A scaling constant to multiply the array by, by default 1.

    Returns
    -------
    np.ndarray
        A scaled time series array where the segment starting from the specified index to the end is marked as 1 and the rest as 0.

    See also
    --------
    [indicator_ts](indicator.md): Indicator time series.

    Examples
    --------
    >>> import numpy as np
    >>> import matplotlib.pyplot as plt
    >>> from timecave.data_generation.time_series_functions import scaled_right_indicator_ts
    >>> ts = scaled_right_indicator_ts(100, 30, 5);
    >>> _ = plt.plot(np.arange(0, ts.shape[0]), ts);
    >>> plt.show();

    ![indicator](../../../images/Scaled_indicator.png)
    """
    _check_number_samples(number_samples)
    return constant * indicator_ts(number_samples, idx, number_samples - 1)