/** {@inheritDoc} */ @Override public double inverseCumulativeProbability(final double p) throws OutOfRangeException { if (p < 0.0 || p > 1.0) { throw new OutOfRangeException(p, 0, 1); } return value; }
@Override public double inverseCumulativeProbability(final double p) throws OutOfRangeException { if (p < 0.0 || p > 1.0) { throw new OutOfRangeException(p, 0, 1); } return p * (upper - lower) + lower; }
/** * Get the simplex point stored at the requested {@code index}. * * @param index Location. * @return the point at location {@code index}. */ public PointValuePair getPoint(int index) { if (index < 0 || index >= simplex.length) { throw new OutOfRangeException(index, 0, simplex.length - 1); } return simplex[index]; }
/** * Creates a new {@link UniformCrossover} policy using the given mixing ratio. * * @param ratio the mixing ratio * @throws OutOfRangeException if the mixing ratio is outside the [0, 1] range */ public UniformCrossover(final double ratio) throws OutOfRangeException { if (ratio < 0.0d || ratio > 1.0d) { throw new OutOfRangeException(LocalizedFormats.CROSSOVER_RATE, ratio, 0.0d, 1.0d); } this.ratio = ratio; }
/** {@inheritDoc} */ @Override public void addToEntry(int index, double increment) throws OutOfRangeException { try { data[index] += increment; } catch(IndexOutOfBoundsException e){ throw new OutOfRangeException(LocalizedFormats.INDEX, index, 0, data.length - 1); } }
/** {@inheritDoc} */ @Override public double inverseCumulativeProbability(final double p) throws OutOfRangeException { if (p < 0.0 || p > 1.0) { throw new OutOfRangeException(p, 0, 1); } return p * (upper - lower) + lower; }
/** * 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 */ 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; }
/** * Check significance level. * * @param alpha significance level * @throws OutOfRangeException if the significance level is out of bounds. */ private void checkSignificanceLevel(final double alpha) throws OutOfRangeException { if (alpha <= 0 || alpha > 0.5) { throw new OutOfRangeException(LocalizedFormats.SIGNIFICANCE_LEVEL, alpha, 0.0, 0.5); } }
/** * Constructs a PSquarePercentile with the specific percentile value. * @param p the percentile * @throws OutOfRangeException if p is not greater than 0 and less * than or equal to 100 */ public PSquarePercentile(final double p) { if (p > 100 || p < 0) { throw new OutOfRangeException(LocalizedFormats.OUT_OF_RANGE, p, 0, 100); } this.quantile = p / 100d;// always set it within (0,1] }
/** * Return marker height given index * * @param markerIndex index of marker within (1,6) * @return marker height */ public double height(final int markerIndex) { if (markerIndex >= markerArray.length || markerIndex <= 0) { throw new OutOfRangeException(markerIndex, 1, markerArray.length); } return markerArray[markerIndex].markerHeight; }
/** * Get the simplex point stored at the requested {@code index}. * * @param index Location. * @return the point at location {@code index}. */ public PointValuePair getPoint(int index) { if (index < 0 || index >= simplex.length) { throw new OutOfRangeException(index, 0, simplex.length - 1); } return simplex[index]; }
/** * Store a new point at location {@code index}. * Note that no deep-copy of {@code point} is performed. * * @param index Location. * @param point New value. */ protected void setPoint(int index, PointValuePair point) { if (index < 0 || index >= simplex.length) { throw new OutOfRangeException(index, 0, simplex.length - 1); } simplex[index] = point; }
/** * Store a new point at location {@code index}. * Note that no deep-copy of {@code point} is performed. * * @param index Location. * @param point New value. */ protected void setPoint(int index, PointValuePair point) { if (index < 0 || index >= simplex.length) { throw new OutOfRangeException(index, 0, simplex.length - 1); } simplex[index] = point; }
/** * Sets the value of the quantile field (determines what percentile is * computed when evaluate() is called with no quantile argument). * * @param p a value between 0 < p <= 100 * @throws MathIllegalArgumentException if p is not greater than 0 and less * than or equal to 100 */ public void setQuantile(final double p) throws MathIllegalArgumentException { if (p <= 0 || p > 100) { throw new OutOfRangeException( LocalizedFormats.OUT_OF_BOUNDS_QUANTILE_VALUE, p, 0, 100); } quantile = p; }
/** * <p>Returns the parameter estimate for the regressor at the given index.</p> * * <p>A redundant regressor will have its redundancy flag set, as well as * a parameters estimated equal to {@code Double.NaN}</p> * * @param index Index. * @return the parameters estimated for regressor at index. * @throws OutOfRangeException if {@code index} is not in the interval * {@code [0, number of parameters)}. */ public double getParameterEstimate(int index) throws OutOfRangeException { if (parameters == null) { return Double.NaN; } if (index < 0 || index >= this.parameters.length) { throw new OutOfRangeException(index, 0, this.parameters.length - 1); } return this.parameters[index]; }
/** {@inheritDoc} */ @Override public double inverseCumulativeProbability(double p) throws OutOfRangeException { if (p < 0.0 || p > 1.0) { throw new OutOfRangeException(p, 0.0, 1.0); } else if (p == 0) { return 0.0; } else if (p == 1) { return Double.POSITIVE_INFINITY; } return s * Math.log(p / (1.0 - p)) + mu; }
/** * Convert to multidimensional counter. * * @param index Index in unidimensional counter. * @return the multidimensional counts. * @throws OutOfRangeException if {@code index} is not between * {@code 0} and the value returned by {@link #getSize()} (excluded). */ public int[] getCounts(int index) throws OutOfRangeException { if (index < 0 || index >= totalSize) { throw new OutOfRangeException(index, 0, totalSize); } final int[] indices = new int[dimension]; int count = 0; for (int i = 0; i < last; i++) { int idx = 0; final int offset = uniCounterOffset[i]; while (count <= index) { count += offset; ++idx; } --idx; count -= offset; indices[i] = idx; } indices[last] = index - count; return indices; }
/** * Create a new genetic algorithm. * @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 GeneticAlgorithm(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; }
/** {@inheritDoc} */ @Override public double inverseCumulativeProbability(double p) throws OutOfRangeException { if (p < 0.0 || p > 1.0) { throw new OutOfRangeException(p, 0.0, 1.0); } else if (p == 0) { return Double.NEGATIVE_INFINITY; } else if (p == 1) { return Double.POSITIVE_INFINITY; } double x = (p > 0.5) ? -Math.log(2.0 - 2.0 * p) : Math.log(2.0 * p); return mu + beta * x; }
/** * {@inheritDoc} */ public double value(double x, double y) { if (x < 0 || x > 1) { throw new OutOfRangeException(x, 0, 1); } if (y < 0 || y > 1) { throw new OutOfRangeException(y, 0, 1); } final double x2 = x * x; final double x3 = x2 * x; final double[] pX = {1, x, x2, x3}; final double y2 = y * y; final double y3 = y2 * y; final double[] pY = {1, y, y2, y3}; return apply(pX, pY, a); }