moving_average3

std.seq.moving_average3 · Level L2

Moving average over a window of three, at every position where the window fits.

yᵢ = (xᵢ + xᵢ₊₁ + xᵢ₊₂)/3

Signature

moving_average3(x: f64[n]) → f64[n−2]

Requires: n ≥ 2

Structure

The function as NOVA stores it: one box per input, operation and output, and arrows that carry values. A double border marks another library function this one runs — called once, or by Scan once per element; select it to open that function.

xf64[n]SliceaSlicemSlicezAddamAddamz3.0Divideyyf64[n−2]
  • input
  • operation
  • constant
  • call
  • output

Verification

  • Signature proven by NOVA’s shape solver, for every size with n ≥ 2.
  • Equal to the reference (x[:-2] + x[1:-1] + x[2:]) / 3 in exact rational arithmetic, on all 40 test cases.
  • All 101 float64 results inside the running error bound; the closest uses 77% of it.
  • Interpreter and NumPy backend return bit-identical results.
Accuracy in detail
correctly rounded (the float64 nearest the exact value)
87%
bit-equal to the NumPy formula in float64
100%
largest error, in units in the last place
21

Large ulp counts appear only where cancellation drives a result toward zero; the absolute error is still inside the bound.

Identity

Calls
—
Called by
—
sha256:f16a5351a286ceb15986ca299bc11116ff6d6989f25e3416235aec7236f7b72b

The semantic hash of the graph. It changes when the program changes, and never when only its documentation does.