commons-statistics-regression/src/test/java/org/apache/commons/statistics/regression/stored/AbstractRegressionTest.java
/**
     * Verifies that newSampleData methods consistently insert unitary columns in
     * design matrix. Confirms the fix for MATH-411.
     */
Verifies that newSampleData methods consistently insert unitary columns in
design matrix. Confirms the fix for MATH-411.
Verifies that newSampleData methods consistently insert unitary columns in design matrix . Confirms the fix for MATH - 411 .
@Test
    public void testNewSample() {
        RegressionDataLoader testData = new RegressionDataLoader();
        double[] design = new double[] {1, 19, 22, 33, 2, 20, 30, 40, 3, 25, 35, 45, 4, 27, 37, 47};
        double[] y = new double[] {1, 2, 3, 4};
        double[][] x = new double[][] {{19, 22, 33}, {20, 30, 40}, {25, 35, 45}, {27, 37, 47}};
        testData.inputNewSampleData(design, 4, 3);
        regression = createRegression(testData);
        StatisticsMatrix flatX = regression.getX().copy();
        StatisticsMatrix flatY = regression.getY().copy();
        testData.inputNewXSampleData(x);
        testData.inputNewYSampleData(y);
        Assertions.assertArrayEquals(flatX.toArray2D(), regression.getX().toArray2D());
        Assertions.assertArrayEquals(flatY.toArray1D(), regression.getY().toArray1D());
        testData.setHasIntercept(false);
        testData.inputNewSampleData(design, 4, 3);
        flatX = regression.getX().copy();
        flatY = regression.getY().copy();
        testData.inputNewXSampleData(x);
        testData.inputNewYSampleData(y);
        Assertions.assertArrayEquals(flatX.toArray2D(), regression.getX().toArray2D());
        Assertions.assertArrayEquals(flatY.toArray1D(), regression.getY().toArray1D());
        regression = createRegression(myData);
    }
@ Test public void testNewSample ( ) { RegressionDataLoader testData = new RegressionDataLoader ( ) ; double [ ] design = new double [ ] { 1 , 19 , 22 , 33 , 2 , 20 , 30 , 40 , 3 , 25 , 35 , 45 , 4 , 27 , 37 , 47 } ; double [ ] y = new double [ ] { 1 , 2 , 3 , 4 } ; double [ ] [ ] x = new double [ ] [ ] { { 19 , 22 , 33 } , { 20 , 30 , 40 } , { 25 , 35 , 45 } , { 27 , 37 , 47 } } ; testData . inputNewSampleData ( design , 4 , 3 ) ; regression = createRegression ( testData ) ; StatisticsMatrix flatX = regression . getX ( ) . copy ( ) ; StatisticsMatrix flatY = regression . getY ( ) . copy ( ) ; testData . inputNewXSampleData ( x ) ; testData . inputNewYSampleData ( y ) ; Assertions . assertArrayEquals ( flatX . toArray2D ( ) , regression . getX ( ) . toArray2D ( ) ) ; Assertions . assertArrayEquals ( flatY . toArray1D ( ) , regression . getY ( ) . toArray1D ( ) ) ; testData . setHasIntercept ( false ) ; testData . inputNewSampleData ( design , 4 , 3 ) ; flatX = regression . getX ( ) . copy ( ) ; flatY = regression . getY ( ) . copy ( ) ; testData . inputNewXSampleData ( x ) ; testData . inputNewYSampleData ( y ) ; Assertions . assertArrayEquals ( flatX . toArray2D ( ) , regression . getX ( ) . toArray2D ( ) ) ; Assertions . assertArrayEquals ( flatY . toArray1D ( ) , regression . getY ( ) . toArray1D ( ) ) ; regression = createRegression ( myData ) ; }
Verifies that newSampleData methods consistently insert unitary columns in
 design matrix.
Verifies that newSampleData methods consistently insert unitary columns in design matrix .
// No intercept