dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: Linear Regression

  1. #1
    Join Date
    Apr 2005
    Posts
    1

    Linear Regression

    Can anyone point me to a simple linear regression algorithm. Nothing fancy, just best fit linear regression line for a set of X/Y coordinates using least squares. C# preferred, but I'll take what I can get.

    Thanks in advance.

    Sean

  2. #2
    Join Date
    Sep 2002
    Location
    Philadelphia ***Epoch: Timeless***
    Posts
    560

    Re: Linear Regression

    Quote Originally Posted by sean_colonello
    Can anyone point me to a simple linear regression algorithm. Nothing fancy, just best fit linear regression line for a set of X/Y coordinates using least squares. C# preferred, but I'll take what I can get.

    Thanks in advance.

    Sean
    If you are simply looking for the regression equation, you can use the following formulae:
    y = b1*x + b0
    b1 = sum((x_i-x_avg)*(y_i-y_avg)) / sum((x_i-x_avg)^2)
    b0 = y_avg - b1*x_avg

    If you also want other statistical data (such as standard deviation, correlation, etc.) there are other, more efficient ways to acquire the data since they are all related. But you don't need an algorithm, just an equation.
    SolarFlare

    Those who cling to life die and those who defy death live. -Sun Tzu

    cout << endl;
    return 0;
    }

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)