drupflare/worker - v1.0.0
    Preparing search index...

    Function fitTrend

    • Least-squares slope over a ring, with a signal-to-noise gate.

      WHY A GATE AND NOT JUST slope > 0. Any real series wobbles, so a bare positive slope fires on noise, and a trend check that fires on noise is worse than none -- it trains the operator to ignore the ledger, which is the only place the host's findings are visible at all. So the fitted rise across the window has to be at least TREND_MIN_SNR times the mean absolute residual.

      A perfectly straight line has zero residual, and rise >= 2 * 0 holds, so the ideal case passes rather than dividing by zero. The x-variance denominator cannot be zero either: x is 0..n-1 with n >= TREND_MIN_SAMPLES.

      Parameters

      • samples: number[] | undefined

      Returns Trend | null