Polynomial regression: Difference between revisions

add RPL
(add RPL)
Line 2,152:
9 262 262.000
10 321 321.000</pre>
 
=={{header|RPL}}==
{{trans|Ada}}
≪ 1 + → x y n
≪ { } n + x SIZE + 0 CON
1 x SIZE '''FOR''' j
1 n '''FOR''' k
{ } k + j + x j GET k 1 - ^ PUT
'''NEXT NEXT'''
DUP y * SWAP DUP TRN * /
<span style="color:grey">@ the following lines convert the resulting vector into a polynomial equation</span>
DUP 'x' STO 1 GET
2 x SIZE '''FOR''' j 'X' * x j GET + '''NEXT'''
EXPAN COLCT
≫ ≫ '<span style="color:blue">FIT</span>' STO
 
[1 2 3 4 5 6 7 8 9 10] [1 6 17 34 57 86 121 162 209 262 321] 2 <span style="color:blue">FIT</span>
{{out}}
<pre>
1: '3+2*X+1*X^2'
</pre>
 
=={{header|Ruby}}==
1,150

edits