Skip to content

Delta Min Preprocessor

The delta min preprocessor function shifts the input signal by the max of the signal. The is defined as:

\[ x_{shifted_{i}} = x_{i} - \min({x}), \quad \forall i \in \{1, \dots, N\} \]

For shifting signals by a custom \(\delta\), see the delta preprocessor function. For more on how we compute the min of a signal, check out min function.

Preprocess the signal x by shifting each element of x by the minimum of x.

Parameters:

Name Type Description Default
x ndarray

The array to shift by its minimum.

required
where Callable[[Union[int, float, int_, float_]], Union[bool, bool_]]

A function that takes a value and returns True or False. Default is lambda x: not np.isnan(x) i.e. a measurement is valid if it is not a NaN value.

lambda : not numpy.isnan(x)
initial Union[int, float, int_, float_]

The initial value for the minimum. Default is np.inf.

inf

Returns:

Type Description
ndarray

The shifted signal.

Examples

Transform Signal

import numpy as np
import autonfeat.preprocess.functional as PF

# Create a random signal
time = np.linspace(0, 10, 1000)
frequency = 500  # Frequency of the signal in Hz
signal = np.sin(np.exp(np.sin(2 * np.pi * frequency * time)))

# Shift the signal by the minimum value
shifted_signal = PF.delta_min_tf(signal)

Visualize Transform

import matplotlib.pyplot as plt

# Plot the original signal and the shifted signal
fig, ax = plt.subplots(figsize=(10, 5))
ax.plot(time, signal, label='Original Signal')
ax.plot(time, shifted_signal, label='Shifted Signal')
ax.axhline(y=0, color='red', linestyle='--', linewidth=2)
ax.set_xlabel('Time (s)')
ax.set_ylabel('Amplitude')
ax.set_title('Signal')
ax.legend()
plt.tight_layout()
plt.show()

This can be seen in the figure below.

DeltaMin

If you enjoy using AutonFeat, please consider starring the repository ⭐️.