timesfm-ts - v1.0.0
    Preparing search index...
    • Fill internal NaN values using linear interpolation between the nearest valid neighbours.

      Equivalent to linear_interpolation() in timesfm_2p5_base.py.

      This implementation is strictly O(n) with two single-pass traversals:

      1. Forward pass: record the last valid value and its position at every index into auxiliary arrays.
      2. Backward pass: for each NaN, interpolate using the pre-recorded left-valid (value & position) and a running right-valid pointer. No inner loops — each array element is visited exactly twice in total.

      Edge cases:

      • No NaNs → returns the original array.
      • All NaNs → returns an all-zero array of the same length.
      • Only one valid point → NaNs are filled with that value.

      Parameters

      • arr: Float32Array

      Returns Float32Array