List of usage examples for org.apache.commons.math3.exception OutOfRangeException OutOfRangeException
public OutOfRangeException(Localizable specific, Number wrong, Number lo, Number hi)
From source file:eu.tsp.sal.SensorGeneticAlgorithm.java
/** * Create a new genetic algorithm.//from w ww. j a v a 2 s. c om * @param crossoverPolicy The {@link CrossoverPolicy} * @param crossoverRate The crossover rate as a percentage (0-1 inclusive) * @param mutationPolicy The {@link MutationPolicy} * @param mutationRate The mutation rate as a percentage (0-1 inclusive) * @param selectionPolicy The {@link SelectionPolicy} * @throws OutOfRangeException if the crossover or mutation rate is outside the [0, 1] range */ public SensorGeneticAlgorithm(final CrossoverPolicy crossoverPolicy, final double crossoverRate, final MutationPolicy mutationPolicy, final double mutationRate, final SelectionPolicy selectionPolicy) throws OutOfRangeException { if (crossoverRate < 0 || crossoverRate > 1) { throw new OutOfRangeException(LocalizedFormats.CROSSOVER_RATE, crossoverRate, 0, 1); } if (mutationRate < 0 || mutationRate > 1) { throw new OutOfRangeException(LocalizedFormats.MUTATION_RATE, mutationRate, 0, 1); } this.crossoverPolicy = crossoverPolicy; this.crossoverRate = crossoverRate; this.mutationPolicy = mutationPolicy; this.mutationRate = mutationRate; this.selectionPolicy = selectionPolicy; }
From source file:cz.cuni.lf1.lge.ThunderSTORM.results.ModifiedLoess.java
/** * Construct a new {@link LoessInterpolator} * with given bandwidth, number of robustness iterations and accuracy. * * @param bandwidth when computing the loess fit at * a particular point, this fraction of source points closest * to the current point is taken into account for computing * a least-squares regression.</br> * A sensible value is usually 0.25 to 0.5, the default value is * {@link #DEFAULT_BANDWIDTH}.// ww w . j ava 2 s . co m * @param robustnessIters This many robustness iterations are done.</br> * A sensible value is usually 0 (just the initial fit without any * robustness iterations) to 4, the default value is * {@link #DEFAULT_ROBUSTNESS_ITERS}. * @param accuracy If the median residual at a certain robustness iteration * is less than this amount, no more iterations are done. * @throws OutOfRangeException if bandwidth does not lie in the interval [0,1]. * @throws NotPositiveException if {@code robustnessIters} is negative. * @see #LoessInterpolator(double, int) * @since 2.1 */ public ModifiedLoess(double bandwidth, int robustnessIters, double accuracy) throws OutOfRangeException, NotPositiveException { if (bandwidth < 0 || bandwidth > 1) { throw new OutOfRangeException(LocalizedFormats.BANDWIDTH, bandwidth, 0, 1); } this.bandwidth = bandwidth; if (robustnessIters < 0) { throw new NotPositiveException(LocalizedFormats.ROBUSTNESS_ITERATIONS, robustnessIters); } this.robustnessIters = robustnessIters; this.accuracy = accuracy; }
From source file:experiment.SimpleRegression_bug.java
/** * Returns the half-width of a (100-100*alpha)% confidence interval for * the slope estimate.// ww w . j a va2 s.c o m * <p> * The (100-100*alpha)% confidence interval is </p> * <p> * <code>(getSlope() - getSlopeConfidenceInterval(), * getSlope() + getSlopeConfidenceInterval())</code></p> * <p> * To request, for example, a 99% confidence interval, use * <code>alpha = .01</code></p> * <p> * <strong>Usage Note</strong>:<br> * The validity of this statistic depends on the assumption that the * observations included in the model are drawn from a * <a href="http://mathworld.wolfram.com/BivariateNormalDistribution.html"> * Bivariate Normal Distribution</a>.</p> * <p> * <strong> Preconditions:</strong><ul> * <li>If there are fewer that <strong>three</strong> observations in the * model, or if there is no variation in x, this returns * <code>Double.NaN</code>. * </li> * <li><code>(0 < alpha < 1)</code>; otherwise an * <code>OutOfRangeException</code> is thrown. * </li></ul></p> * * @param alpha the desired significance level * @return half-width of 95% confidence interval for the slope estimate * @throws OutOfRangeException if the confidence interval can not be computed. */ public double getSlopeConfidenceInterval(final double alpha) throws OutOfRangeException { if (n < 3) { return Double.NaN; } if (alpha >= 1 || alpha <= 0) { throw new OutOfRangeException(LocalizedFormats.SIGNIFICANCE_LEVEL, alpha, 0, 1); } // No advertised NotStrictlyPositiveException here - will return NaN above TDistribution distribution = new TDistribution(n - 2); return getSlopeStdErr() * distribution.inverseCumulativeProbability(1d - alpha / 2d); }
From source file:cz.cuni.mff.spl.evaluator.statistics.KolmogorovSmirnovTestFlag.java
/** * Performs a <a href="http://en.wikipedia.org/wiki/Kolmogorov-Smirnov_test"> Kolmogorov-Smirnov * test</a> evaluating the null hypothesis that {@code data} conforms to {@code distribution}. * * @param distribution reference distribution * @param data sample being being evaluated * @param alpha significance level of the test * @return true iff the null hypothesis that {@code data} is a sample from {@code distribution} * can be rejected with confidence 1 - {@code alpha} * @throws InsufficientDataException if {@code data} does not have length at least 2 * @throws NullArgumentException if {@code data} is null *//*from w ww . ja va2s. c o m*/ public boolean kolmogorovSmirnovTest(RealDistribution distribution, double[] data, double alpha) { if ((alpha <= 0) || (alpha > 0.5)) { throw new OutOfRangeException(LocalizedFormats.OUT_OF_BOUND_SIGNIFICANCE_LEVEL, alpha, 0, 0.5); } return kolmogorovSmirnovTest(distribution, data) < alpha; }
From source file:embedded2.ESecure.TTest.java
/** * Check significance level.//from w ww. ja v a2s .co m * * @param alpha significance level * @throws OutOfRangeException if the significance level is out of bounds. */ private static void checkSignificanceLevel(final double alpha) throws OutOfRangeException { if (alpha <= 0 || alpha > 0.5) { throw new OutOfRangeException(LocalizedFormats.SIGNIFICANCE_LEVEL, alpha, 0.0, 0.5); } }
From source file:com.itemanalysis.psychometrics.optimization.BOBYQAOptimizer.java
/** * Performs validity checks./* w w w . j a v a2s . c o m*/ * * @param lowerBound Lower bounds (constraints) of the objective variables. * @param upperBound Upperer bounds (constraints) of the objective variables. */ private void setup(double[] lowerBound, double[] upperBound) { printMethod(); // XXX double[] init = getStartPoint(); final int dimension = init.length; // Check problem dimension. if (dimension < MINIMUM_PROBLEM_DIMENSION) { throw new NumberIsTooSmallException(dimension, MINIMUM_PROBLEM_DIMENSION, true); } // Check number of interpolation points. final int[] nPointsInterval = { dimension + 2, (dimension + 2) * (dimension + 1) / 2 }; if (numberOfInterpolationPoints < nPointsInterval[0] || numberOfInterpolationPoints > nPointsInterval[1]) { throw new OutOfRangeException(LocalizedFormats.NUMBER_OF_INTERPOLATION_POINTS, numberOfInterpolationPoints, nPointsInterval[0], nPointsInterval[1]); } // Initialize bound differences. boundDifference = new double[dimension]; double requiredMinDiff = 2 * initialTrustRegionRadius; double minDiff = Double.POSITIVE_INFINITY; for (int i = 0; i < dimension; i++) { boundDifference[i] = upperBound[i] - lowerBound[i]; minDiff = Math.min(minDiff, boundDifference[i]); } if (minDiff < requiredMinDiff) { initialTrustRegionRadius = minDiff / 3.0; } // Initialize the data structures used by the "bobyqa" method. bMatrix = new Array2DRowRealMatrix(dimension + numberOfInterpolationPoints, dimension); zMatrix = new Array2DRowRealMatrix(numberOfInterpolationPoints, numberOfInterpolationPoints - dimension - 1); interpolationPoints = new Array2DRowRealMatrix(numberOfInterpolationPoints, dimension); originShift = new ArrayRealVector(dimension); fAtInterpolationPoints = new ArrayRealVector(numberOfInterpolationPoints); trustRegionCenterOffset = new ArrayRealVector(dimension); gradientAtTrustRegionCenter = new ArrayRealVector(dimension); lowerDifference = new ArrayRealVector(dimension); upperDifference = new ArrayRealVector(dimension); modelSecondDerivativesParameters = new ArrayRealVector(numberOfInterpolationPoints); newPoint = new ArrayRealVector(dimension); alternativeNewPoint = new ArrayRealVector(dimension); trialStepPoint = new ArrayRealVector(dimension); lagrangeValuesAtNewPoint = new ArrayRealVector(dimension + numberOfInterpolationPoints); modelSecondDerivativesValues = new ArrayRealVector(dimension * (dimension + 1) / 2); }
From source file:org.apache.kylin.cube.cuboid.algorithm.generic.lib.ElitisticListPopulation.java
/** * Sets the elitism rate, i.e. how many best chromosomes will be directly transferred to the next generation [in %]. * * @param elitismRate how many best chromosomes will be directly transferred to the next generation [in %] * @throws OutOfRangeException if the elitism rate is outside the [0, 1] range *///from w ww .j a v a2 s . c o m public void setElitismRate(final double elitismRate) throws OutOfRangeException { if (elitismRate < 0 || elitismRate > 1) { throw new OutOfRangeException(LocalizedFormats.ELITISM_RATE, elitismRate, 0, 1); } this.elitismRate = elitismRate; }
From source file:ro.hasna.ts.math.filter.ExponentialMovingAverageFilter.java
public ExponentialMovingAverageFilter(double smoothingFactor) { if (smoothingFactor <= 0 || smoothingFactor >= 1) { throw new OutOfRangeException(LocalizableMessages.OUT_OF_RANGE_BOTH_EXCLUSIVE, smoothingFactor, 0, 1); }//from w ww. j a va 2 s . co m this.smoothingFactor = smoothingFactor; }
From source file:ro.hasna.ts.math.ml.distance.DynamicTimeWarpingDistance.java
/** * Creates a new instance of this class with * * @param radiusPercentage Sakoe-Chiba Band width used to constraint the warping window * @param normalizer the normalizer (it can be null if the values were normalized) * @throws OutOfRangeException if radiusPercentage is outside the interval [0, 1] *///from w w w . java 2 s. c om public DynamicTimeWarpingDistance(double radiusPercentage, Normalizer normalizer) { if (radiusPercentage < 0 || radiusPercentage > 1) { throw new OutOfRangeException(LocalizableMessages.OUT_OF_RANGE_BOTH_INCLUSIVE, radiusPercentage, 0, 1); } this.radiusPercentage = radiusPercentage; this.normalizer = normalizer; }
From source file:ro.hasna.ts.math.ml.distance.LongestCommonSubsequenceDistance.java
/** * Creates a new instance of this class with * * @param epsilon the maximum absolute difference between two values that are considered equal * @param radiusPercentage Sakoe-Chiba Band width used to constraint the searching window * @throws OutOfRangeException if radiusPercentage is outside the interval [0, 1] *///from w w w .j a v a 2s. c om public LongestCommonSubsequenceDistance(double epsilon, double radiusPercentage) { this.epsilon = epsilon; if (radiusPercentage < 0 || radiusPercentage > 1) { throw new OutOfRangeException(LocalizableMessages.OUT_OF_RANGE_BOTH_INCLUSIVE, radiusPercentage, 0, 1); } this.radiusPercentage = radiusPercentage; }