From: John D'Errico on
"Giorgio " <christianjp(a)inwind.it> wrote in message <htpag1$6pv$1(a)fred.mathworks.com>...
> "Matt J " <mattjacREMOVE(a)THISieee.spam> wrote in message <htp9le$epg$1(a)fred.mathworks.com>...
> > "Giorgio " <christianjp(a)inwind.it> wrote in message <htp8ls$d5s$1(a)fred.mathworks.com>...
> >
> > > i would like to find out the OLS slope that passes through the smallest x, and highest y.. i.e. passing through min(x), max(y).
> > =====
> >
> > I must be missing something. In the data you've given min(x) and max(y) occur at 2 separate points. So, if this is to be a linear fit passing through these 2 points, then those 2 points constrain the line completely, irrespective of the rest of data. Just connect them with a line and you're done.
>
> Apologies. In this example, the OLS regression should pass through point(-0.651047629509525,-0.806235701025338), second row for each vector (ignore first data point and in my post above x should be y and vice versa).

Assume that the line must pass through the point
(x0,y0).

Then for column vectors X and Y, the slope of that
line is just

S = (X-x0)\(Y-x0);

The equation of the line is given by the point/slope
formula.

y = S*(x - x0) + y0

HTH,
John
 | 
Pages: 1
Prev: Interesting optimization problem
Next: pso + ANFIS