/** {@inheritDoc} */ @Override public double inverseCumulativeProbability(double p) throws MathException { if (p == 0) { return 0; } else if (p == 1) { return 1; } else { return super.inverseCumulativeProbability(p); } }
double lowerBound = getDomainLowerBound(p); double upperBound = getDomainUpperBound(p); double[] bracket = null; try { bracket = UnivariateRealSolverUtils.bracket( rootFindingFunction, getInitialDomain(p), lowerBound, upperBound); } catch (ConvergenceException ex) { if (Math.abs(rootFindingFunction.value(lowerBound)) < getSolverAbsoluteAccuracy()) { return lowerBound; if (Math.abs(rootFindingFunction.value(upperBound)) < getSolverAbsoluteAccuracy()) { return upperBound; bracket[0],bracket[1], getSolverAbsoluteAccuracy()); return root;
double lowerBound = getDomainLowerBound(p); double upperBound = getDomainUpperBound(p); double[] bracket = null; try { bracket = UnivariateRealSolverUtils.bracket( rootFindingFunction, getInitialDomain(p), lowerBound, upperBound); } catch (ConvergenceException ex) {
public double value(double x) throws FunctionEvaluationException { try { return cumulativeProbability(x) - p; } catch (MathException ex) { throw new FunctionEvaluationException(x, ex.getPattern(), ex.getArguments(), ex); } } };
/** * Generates a random sample from the distribution. The default implementation * generates the sample by calling {@link #sample()} in a loop. * * @param sampleSize number of random values to generate * @since 2.2 * @return an array representing the random sample * @throws MathException if an error occurs generating the sample * @throws IllegalArgumentException if sampleSize is not positive */ public double[] sample(int sampleSize) throws MathException { if (sampleSize <= 0) { MathRuntimeException.createIllegalArgumentException(LocalizedFormats.NOT_POSITIVE_SAMPLE_SIZE, sampleSize); } double[] out = new double[sampleSize]; for (int i = 0; i < sampleSize; i++) { out[i] = sample(); } return out; }
double lowerBound = getDomainLowerBound(p); double upperBound = getDomainUpperBound(p); double[] bracket = null; try { bracket = UnivariateRealSolverUtils.bracket( rootFindingFunction, getInitialDomain(p), lowerBound, upperBound); } catch (ConvergenceException ex) { if (FastMath.abs(rootFindingFunction.value(lowerBound)) < getSolverAbsoluteAccuracy()) { return lowerBound; if (FastMath.abs(rootFindingFunction.value(upperBound)) < getSolverAbsoluteAccuracy()) { return upperBound; bracket[0],bracket[1], getSolverAbsoluteAccuracy()); return root;
public double value(double x) throws FunctionEvaluationException { double ret = Double.NaN; try { ret = cumulativeProbability(x) - p; } catch (MathException ex) { throw new FunctionEvaluationException(ex, x, ex.getPattern(), ex.getArguments()); } if (Double.isNaN(ret)) { throw new FunctionEvaluationException(x, "Cumulative probability function returned NaN for argument {0} p = {1}", x, p); } return ret; } };
/** {@inheritDoc} */ @Override public double inverseCumulativeProbability(double p) throws MathException { if (p == 0) { return 0; } else if (p == 1) { return 1; } else { return super.inverseCumulativeProbability(p); } }
public double value(double x) throws FunctionEvaluationException { double ret = Double.NaN; try { ret = cumulativeProbability(x) - p; } catch (MathException ex) { throw new FunctionEvaluationException(x, ex.getSpecificPattern(), ex.getGeneralPattern(), ex.getArguments()); } if (Double.isNaN(ret)) { throw new FunctionEvaluationException(x, LocalizedFormats.CUMULATIVE_PROBABILITY_RETURNED_NAN, x, p); } return ret; } };
/** * For this distribution, X, this method returns the critical point x, such * that P(X < x) = <code>p</code>. * <p> * Returns 0 for p=0 and <code>Double.POSITIVE_INFINITY</code> for p=1.</p> * * @param p the desired probability * @return x, such that P(X < x) = <code>p</code> * @throws MathException if the inverse cumulative probability can not be * computed due to convergence or other numerical errors. * @throws IllegalArgumentException if <code>p</code> is not a valid * probability. */ @Override public double inverseCumulativeProbability(final double p) throws MathException { if (p == 0) { return 0d; } if (p == 1) { return Double.POSITIVE_INFINITY; } return super.inverseCumulativeProbability(p); }
/** * For this distribution, X, this method returns the critical point x, such * that P(X < x) = <code>p</code>. * <p> * Returns 0 for p=0 and <code>Double.POSITIVE_INFINITY</code> for p=1.</p> * * @param p the desired probability * @return x, such that P(X < x) = <code>p</code> * @throws MathException if the inverse cumulative probability can not be * computed due to convergence or other numerical errors. * @throws IllegalArgumentException if <code>p</code> is not a valid * probability. */ @Override public double inverseCumulativeProbability(final double p) throws MathException { if (p == 0) { return 0d; } if (p == 1) { return Double.POSITIVE_INFINITY; } return super.inverseCumulativeProbability(p); }
/** * For this distribution, X, this method returns the critical point x, such * that P(X < x) = <code>p</code>. * <p> * Returns 0 for p=0 and <code>Double.POSITIVE_INFINITY</code> for p=1.</p> * * @param p the desired probability * @return x, such that P(X < x) = <code>p</code> * @throws MathException if the inverse cumulative probability can not be * computed due to convergence or other numerical errors. * @throws IllegalArgumentException if <code>p</code> is not a valid * probability. */ public double inverseCumulativeProbability(final double p) throws MathException { if (p == 0) { return 0d; } if (p == 1) { return Double.POSITIVE_INFINITY; } return super.inverseCumulativeProbability(p); }
/** * For this distribution, X, this method returns the critical point x, such * that P(X < x) = <code>p</code>. * <p> * Returns <code>Double.NEGATIVE_INFINITY</code> for p=0 and * <code>Double.POSITIVE_INFINITY</code> for p=1.</p> * * @param p the desired probability * @return x, such that P(X < x) = <code>p</code> * @throws MathException if the inverse cumulative probability can not be * computed due to convergence or other numerical errors. * @throws IllegalArgumentException if <code>p</code> is not a valid * probability. */ @Override public double inverseCumulativeProbability(final double p) throws MathException { if (p == 0) { return Double.NEGATIVE_INFINITY; } if (p == 1) { return Double.POSITIVE_INFINITY; } return super.inverseCumulativeProbability(p); }
/** * For this distribution, X, this method returns the critical point x, such * that P(X < x) = <code>p</code>. * <p> * Returns <code>Double.NEGATIVE_INFINITY</code> for p=0 and * <code>Double.POSITIVE_INFINITY</code> for p=1.</p> * * @param p the desired probability * @return x, such that P(X < x) = <code>p</code> * @throws MathException if the inverse cumulative probability can not be * computed due to convergence or other numerical errors. * @throws IllegalArgumentException if <code>p</code> is not a valid * probability. */ @Override public double inverseCumulativeProbability(final double p) throws MathException { if (p == 0) { return Double.NEGATIVE_INFINITY; } if (p == 1) { return Double.POSITIVE_INFINITY; } return super.inverseCumulativeProbability(p); }
/** * For this distribution, X, this method returns the critical point x, such * that P(X < x) = <code>p</code>. * <p> * Returns <code>Double.NEGATIVE_INFINITY</code> for p=0 and * <code>Double.POSITIVE_INFINITY</code> for p=1.</p> * * @param p the desired probability * @return x, such that P(X < x) = <code>p</code> * @throws MathException if the inverse cumulative probability can not be * computed due to convergence or other numerical errors. * @throws IllegalArgumentException if <code>p</code> is not a valid * probability. */ public double inverseCumulativeProbability(final double p) throws MathException { if (p == 0) { return Double.NEGATIVE_INFINITY; } if (p == 1) { return Double.POSITIVE_INFINITY; } return super.inverseCumulativeProbability(p); }
/** * For this distribution, X, this method returns the critical point x, such * that P(X < x) = <code>p</code>. * <p> * Returns 0 for p=0 and <code>Double.POSITIVE_INFINITY</code> for p=1.</p> * * @param p the desired probability * @return x, such that P(X < x) = <code>p</code> * @throws MathException if the inverse cumulative probability can not be * computed due to convergence or other numerical errors. * @throws IllegalArgumentException if <code>p</code> is not a valid * probability. */ @Override public double inverseCumulativeProbability(final double p) throws MathException { if (p == 0) { return 0d; } if (p == 1) { return Double.POSITIVE_INFINITY; } return super.inverseCumulativeProbability(p); }
/** * For this distribution, X, this method returns the critical point x, such * that P(X < x) = <code>p</code>. * <p> * Returns 0 for p=0 and <code>Double.POSITIVE_INFINITY</code> for p=1.</p> * * @param p the desired probability * @return x, such that P(X < x) = <code>p</code> * @throws MathException if the inverse cumulative probability can not be * computed due to convergence or other numerical errors. * @throws IllegalArgumentException if <code>p</code> is not a valid * probability. */ public double inverseCumulativeProbability(final double p) throws MathException { if (p == 0) { return 0d; } if (p == 1) { return Double.POSITIVE_INFINITY; } return super.inverseCumulativeProbability(p); }
/** * For this distribution, X, this method returns the critical point x, such * that P(X < x) = <code>p</code>. * <p> * Returns <code>Double.NEGATIVE_INFINITY</code> for p=0 and * <code>Double.POSITIVE_INFINITY</code> for p=1.</p> * * @param p the desired probability * @return x, such that P(X < x) = <code>p</code> * @throws MathException if the inverse cumulative probability can not be * computed due to convergence or other numerical errors. * @throws IllegalArgumentException if <code>p</code> is not a valid * probability. */ @Override public double inverseCumulativeProbability(final double p) throws MathException { if (p == 0) { return Double.NEGATIVE_INFINITY; } if (p == 1) { return Double.POSITIVE_INFINITY; } return super.inverseCumulativeProbability(p); }
/** * For this distribution, X, this method returns the critical point x, such * that P(X < x) = <code>p</code>. * <p> * Returns 0 for p=0 and <code>Double.POSITIVE_INFINITY</code> for p=1.</p> * * @param p the desired probability * @return x, such that P(X < x) = <code>p</code> * @throws MathException if the inverse cumulative probability can not be * computed due to convergence or other numerical errors. * @throws IllegalArgumentException if <code>p</code> is not a valid * probability. */ @Override public double inverseCumulativeProbability(final double p) throws MathException { if (p == 0) { return 0d; } if (p == 1) { return Double.POSITIVE_INFINITY; } return super.inverseCumulativeProbability(p); }
/** * For this distribution, X, this method returns the critical point x, such * that P(X < x) = <code>p</code>. * <p> * Returns 0 for p=0 and <code>Double.POSITIVE_INFINITY</code> for p=1.</p> * * @param p the desired probability * @return x, such that P(X < x) = <code>p</code> * @throws MathException if the inverse cumulative probability can not be * computed due to convergence or other numerical errors. * @throws IllegalArgumentException if <code>p</code> is not a valid * probability. */ public double inverseCumulativeProbability(final double p) throws MathException { if (p == 0) { return 0d; } if (p == 1) { return Double.POSITIVE_INFINITY; } return super.inverseCumulativeProbability(p); }