This commit is contained in:
Gilles 2015-12-31 01:35:30 +01:00
commit 2fcfce3039
5 changed files with 15 additions and 16 deletions

View File

@ -113,7 +113,7 @@ public class LaguerreSolver extends AbstractPolynomialSolver {
// Reduce interval if min and initial bracket the root. // Reduce interval if min and initial bracket the root.
if (yInitial * yMin < 0) { if (yInitial * yMin < 0) {
return laguerre(min, initial, yMin, yInitial); return laguerre(min, initial);
} }
// Return the second endpoint if it is good enough. // Return the second endpoint if it is good enough.
@ -124,7 +124,7 @@ public class LaguerreSolver extends AbstractPolynomialSolver {
// Reduce interval if initial and max bracket the root. // Reduce interval if initial and max bracket the root.
if (yInitial * yMax < 0) { if (yInitial * yMax < 0) {
return laguerre(initial, max, yInitial, yMax); return laguerre(initial, max);
} }
throw new NoBracketingException(min, max, yMin, yMax); throw new NoBracketingException(min, max, yMin, yMax);
@ -144,12 +144,9 @@ public class LaguerreSolver extends AbstractPolynomialSolver {
* *
* @param lo Lower bound of the search interval. * @param lo Lower bound of the search interval.
* @param hi Higher bound of the search interval. * @param hi Higher bound of the search interval.
* @param fLo Function value at the lower bound of the search interval.
* @param fHi Function value at the higher bound of the search interval.
* @return the point at which the function value is zero. * @return the point at which the function value is zero.
*/ */
private double laguerre(double lo, double hi, private double laguerre(double lo, double hi) {
double fLo, double fHi) {
final Complex c[] = ComplexUtils.convertToComplex(getCoefficients()); final Complex c[] = ComplexUtils.convertToComplex(getCoefficients());
final Complex initial = new Complex(0.5 * (lo + hi), 0); final Complex initial = new Complex(0.5 * (lo + hi), 0);

View File

@ -556,14 +556,16 @@ public class CMAESOptimizer
* Checks dimensions and values of boundaries and inputSigma if defined. * Checks dimensions and values of boundaries and inputSigma if defined.
*/ */
private void checkParameters() { private void checkParameters() {
final double[] init = getStartPoint();
final double[] lB = getLowerBound();
final double[] uB = getUpperBound();
if (inputSigma != null) { if (inputSigma != null) {
final double[] init = getStartPoint();
if (inputSigma.length != init.length) { if (inputSigma.length != init.length) {
throw new DimensionMismatchException(inputSigma.length, init.length); throw new DimensionMismatchException(inputSigma.length, init.length);
} }
final double[] lB = getLowerBound();
final double[] uB = getUpperBound();
for (int i = 0; i < init.length; i++) { for (int i = 0; i < init.length; i++) {
if (inputSigma[i] > uB[i] - lB[i]) { if (inputSigma[i] > uB[i] - lB[i]) {
throw new OutOfRangeException(inputSigma[i], 0, uB[i] - lB[i]); throw new OutOfRangeException(inputSigma[i], 0, uB[i] - lB[i]);

View File

@ -159,7 +159,7 @@ public class PSquarePercentile extends AbstractStorelessUnivariateStatistic
boolean result = false; boolean result = false;
if (this == o) { if (this == o) {
result = true; result = true;
} else if (o != null && o instanceof PSquarePercentile) { } else if (o instanceof PSquarePercentile) {
PSquarePercentile that = (PSquarePercentile) o; PSquarePercentile that = (PSquarePercentile) o;
boolean isNotNull = markers != null && that.markers != null; boolean isNotNull = markers != null && that.markers != null;
boolean isNull = markers == null && that.markers == null; boolean isNull = markers == null && that.markers == null;
@ -410,7 +410,7 @@ public class PSquarePercentile extends AbstractStorelessUnivariateStatistic
boolean result = false; boolean result = false;
if (this == o) { if (this == o) {
result = true; result = true;
} else if (o != null && o instanceof Markers) { } else if (o instanceof Markers) {
Markers that = (Markers) o; Markers that = (Markers) o;
result = Arrays.deepEquals(markerArray, that.markerArray); result = Arrays.deepEquals(markerArray, that.markerArray);
} }
@ -802,7 +802,7 @@ public class PSquarePercentile extends AbstractStorelessUnivariateStatistic
boolean result = false; boolean result = false;
if (this == o) { if (this == o) {
result = true; result = true;
} else if (o != null && o instanceof Marker) { } else if (o instanceof Marker) {
Marker that = (Marker) o; Marker that = (Marker) o;
result = Double.compare(markerHeight, that.markerHeight) == 0; result = Double.compare(markerHeight, that.markerHeight) == 0;

View File

@ -39,16 +39,16 @@ public class ClopperPearsonInterval implements BinomialConfidenceInterval {
final FDistribution distributionLowerBound = new FDistribution(2 * (numberOfTrials - numberOfSuccesses + 1), final FDistribution distributionLowerBound = new FDistribution(2 * (numberOfTrials - numberOfSuccesses + 1),
2 * numberOfSuccesses); 2 * numberOfSuccesses);
final double fValueLowerBound = distributionLowerBound.inverseCumulativeProbability(1 - alpha);
if (numberOfSuccesses > 0) { if (numberOfSuccesses > 0) {
final double fValueLowerBound = distributionLowerBound.inverseCumulativeProbability(1 - alpha);
lowerBound = numberOfSuccesses / lowerBound = numberOfSuccesses /
(numberOfSuccesses + (numberOfTrials - numberOfSuccesses + 1) * fValueLowerBound); (numberOfSuccesses + (numberOfTrials - numberOfSuccesses + 1) * fValueLowerBound);
} }
final FDistribution distributionUpperBound = new FDistribution(2 * (numberOfSuccesses + 1), final FDistribution distributionUpperBound = new FDistribution(2 * (numberOfSuccesses + 1),
2 * (numberOfTrials - numberOfSuccesses)); 2 * (numberOfTrials - numberOfSuccesses));
final double fValueUpperBound = distributionUpperBound.inverseCumulativeProbability(1 - alpha);
if (numberOfSuccesses > 0) { if (numberOfSuccesses > 0) {
final double fValueUpperBound = distributionUpperBound.inverseCumulativeProbability(1 - alpha);
upperBound = (numberOfSuccesses + 1) * fValueUpperBound / upperBound = (numberOfSuccesses + 1) * fValueUpperBound /
(numberOfTrials - numberOfSuccesses + (numberOfSuccesses + 1) * fValueUpperBound); (numberOfTrials - numberOfSuccesses + (numberOfSuccesses + 1) * fValueUpperBound);
} }

View File

@ -650,7 +650,7 @@ public final class ArithmeticUtils {
*/ */
private static long addAndCheck(long a, long b, Localizable pattern) throws MathArithmeticException { private static long addAndCheck(long a, long b, Localizable pattern) throws MathArithmeticException {
final long result = a + b; final long result = a + b;
if (!((a ^ b) < 0 | (a ^ result) >= 0)) { if (!((a ^ b) < 0 || (a ^ result) >= 0)) {
throw new MathArithmeticException(pattern, a, b); throw new MathArithmeticException(pattern, a, b);
} }
return result; return result;