Example #1
0
        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)
            });
        }
Example #2
0
        public MainWindow()
        {
            InitializeComponent();
            Assignment5Result result = Assignment5.Analyze(PHYS121L.l, PHYS121L.h, PHYS121L.Measurements);

            this.textBlock.Text = string.Format("Slope is {0}\nIntercept is {1}\nGravity is {2} m/s^2\nStandard deviation is {3}", result.LeastSquaresFitResult.Slope,
                                                result.LeastSquaresFitResult.Intercept, result.g, result.StandardDeviation);

            Point[] points = new Point[]
            {
                new Point(this.Chart.XMin, result.LeastSquaresFitResult.Intercept),
                new Point(this.Chart.XMax, result.LeastSquaresFitResult.Intercept + result.LeastSquaresFitResult.Slope * this.Chart.XMax)
            };

            this.Chart.AddLinePlot(points);
            this.Chart.AddCirclePlot(PHYS121L.Measurements.Select(m => new Point(m.Distance, m.TimeValues.Average(t => t * t))), 12);
        }