@kaiord/core / EmaPoint
Type Alias: EmaPoint
EmaPoint =
object
Defined in: packages/core/src/application/energy/ema.ts:21
Exponential moving average (EMA) over a dated numeric series. Pure; no adapter/external deps.
Used to smooth noisy daily weigh-ins into a trend line (and reusable for any other dated signal). Points MUST be ascending by date; the returned series mirrors the input one-to-one, each entry carrying the running EMA up to and including that point.
Alpha derivation: a windowDays span maps to the standard smoothing factor alpha = 2 / (windowDays + 1) the same relation used for an N-period EMA. A larger window yields a smaller alpha and therefore a heavier, slower-moving trend. The first point seeds the EMA with its own value (ema[0] = value[0]); each subsequent point updates it as ema = alpha * value + (1 - alpha) * prevEma.
Guards: empty input returns []; a non-finite windowDays (≤ 0) or any non-finite point value throws a RangeError rather than propagating NaN.
Properties
date
date:
string
Defined in: packages/core/src/application/energy/ema.ts:23
ISO date (YYYY-MM-DD); the series MUST be ascending by date.
value
value:
number
Defined in: packages/core/src/application/energy/ema.ts:24