Skip to content
Free public beta until December 4, 2026: every course is open, no card needed. After that, the first chapter of each course stays free and full access is a one-time $39 ($19 for up to 100 founding members chosen for helpful feedback). Your progress is kept. How the beta works

Recipe

Choose an EMA's alpha

Use when: you want an EMA that settles in a chosen time, at a known sample interval

Goal: an alpha that gives the wanted time constant, and a check of the lag it costs

Taught in Noise and filtering

  1. 1

    Pick a time constant \tau: how quickly a real change should show up (63% of it).

    Example

    A room-temperature display should follow a real change within a few seconds: \tau = 2 s.

    Why: alpha only means something together with how often you sample.

  2. 2

    Find \Delta t, the time between filter updates.

    Example

    One reading every 500 ms: \Delta t = 0.5 s.

    Why: the same alpha is a slow filter at 1 reading per second and a fast one at 100.

  3. 3

    \alpha = 1 - e^{-\Delta t/\tau}, or roughly \Delta t/\tau when that is small.

    Example

    \alpha = 1 - e^{-0.25} \approx 0.22 (the rough form gives 0.25).

    Why: it's the time-constant formula solved for alpha.

  4. 4

    After a step, 95% arrives after about 3\tau; a steady climb is followed (1-\alpha)/\alpha samples late.

    • the lag is acceptable and the output is steady enough — done.
    • still too noisy — lower alpha and accept more lag, or fix the noise at its source.
    • too slow — raise alpha, sample faster, or use a filter only on the display, not on an alarm.

    Why: every filter trades noise for lag; this step makes you choose the trade on purpose.

Common mistakes

  • Declaring the filtered value inside loop(), so it is reset every pass.
  • Starting the output at 0 instead of the first reading.
  • Keeping alpha but changing the sample interval, which changes the time constant.
  • Filtering a safety alarm so heavily that it reacts seconds late.