func1 function
Fits y = a*f(x) to sample data.
Implementation
double func1(List<DataPoint> p, double Function(double) f) {
var syf = 0.0, sf2 = 0.0;
for (final pt in p) {
final fv = f(pt.x);
syf += pt.y * fv;
sf2 += fv * fv;
}
return syf / sf2;
}