public static Assignment5Result Analyze(double l, double h, Measurement[] measurements) { Point[] points = measurements.Select(m => new Point(m.Distance, m.TimeValues.Average(t => t * t))).ToArray(); LeastSquaresFitResult result = Assignment5.LeastSquaresFit(points); return(new Assignment5Result { LeastSquaresFitResult = result, g = 2 * l / (result.Slope * h) / 100, StandardDeviation = Assignment5.StandardDeviationY(points, result) }); }
public static double StandardDeviationY(Point[] points, LeastSquaresFitResult result) { return(Math.Sqrt(points.Sum(p => Math.Pow(p.Y - (result.Intercept + result.Slope * p.X), 2)) / (points.Length - 2))); }