Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
12
Task/Polynomial-regression/GAP/polynomial-regression.gap
Normal file
12
Task/Polynomial-regression/GAP/polynomial-regression.gap
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
PolynomialRegression := function(x, y, n)
|
||||
local a;
|
||||
a := List([0 .. n], i -> List(x, s -> s^i));
|
||||
return TransposedMat((a * TransposedMat(a))^-1 * a * TransposedMat([y]))[1];
|
||||
end;
|
||||
|
||||
x := [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
|
||||
y := [1, 6, 17, 34, 57, 86, 121, 162, 209, 262, 321];
|
||||
|
||||
# Return coefficients in ascending degree order
|
||||
PolynomialRegression(x, y, 2);
|
||||
# [ 1, 2, 3 ]
|
||||
Loading…
Add table
Add a link
Reference in a new issue