Cubic Regression - Math/Numerical Question

This is a discussion on Cubic Regression - Math/Numerical Question within the A Brief History of Cprogramming.com forums, part of the Community Boards category; Hi there, How do I implement cubic regression? I.e. given a series of x-y data points, how do I find ...

  1. #1
    Code Monkey Davros's Avatar
    Join Date
    Jun 2002
    Posts
    812

    Cubic Regression - Math/Numerical Question

    Hi there,

    How do I implement cubic regression? I.e. given a series of x-y data points, how do I find the coefficients:

    y = ax^3 + bx^2 + cx + d

    Am aware that if I differentiate twice, I get:

    d2y/dsx2 = 6ax + 2b

    so if I can numerically differentiate my x-y data twice, I can find constants a & b by linear regression.

    How do I go about differentiating the data. And how do I find constants c & d?

    Or is there a better approach?
    OS: Windows XP
    Compilers: MinGW (Code::Blocks), BCB 5

    BigAngryDog.com

  2. #2
    Senior Member joshdick's Avatar
    Join Date
    Nov 2002
    Location
    Phildelphia, PA
    Posts
    1,146
    http://en.wikipedia.org/wiki/Linear_regression

    This gets into Linear Algebra.
    FAQ

    "The computer programmer is a creator of universes for which he alone is responsible. Universes of virtually unlimited complexity can be created in the form of computer programs." -- Joseph Weizenbaum.

    "If you cannot grok the overall structure of a program while taking a shower, you are not ready to code it." -- Richard Pattis.

  3. #3
    Code Monkey Davros's Avatar
    Join Date
    Jun 2002
    Posts
    812
    Thanks for the reply.

    >This gets into Linear Algebra.

    I can do the linear regression bit. But...

    how do I transform a cubic in order to determine all the constants?
    OS: Windows XP
    Compilers: MinGW (Code::Blocks), BCB 5

    BigAngryDog.com

  4. #4
    S Sang-drax's Avatar
    Join Date
    May 2002
    Location
    Göteborg, Sweden
    Posts
    2,072
    This page can perhaps help you:
    http://www.efunda.com/math/leastsqua...sqrmdcurve.cfm
    it's linked from
    http://www.efunda.com/math/leastsqua...astsquares.cfm

    These pages seem good, there's a linear example as well.

    To do this in MATLAB, use the polyfit() function.
    Last edited by Sang-drax; 04-27-2005 at 02:30 PM.
    Last edited by Sang-drax : Tomorrow at 02:21 AM. Reason: Time travelling

  5. #5
    VA National Guard The Brain's Avatar
    Join Date
    May 2004
    Location
    Manassas, VA USA
    Posts
    903
    why not just use the cubic regression from your TI-83 ?
    • "Problem Solving C++, The Object of Programming" -Walter Savitch
    • "Data Structures and Other Objects using C++" -Walter Savitch
    • "Assembly Language for Intel-Based Computers" -Kip Irvine
    • "Programming Windows, 5th edition" -Charles Petzold
    • "Visual C++ MFC Programming by Example" -John E. Swanke
    • "Network Programming Windows" -Jones/Ohlund
    • "Sams Teach Yourself Game Programming in 24 Hours" -Michael Morrison
    • "Mathmatics for 3D Game Programming & Computer Graphics" -Eric Lengyel

  6. #6
    Code Monkey Davros's Avatar
    Join Date
    Jun 2002
    Posts
    812
    >This page can perhaps help you:

    Indeed yes, that helps. Thank you.


    >why not just use the cubic regression from your TI-83 ?

    Because I am writing a program to do it.
    OS: Windows XP
    Compilers: MinGW (Code::Blocks), BCB 5

    BigAngryDog.com

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Alice....
    By Lurker in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 06-20-2005, 02:51 PM
  2. Debugging question
    By o_0 in forum C Programming
    Replies: 9
    Last Post: 10-10-2004, 05:51 PM
  3. Question about pointers #2
    By maxhavoc in forum C++ Programming
    Replies: 28
    Last Post: 06-21-2004, 12:52 PM
  4. Question...
    By TechWins in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 07-28-2003, 09:47 PM
  5. Math Question, hard
    By Yoshi in forum A Brief History of Cprogramming.com
    Replies: 34
    Last Post: 12-08-2001, 10:58 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21