Skip to content

Least squares over runtime-length samples, in double, with R² #4

Description

@Yaraslaut

Problem

linear_least_squares fits a curve of fixed length N and evaluates only in Rational. Two common situations are not covered:

  1. The number of points is data, not part of the method. A method says "all determinations of the series that meet condition X", so the count is only known at run time. observations<Q, Capacity> models exactly this for statistics, but it cannot be the input of a fit, a curve or an opaque operation (ObservationsNodeBase: "the only thing that reads it is binned").
  2. The point count and precision are beyond Rational headroom. A realistic case is about 50 points with 4 decimal places, which is past the overflow sizes measured in docs/numeric-headroom.md (see Numeric headroom: 64-bit Rational overflows on realistic lab statistics — 128-bit intermediates or a wider representation? #1). There is no traced fallback in double: LinearLeastSquares::compute<double> can be called, but its result reaches neither the trace nor the page.

Wanted

  • A least-squares line over observations<Q, Capacity> (domain and value observations of the same count, or pairs), with Capacity a bound as elsewhere.
  • Evaluation with Rep = double through checked_evaluate_si<double>, traced like any other opaque call.
  • A coefficient of determination output next to intercept and slope; methods report it and use it as an acceptance criterion.
  • A degenerate set (fewer than two points, no spread in the domain) stays the fit's own DomainError.

Related: #1 would remove the overflow for the exact path, but not the fixed-length restriction.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions