GaussianCurveFitter extends AbstractCurveFitter { public static GaussianCurveFitter create() { return new GaussianCurveFitter(null, Integer.MAX_VALUE); } private  GaussianCurveFitter(double[] initialGuess,
                                int maxIter); static GaussianCurveFitter create(); GaussianCurveFitter withStartPoint(double[] newStart); GaussianCurveFitter withMaxIterations(int newMaxIter);  }
@Test public void testFit01() { GaussianCurveFitter fitter = GaussianCurveFitter.create(); double[] parameters = fitter.fit(createDataset(DATASET1).toList()); Assert.assertEquals(3496978.1837704973, parameters[0], 1e-4); Assert.assertEquals(4.054933085999146, parameters[1], 1e-4); Assert.assertEquals(0.015039355620304326, parameters[2], 1e-4); }
@Test(expected=MathIllegalArgumentException.class) public void testFit02() { GaussianCurveFitter.create().fit(new WeightedObservedPoints().toList()); }
@Test(expected=MathIllegalArgumentException.class) public void testFit03() { GaussianCurveFitter fitter = GaussianCurveFitter.create(); fitter.fit(createDataset(new double[][] { {4.0254623, 531026.0}, {4.02804905, 664002.0} }).toList()); }
@Test public void testFit04() { GaussianCurveFitter fitter = GaussianCurveFitter.create(); double[] parameters = fitter.fit(createDataset(DATASET2).toList()); Assert.assertEquals(233003.2967252038, parameters[0], 1e-4); Assert.assertEquals(-10.654887521095983, parameters[1], 1e-4); Assert.assertEquals(4.335937353196641, parameters[2], 1e-4); }
@Test public void testFit05() { GaussianCurveFitter fitter = GaussianCurveFitter.create(); double[] parameters = fitter.fit(createDataset(DATASET3).toList()); Assert.assertEquals(283863.81929180305, parameters[0], 1e-4); Assert.assertEquals(-13.29641995105174, parameters[1], 1e-4); Assert.assertEquals(1.7297330293549908, parameters[2], 1e-4); }
@Test public void testFit06() { GaussianCurveFitter fitter = GaussianCurveFitter.create(); double[] parameters = fitter.fit(createDataset(DATASET4).toList()); Assert.assertEquals(285250.66754309234, parameters[0], 1e-4); Assert.assertEquals(-13.528375695228455, parameters[1], 1e-4); Assert.assertEquals(1.5204344894331614, parameters[2], 1e-4); }
@Test public void testFit07() { GaussianCurveFitter fitter = GaussianCurveFitter.create(); double[] parameters = fitter.fit(createDataset(DATASET5).toList()); Assert.assertEquals(3514384.729342235, parameters[0], 1e-4); Assert.assertEquals(4.054970307455625, parameters[1], 1e-4); Assert.assertEquals(0.015029412832160017, parameters[2], 1e-4); }
@Test public void testMath519() { final double[] data = { 1.1143831578403364E-29, 4.95281403484594E-28, 1.1171347211930288E-26, 1.7044813962636277E-25, 1.9784716574832164E-24, 1.8630236407866774E-23, 1.4820532905097742E-22, 1.0241963854632831E-21, 6.275077366673128E-21, 3.461808994532493E-20, 1.7407124684715706E-19, 8.056687953553974E-19, 3.460193945992071E-18, 1.3883326374011525E-17, 5.233894983671116E-17, 1.8630791465263745E-16, 6.288759227922111E-16, 2.0204433920597856E-15, 6.198768938576155E-15, 1.821419346860626E-14, 5.139176445538471E-14, 1.3956427429045787E-13, 3.655705706448139E-13, 9.253753324779779E-13, 2.267636001476696E-12, 5.3880460095836855E-12, 1.2431632654852931E-11 }; final WeightedObservedPoints obs = new WeightedObservedPoints(); for (int i = 0; i < data.length; i++) { obs.add(i, data[i]); } final double[] p = GaussianCurveFitter.create().fit(obs.toList()); Assert.assertEquals(53.1572792, p[1], 1e-7); Assert.assertEquals(5.75214622, p[2], 1e-8); }
@Test public void testMath798() { final WeightedObservedPoints obs = new WeightedObservedPoints(); obs.add(0.23, 395.0); obs.add(1.14, 376.0); obs.add(2.05, 163.0); obs.add(2.95, 49.0); obs.add(3.86, 16.0); obs.add(4.77, 1.0); final double[] p = GaussianCurveFitter.create().fit(obs.toList()); Assert.assertEquals(420.8397296167364, p[0], 1e-12); Assert.assertEquals(0.603770729862231, p[1], 1e-15); Assert.assertEquals(1.0786447936766612, p[2], 1e-14); }