EMAFilter

class EMAFilter(val alpha: Double)(source)

Exponential Moving Average (EMA) filter.

Applies the recurrence: \(y_{n} = \alpha \cdot x_n + (1 - \alpha) \cdot y_n\)

The first output uses \(y_{-1} = 0\) unless previous is preset.

Parameters

alpha

smoothing factor \(\alpha \in 0.0, 1.0\); higher values weight newer samples more.

Constructors

Link copied to clipboard
constructor(alpha: Double)

Properties

Link copied to clipboard
Link copied to clipboard

Last output sample, or null before the first call to calculate.

Functions

Link copied to clipboard
fun calculate(newValue: Double): Double

Updates the filter with a new sample and returns the filtered value.