commit
8694f8478b
|
@ -54,6 +54,9 @@ If the output is not quite correct, check for invisible trailing spaces!
|
|||
</release>
|
||||
|
||||
<release version="4.0" date="XXXX-XX-XX" description="">
|
||||
<action dev="erans" type="add" issue="MATH-1477" due-to="Chee Sing Lee">
|
||||
"MillerUpdatingRegression": Fixed "ArrayIndexOutOfBounds" exception.
|
||||
</action>
|
||||
<action dev="erans" type="fix" issue="MATH-1463">
|
||||
"IntegerSequence.incrementor": Throw "NoSuchElementException" from "next" method.
|
||||
</action>
|
||||
|
|
|
@ -1063,7 +1063,7 @@ public class MillerUpdatingRegression implements UpdatingMultipleLinearRegressio
|
|||
}
|
||||
|
||||
boolean needsReorder = false;
|
||||
for (int i = 0; i < this.nvars; i++) {
|
||||
for (int i = 0; i < series.length; i++) {
|
||||
if (this.vorder[i] != series[i]) {
|
||||
needsReorder = true;
|
||||
break;
|
||||
|
|
|
@ -1051,19 +1051,27 @@ public class MillerUpdatingRegressionTest {
|
|||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testSubsetRegression() {
|
||||
|
||||
MillerUpdatingRegression instance = new MillerUpdatingRegression(3, true);
|
||||
MillerUpdatingRegression redRegression = new MillerUpdatingRegression(2, true);
|
||||
private void subsetRegression(int i_exclude, boolean constant){
|
||||
int[] indices = new int[2];
|
||||
int j = 0;
|
||||
for (int i = 0; i < 3; i++){
|
||||
if (i != i_exclude){
|
||||
indices[j] = i;
|
||||
j++;
|
||||
}
|
||||
}
|
||||
int i0 = indices[0];
|
||||
int i1 = indices[1];
|
||||
MillerUpdatingRegression instance = new MillerUpdatingRegression(3, constant);
|
||||
MillerUpdatingRegression redRegression = new MillerUpdatingRegression(2, constant);
|
||||
double[][] x = new double[airdata[0].length][];
|
||||
double[][] xReduced = new double[airdata[0].length][];
|
||||
double[] y = new double[airdata[0].length];
|
||||
for (int i = 0; i < airdata[0].length; i++) {
|
||||
x[i] = new double[3];
|
||||
x[i][0] = FastMath.log(airdata[3][i]);
|
||||
x[i][1] = FastMath.log(airdata[4][i]);
|
||||
x[i][2] = airdata[5][i];
|
||||
x[i][i0] = FastMath.log(airdata[3][i]);
|
||||
x[i][i1] = FastMath.log(airdata[4][i]);
|
||||
x[i][i_exclude] = airdata[5][i];
|
||||
|
||||
xReduced[i] = new double[2];
|
||||
xReduced[i][0] = FastMath.log(airdata[3][i]);
|
||||
|
@ -1075,7 +1083,17 @@ public class MillerUpdatingRegressionTest {
|
|||
instance.addObservations(x, y);
|
||||
redRegression.addObservations(xReduced, y);
|
||||
|
||||
RegressionResults resultsInstance = instance.regress( new int[]{0,1,2} );
|
||||
int includedIndices[];
|
||||
if (constant){
|
||||
includedIndices = new int[3];
|
||||
includedIndices[0] = 0;
|
||||
includedIndices[1] = i0 + 1;
|
||||
includedIndices[2] = i1 + 1;
|
||||
} else {
|
||||
includedIndices = indices;
|
||||
}
|
||||
|
||||
RegressionResults resultsInstance = instance.regress( includedIndices );
|
||||
RegressionResults resultsReduced = redRegression.regress();
|
||||
|
||||
TestUtils.assertEquals(resultsInstance.getParameterEstimates(), resultsReduced.getParameterEstimates(), 1.0e-12);
|
||||
|
@ -1083,4 +1101,13 @@ public class MillerUpdatingRegressionTest {
|
|||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testSubsetRegression() {
|
||||
for (int i=0; i < 3; i++){
|
||||
subsetRegression(i, true);
|
||||
subsetRegression(i, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue