Browse souce code repository at: https://github.com/jjYBdx4IL/java-evaluation/blob/master/src/test/java/org/apache/commons/math3/StatSimpleRegressionTest.java
/*
 * #%L
 * Evaluation
 * %%
 * Copyright (C) 2015 - 2016 Github jjYBdx4IL Projects
 * %%
 * #L%
 */
package org.apache.commons.math3;

import static org.junit.Assert.assertEquals;

import org.apache.commons.math3.stat.regression.RegressionResults;
import org.apache.commons.math3.stat.regression.SimpleRegression;
import org.junit.Test;

/**
 *
 * @author Github jjYBdx4IL Projects
 */
public class StatSimpleRegressionTest {

    @Test
    public void testSimpleRegression() {
        SimpleRegression sr = new SimpleRegression(true);
        double[][] data = new double[][]{
            {0, 0},
            {1, 1},
            {2, 2},
        };
        sr.addData(data);
        RegressionResults rr = sr.regress();
        
        double[] estimates = rr.getParameterEstimates();
        assertEquals(2, estimates.length);
        assertEquals(0d, estimates[0], 1e-7);
        assertEquals(1d, estimates[1], 1e-7);
    }
    
}
-------------------------------------------------------------------------------
Test set: org.apache.commons.math3.StatSimpleRegressionTest
-------------------------------------------------------------------------------
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0 s - in org.apache.commons.math3.StatSimpleRegressionTest
testSimpleRegression  Time elapsed: 0 s