List of usage examples for org.apache.commons.math3.exception.util LocalizedFormats DIMENSIONS_MISMATCH_SIMPLE
LocalizedFormats DIMENSIONS_MISMATCH_SIMPLE
To view the source code for org.apache.commons.math3.exception.util LocalizedFormats DIMENSIONS_MISMATCH_SIMPLE.
Click Source Link
From source file:experiment.SimpleRegression_bug.java
/** * Adds a series of observations to the regression model. The lengths of * x and y must be the same and x must be rectangular. * * @param x a series of observations on the independent variables * @param y a series of observations on the dependent variable * The length of x and y must be the same * @throws ModelSpecificationException if {@code x} is not rectangular, does not match * the length of {@code y} or does not contain sufficient data to estimate the model *///w w w .jav a 2 s .c o m public void addObservations(final double[][] x, final double[] y) throws ModelSpecificationException { if ((x == null) || (y == null) || (x.length != y.length)) { throw new ModelSpecificationException(LocalizedFormats.DIMENSIONS_MISMATCH_SIMPLE, (x == null) ? 0 : x.length, (y == null) ? 0 : y.length); } boolean obsOk = true; for (int i = 0; i < x.length; i++) { if (x[i] == null || x[i].length == 0) { obsOk = false; } } if (!obsOk) { throw new ModelSpecificationException(LocalizedFormats.NOT_ENOUGH_DATA_FOR_NUMBER_OF_PREDICTORS, 0, 1); } for (int i = 0; i < x.length; i++) { addData(x[i][0], y[i]); } }
From source file:org.orekit.propagation.conversion.AbstractPropagatorBuilder.java
/** Check the size of the parameters array. * @param parameters to configure the propagator * @exception OrekitIllegalArgumentException if the number of * parameters is not 6 (for initial state) plus the number of free * parameters/* w ww. j av a 2 s. c o m*/ */ protected void checkParameters(final double[] parameters) throws OrekitIllegalArgumentException { if (parameters.length != (freeParameters.size() + 6)) { throw new OrekitIllegalArgumentException(LocalizedFormats.DIMENSIONS_MISMATCH_SIMPLE, parameters.length, freeParameters.size() + 6); } }
From source file:org.orekit.propagation.conversion.EcksteinHechlerConverterTest.java
@Test public void testWrongParametersSize() throws OrekitException { try {/*from w w w. j a v a2 s . co m*/ PropagatorBuilder builder = new EcksteinHechlerPropagatorBuilder(orbit.getFrame(), provider, OrbitType.CIRCULAR, PositionAngle.TRUE); final List<String> empty = Collections.emptyList(); builder.setFreeParameters(empty); builder.buildPropagator(orbit.getDate(), new double[3]); Assert.fail("an exception should have been thrown"); } catch (OrekitIllegalArgumentException oiae) { Assert.assertEquals(LocalizedFormats.DIMENSIONS_MISMATCH_SIMPLE, oiae.getSpecifier()); Assert.assertEquals(3, ((Integer) oiae.getParts()[0]).intValue()); Assert.assertEquals(6, ((Integer) oiae.getParts()[1]).intValue()); } }
From source file:org.orekit.propagation.conversion.KeplerianConverterTest.java
@Test public void testWrongParametersSize() throws OrekitException { try {/*from w w w. j a v a 2s. c o m*/ PropagatorBuilder builder = new KeplerianPropagatorBuilder(mu, orbit.getFrame(), OrbitType.CIRCULAR, PositionAngle.TRUE); final List<String> empty = Collections.emptyList(); builder.setFreeParameters(empty); builder.buildPropagator(orbit.getDate(), new double[3]); Assert.fail("an exception should have been thrown"); } catch (OrekitIllegalArgumentException oiae) { Assert.assertEquals(LocalizedFormats.DIMENSIONS_MISMATCH_SIMPLE, oiae.getSpecifier()); Assert.assertEquals(3, ((Integer) oiae.getParts()[0]).intValue()); Assert.assertEquals(6, ((Integer) oiae.getParts()[1]).intValue()); } }
From source file:org.orekit.propagation.conversion.NumericalConverterTest.java
@Test public void testWrongParametersSize() throws OrekitException { try {/* ww w.ja v a 2 s . c o m*/ NumericalPropagatorBuilder builder = new NumericalPropagatorBuilder(mu, orbit.getFrame(), new LutherIntegratorBuilder(100.0), OrbitType.CIRCULAR, PositionAngle.TRUE); builder.addForceModel(drag); builder.addForceModel(gravity); final List<String> empty = Collections.emptyList(); builder.setFreeParameters(empty); builder.buildPropagator(orbit.getDate(), new double[3]); Assert.fail("an exception should have been thrown"); } catch (OrekitIllegalArgumentException oiae) { Assert.assertEquals(LocalizedFormats.DIMENSIONS_MISMATCH_SIMPLE, oiae.getSpecifier()); Assert.assertEquals(3, ((Integer) oiae.getParts()[0]).intValue()); Assert.assertEquals(6, ((Integer) oiae.getParts()[1]).intValue()); } }
From source file:org.orekit.propagation.conversion.TLEConverterTest.java
@Test public void testWrongParametersSize() throws OrekitException { try {/*from w w w.ja va 2s .c o m*/ PropagatorBuilder builder = new TLEPropagatorBuilder(leoTLE.getSatelliteNumber(), leoTLE.getClassification(), leoTLE.getLaunchYear(), leoTLE.getLaunchNumber(), leoTLE.getLaunchPiece(), leoTLE.getElementNumber(), leoTLE.getRevolutionNumberAtEpoch(), OrbitType.CIRCULAR, PositionAngle.TRUE); final List<String> empty = Collections.emptyList(); builder.setFreeParameters(empty); builder.buildPropagator(leoTLE.getDate(), new double[3]); Assert.fail("an exception should have been thrown"); } catch (OrekitIllegalArgumentException oiae) { Assert.assertEquals(LocalizedFormats.DIMENSIONS_MISMATCH_SIMPLE, oiae.getSpecifier()); Assert.assertEquals(3, ((Integer) oiae.getParts()[0]).intValue()); Assert.assertEquals(6, ((Integer) oiae.getParts()[1]).intValue()); } }
From source file:Rotationforest.Covariance.java
/** * Computes the covariance between the two arrays. * * <p>Array lengths must match and the common length must be at least 2.</p> * * @param xArray first data array/* w ww .j a v a 2 s. c o m*/ * @param yArray second data array * @param biasCorrected if true, returned value will be bias-corrected * @return returns the covariance for the two arrays * @throws MathIllegalArgumentException if the arrays lengths do not match or * there is insufficient data */ public double covariance(final double[] xArray, final double[] yArray, boolean biasCorrected) throws MathIllegalArgumentException { Mean mean = new Mean(); double result = 0d; int length = xArray.length; if (length != yArray.length) { throw new MathIllegalArgumentException(LocalizedFormats.DIMENSIONS_MISMATCH_SIMPLE, length, yArray.length); } else if (length < 2) { throw new MathIllegalArgumentException(LocalizedFormats.INSUFFICIENT_OBSERVED_POINTS_IN_SAMPLE, length, 2); } else { double xMean = mean.evaluate(xArray); double yMean = mean.evaluate(yArray); for (int i = 0; i < length; i++) { double xDev = xArray[i] - xMean; double yDev = yArray[i] - yMean; result += (xDev * yDev - result) / (i + 1); } } return biasCorrected ? result * ((double) length / (double) (length - 1)) : result; }