> Hi there. Does anybody here happen to know how to perform linear
> regression?
>
> As in, I've got a list of data points that ought to lie in a nearly
> perfect straight line, and I want to discover what the slope and intercept
> of that line is. (But each individual point might contain a certain amount
> of measurement error.)
>
> I've had a look on Wikipedia, but it starts talking about chi-squared and
> Student t-distributions and covariance and basically I have no clue what
> the hell any of it means. :-/
This page:
http://en.wikipedia.org/wiki/Simple_linear_regression
Gives the formula for the coefficients alpha and beta for the line of best
fit. It's pretty self-explanatory if you know how to calculate a summation.
The simplest form for you seems to be:
b = (mean[x*y] - mean[x] * mean[y]) / ( mean[x^2] - mean[x]^2 )
a = mean[y] - b * mean[x]
then your line of best fit is:
y = a + b*x
Post a reply to this message
|