Giter Club home page Giter Club logo

polyfit's Introduction

Name

polyfit — "C" function that fits a polynomial to a set of points

Synopsis

#include "polyfit.h"

int polyfit( int pointCount, double *xValues, double *yValues, int coefficientCount, double *coefficientResults );

Description

The polyfit() function regresses a line or a higher-order polynomial to a set of points, using the Method of Least Squares. Its design goals were simplicity and ease of porting, as opposed to run-time efficiency with large data.

Arguments

pointCount — input. The total number of points in the set. For the algorithm to work, this must be greater than or equal to coefficientCount.

xValues — input. Points to an array of the X coordinates of the points. There should be pointCount X coordinates.

yValues — input. Points to an array of the Y coordinates of the points. There should be pointCount Y coordinates.

coefficientCount — input. The number of coefficients to be computed, equal to the degree of the polynomial plus 1. For instance, if fitting a line — a first degree polynomial — then coefficientCount would be 2, and for fitting a parabola — a second degree polynomial — coefficientCount would be 3.

results — input. Points to where the computed coefficients will be stored. There should be space for coefficientCount coefficients. These coefficients are ordered from the highest-order monomial term to the lowest, such that for instance the polynomial:

 5x² + 3x - 7

is represented as:

 [ 5, 3, -7 ] 

Return Value

In addition to setting the coefficient results, the polyfit() function returns 0 on success.

FILES

./src/polyfit.c — defines the polyfit() function.

./inc/polyfit.h — declares the polyfit() function's prototype.

MISC

To support unit testing on Linux with gcc, the repo has these additional files:

./src/test.c — exercises polyfit() and provides examples of usage.

./Makefile — allows the make command to build an executable, ./bin/polytest, that tests polyfit().

polyfit's People

Contributors

henryfo avatar

Stargazers

 avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.