RosettaCodeData/Task/Multiple-regression/BBC-BASIC/multiple-regression.basic

30 lines
872 B
Plaintext

*FLOAT 64
INSTALL @lib$+"ARRAYLIB"
DIM y(14), x(2,14), c(2)
y() = 52.21, 53.12, 54.48, 55.84, 57.20, 58.57, 59.93, 61.29, \
\ 63.11, 64.47, 66.28, 68.10, 69.92, 72.19, 74.46
x() = 1.47, 1.50, 1.52, 1.55, 1.57, 1.60, 1.63, 1.65, \
\ 1.68, 1.70, 1.73, 1.75, 1.78, 1.80, 1.83
FOR row% = DIM(x(),1) TO 0 STEP -1
FOR col% = 0 TO DIM(x(),2)
x(row%,col%) = x(0,col%) ^ row%
NEXT
NEXT row%
PROCmultipleregression(y(), x(), c())
FOR i% = 0 TO DIM(c(),1) : PRINT c(i%) " "; : NEXT
PRINT
END
DEF PROCmultipleregression(y(), x(), c())
LOCAL m(), t()
DIM m(DIM(x(),1), DIM(x(),1)), t(DIM(x(),2),DIM(x(),1))
PROC_transpose(x(), t())
m() = x().t()
PROC_invert(m())
t() = t().m()
c() = y().t()
ENDPROC