public static LevenbergMarquardt fit(DifferentiableMultivariateFunction func, double[] x, double[] y, double[] p) {
        return fit(func, x, y, p, 0.0001, 20);
    }
@Test
    public void test() {
        System.out.println("LevenbergMarquardt");

        MathEx.setSeed(19650218); // to get repeatable results.
        double[] x = new double[100];
        double[] y = new double[100];
        GaussianDistribution d = new GaussianDistribution(0.0, 1);
        for (int i = 0; i < x.length; i++) {
            x[i] = (i+1) * 0.05;
            y[i] = 1.0 / (1 + 1.2 * Math.pow(x[i], 1.8)) + d.rand() * 0.03;
        }

        double[] p = {0.5, 0.0};
        LevenbergMarquardt lma = LevenbergMarquardt.fit(func, x, y, p);
        assertEquals(0.0863, lma.sse, 1E-4);
        assertEquals(1.2260, lma.parameters[0], 1E-4);
        assertEquals(1.8024, lma.parameters[1], 1E-4);
    }