[6.6] Linear regression through a fixed point
It can be useful or necessary to force a regression equation through a fixed point. For example, you
might be modelling a system, and you know from the physical laws that the function must pass through
(0,0). The 89/92+ built-in regression functions do not address this requirement. This function will find
the fit coefficients for y = bx + a through a fixed point (h,k).
linreghk(xl,yl,h,k)
func
©return {b,a} for y=b*x+a through (h,k)
©
1
4mar00/dburkett@infinet.com
local s
1
,s2,s3
sum(xl^2)
→
s3
if h
≠
0 then
sum(xl)
→
s2
(h*k*s2-k*s3-h^2*sum(yl)+h*sum(xl*yl))/(2*h*s2-s3-h^2*dim(xl))
→
s
1
return {(k-s
1
)/h,s
1
}
else
return {sum(xl*yl)/s3,0}
endif
Endfunc
The code is a straightforward implementation of the regression equations from the book Curve Fitting
for Programmable Calculators, William W. Kolb, Syntek, Inc., which is unfortunately out of print.
xl and yl are lists that specify the (x,y) data points to fit. h and k specify the point (h,k) through which to
force the best-fit line. linreghk() returns a list that contains the coefficients {b,a}, where y = bx + a. Note
that this list can be used directly with polyeval() to evalute the function at some point:
polyeval({b,a},x)
To force the fit curve through a specified a-value, use
linreghk(xl,yl,h,0)
To force the fit curve through the origin (0,0), use
linreghk(xl,yl,0,0)
Two different methods are needed, depending on whether or not h = 0. This routine does no error
checking, but these criteria must be met:
1. The lists xl and yl must be the same length.
2. If h=0, then xl and yl must have at least two elements
3. If h is not equal to zero, then xl and yl must have at least three elements.
4. The function should be executed in Approx mode.
This data can be used to test the routine for a fit through the origin (0,0):
xl = {11,17,23,29}
yl = {15,23,31,39}
6 - 6
Summary of Contents for TI-92+
Page 52: ...Component side of PCB GraphLink I O connector detail 1 41...
Page 53: ...LCD connector detail PCB switch side 1 42...
Page 54: ...Key pad sheet contact side Key pad sheet key side 1 43...
Page 55: ...Key cap detail 1 44...
Page 57: ...Component side of PCB with shield removed A detail view of the intergrated circuits 1 46...
Page 410: ...void extensionroutine2 void Credit to Bhuvanesh Bhatt 10 4...