Esempio n. 1
0
        public void RunLine()
        {
            double[] x = {0, 2, 6, 8, 9};
            double[] a = {2, 0.51};

            LMAFunction f = new LineFunction();

            double[][] dataPoints = f.GenerateData(a,x);

            LMA algorithm = new LMA(f,new double[] {100, -100},
                dataPoints, null, new GeneralMatrix(2,2),1d-20,100);

            algorithm.Fit();

            for (int i=0; i<a.Length; i++)
            {
                Assert.IsTrue(System.Math.Abs(algorithm.Parameters[i]-a[i])<0.0001);
                Trace.WriteLine("Parameter" + i.ToString() + " " + algorithm.Parameters[i].ToString());
            }

            Trace.WriteLine("# of iterations =" + algorithm.Iterations.ToString());
        }
Esempio n. 2
0
        public void RunLine()
        {
            double[] x = { 0, 2, 6, 8, 9 };
            double[] a = { 2, 0.51 };

            LMAFunction f = new LineFunction();

            double[][] dataPoints = f.GenerateData(a, x);

            LMA algorithm = new LMA(f, new double[] { 100, -100 },
                                    dataPoints, null, new GeneralMatrix(2, 2), 1d - 20, 100);

            algorithm.Fit();

            for (int i = 0; i < a.Length; i++)
            {
                Assert.IsTrue(System.Math.Abs(algorithm.Parameters[i] - a[i]) < 0.0001);
                Trace.WriteLine("Parameter" + i.ToString() + " " + algorithm.Parameters[i].ToString());
            }

            Trace.WriteLine("# of iterations =" + algorithm.Iterations.ToString());
        }