Polynomial regression: Difference between revisions

Content added Content deleted
m (→‎{{header|Perl 6}}: remove surnumerary newline)
(→‎{{header|zkl}}: added GSL solution)
Line 1,240: Line 1,240:


=={{header|zkl}}==
=={{header|zkl}}==
Using the GNU Scientific Library
<lang zkl>var [const] GSL=Import("zklGSL"); // libGSL (GNU Scientific Library)
xs:=GSL.VectorFromData(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
ys:=GSL.VectorFromData(1, 6, 17, 34, 57, 86, 121, 162, 209, 262, 321);
v :=GSL.polyFit(xs,ys,2);
v.format().println();
GSL.Helpers.polyString(v).println();
GSL.Helpers.polyEval(v,xs).format().println();</lang>
{{out}}
<pre>
1.00,2.00,3.00
1 + 2x + 3x^2
1.00,6.00,17.00,34.00,57.00,86.00,121.00,162.00,209.00,262.00,321.00
</pre>
Or, using lists:
{{trans|Common Lisp}}
{{trans|Common Lisp}}
Uses the code from [[Multiple regression#zkl]].
Uses the code from [[Multiple regression#zkl]].