Shop OBEX P1 Docs P2 Docs Learn Events
Polynomial curve fitting in Spin — Parallax Forums

Polynomial curve fitting in Spin

Does anyone have any Spin code for doing least squares regression? Ideally I'm looking for a method where I could specify memory locations of X and Y data arrays, and a degree, and it would return the coefficients and optionally an R^2 value.

I don't expect that I would need a degree higher than 2, as in y = Ax^2 + Bx + C.

I found a number of functions on the web in other languages that I could translate, but I thought I'd at least ask here in case someone has already gone through the exercise.

Thanks!

Comments

  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2016-01-09 04:21
    What are the ranges of your X and Y values? Integer-only, or floating point?

    -Phil
  • X and Y values will most likely be stored in word variable arrays and will be in the range of 0 to 5000. I'd like to avoid floating point if possible.
Sign In or Register to comment.