Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Polynomial fitting #601

Open
Open
Labels
APIDiscussion on a specific API for a proposal (exploratory) ideaProposition of an idea and opening an issue to discuss it topic: mathematicslinear algebra, sparse matrices, special functions, FFT, random numbers, statistics, ...
@ivan-pi

Description

Motivation

Functions for low-order polynomial fitting using (weighted) least squares regression are common in many scientific libraries.

Here's an interface for the non-weighted case, inspired by the numpy version cited below:

 function polyfit(x, y, deg, rcond, rank, singular_values) result(p)
 real, intent(in) :: x(:), y(:)
 integer, intent(in) :: deg
 real, intent(in), optional :: rcond
 integer, intent(out), optional :: rank
 real, intent(out), allocatable, optional :: singular_values(:)

Prior Art

Prior art in popular scripting languages:

Prior art in Fortran (in no particular order):

Prior art in other programming languages

  • GSL: Linear Least-Squares Fitting (can be used via the Fortran interface fgsl, the relevant routine is called multifit which may be used for any linear model)
  • alglib (C++)

Additional Information

This will probably require LAPACK for the factorization of the Vandermonde matrix either using a rank-revealing QR or SVD factorization.

A function to evaluate the polynomial (and it's derivatives) using Horner's scheme (or alternatively, in some orthogonal form), should be added in parallel.

An advanced interface could consider using derived types for polynomials, similar to the numpy Polynomial sub-package.

Metadata

Metadata

Assignees

No one assigned

    Labels

    APIDiscussion on a specific API for a proposal (exploratory) ideaProposition of an idea and opening an issue to discuss it topic: mathematicslinear algebra, sparse matrices, special functions, FFT, random numbers, statistics, ...

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

        AltStyle によって変換されたページ (->オリジナル) /