next up previous
Next: Selection Up: Benchmark Code Previous: Benchmark Code

Line-fit

   function linefit(x, y) =
      let 
        n    = float(#x);
        xa   = sum(x)/n;
        ya   = sum(y)/n;
        Stt  = sum({(x - xa)^2: x});
        b    = sum({(x - xa) * y: x; y}) / Stt;
        a    = ya - xa*b;
        chi2 = sum({(y - a - b * x)^2: x; y});
        siga = sqrt((1.0 / n + xa^2 / Stt)* chi2 / n);
        sigb = sqrt((1.0 / Stt) * chi2 / n)
      in 
        (a, b, siga, sigb);

For the line-fit benchmarks, x and y were both copies of the floating-point index vector [0.0, 1.0, 2.0, ...].


next up previous
Next: Selection Up: Benchmark Code Previous: Benchmark Code

Jonathan Hardwick