# # canola - canon canola 1614p emulator # Copyright (C) 2011 Peter Miller # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License, version 3, as # published by the Free Software Foundation. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License along # with this program. If not, see . # ; ------------------ Card-Pocket-Begin ----------------------------------- ; Title: ST-2: Linear Regression ; Color: green ; Style: blank ; ------------------ Card-Pocket-End ------------------------------------- ; ; How-to-Operate: ; [START] ; x1 [START] y1 [START] ; x2 [START] y2 [START] ; x3 [START] y3 [START] ; : : : : ; xn [START] yn [START] ; [START] => a ; b ; x [START] => y ; this repeats ; : : ; [START] ; no X entry means start again from beginning ; ; Example: ; [START] ; 2 [START] 12 [START] ; 3 [START] 15 [START] ; 4 [START] 20 [START] ; [START] => 3.66667 ; a ; 4.00000 ; b ; 1 [START] => 7.66667 ; ; Equations: ; y = a + b * x ; a = (sigma(x**2) * sigma(y) - sigma(x) * sigma(x * y)) / ; (n * sigma(x**2) - (sigma(x))**2) ; b = (n * sigma(x * y) - sigma(x) * sigma(y)) / ; (n * sigma(x**2) - (sigma(x))**2) ; CM14 ; sigma(x) CM13 ; sigma(x**2) CM12 ; sigma(y) CM11 ; sigma(x * y) CM10 ; n ENT FJ $611 M14 * += M13 RV * ENT M12 += M11 1 M10 RM10 EJ $611 ; if more data, loop * RM13 += SM9 ; m9 = n * sigma(x**2) RM14 * -= M9 ; m9 = n * sigma(x**2) - sigma(x) ** 2 RM10 * RM11 += SM10 ; m10 = n * sigma(x * y) RM14 * RM12 -= ; - sigma(x) * sigma(y) RM10 += ; n * sigma(x * y) - sigma(x) * sigma(y) / RM9 ROUND 5 += SM10 ; b RM14 * RM11 -= ; sigma(x) * sigma(x * y) SM14 RM13 * RM12 ; sigma(x**2) * sigma(y) += RM14 += ; sigma(x**2) * sigma(y) - sigma(x) * sigma(x * y) / RM9 ROUND 5 += SM9 ; a PRINT RM10 ; b PRINT ENT ; x FJ $612 * RM10 += RM9 += PRINT ; a + b * x EJ $612