Java Code Examples for org.apache.commons.math3.special.Erf#erfInv()

The following examples show how to use org.apache.commons.math3.special.Erf#erfInv() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MathFunctions.java    From presto with Apache License 2.0 5 votes vote down vote up
@Description("Inverse of normal cdf given a mean, std, and probability")
@ScalarFunction
@SqlType(StandardTypes.DOUBLE)
public static double inverseNormalCdf(@SqlType(StandardTypes.DOUBLE) double mean, @SqlType(StandardTypes.DOUBLE) double sd, @SqlType(StandardTypes.DOUBLE) double p)
{
    checkCondition(p > 0 && p < 1, INVALID_FUNCTION_ARGUMENT, "p must be 0 > p > 1");
    checkCondition(sd > 0, INVALID_FUNCTION_ARGUMENT, "sd must be > 0");

    return mean + sd * 1.4142135623730951 * Erf.erfInv(2 * p - 1);
}
 
Example 2
Source File: NormalDistribution.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/** {@inheritDoc}
 * @since 3.2
 */
@Override
public double inverseCumulativeProbability(final double p) throws OutOfRangeException {
    if (p < 0.0 || p > 1.0) {
        throw new OutOfRangeException(p, 0, 1);
    }
    return mean + standardDeviation * SQRT2 * Erf.erfInv(2 * p - 1);
}
 
Example 3
Source File: NormalDistribution.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/** {@inheritDoc}
 * @since 3.2
 */
@Override
public double inverseCumulativeProbability(final double p) throws OutOfRangeException {
    if (p < 0.0 || p > 1.0) {
        throw new OutOfRangeException(p, 0, 1);
    }
    return mean + standardDeviation * SQRT2 * Erf.erfInv(2 * p - 1);
}
 
Example 4
Source File: NormalDistribution.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override
public double inverseCumulativeProbability(final double p) throws OutOfRangeException {
    if (p < 0.0 || p > 1.0) {
        throw new OutOfRangeException(p, 0, 1);
    }
    return mean + standardDeviation * SQRT2 * Erf.erfInv(2 * p - 1);
}
 
Example 5
Source File: NormalDistribution.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/** {@inheritDoc}
 * @since 3.2
 */
@Override
public double inverseCumulativeProbability(final double p) throws OutOfRangeException {
    if (p < 0.0 || p > 1.0) {
        throw new OutOfRangeException(p, 0, 1);
    }
    return mean + standardDeviation * SQRT2 * Erf.erfInv(2 * p - 1);
}
 
Example 6
Source File: NormalDistribution.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/** {@inheritDoc}
 * @since 3.2
 */
@Override
public double inverseCumulativeProbability(final double p) throws OutOfRangeException {
    if (p < 0.0 || p > 1.0) {
        throw new OutOfRangeException(p, 0, 1);
    }
    return mean + standardDeviation * SQRT2 * Erf.erfInv(2 * p - 1);
}
 
Example 7
Source File: LogNormalDistribution.java    From nd4j with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 *
 * @since 3.2
 */
@Override
public double inverseCumulativeProbability(final double p) throws OutOfRangeException {
    if (p < 0.0 || p > 1.0) {
        throw new OutOfRangeException(p, 0, 1);
    }
    if (means != null)
        throw new IllegalStateException("Unable to sample from more than one mean");

    return mean + standardDeviation * SQRT2 * Erf.erfInv(2 * p - 1);
}
 
Example 8
Source File: TruncatedNormalDistribution.java    From nd4j with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 *
 * @since 3.2
 */
@Override
public double inverseCumulativeProbability(final double p) throws OutOfRangeException {
    if (p < 0.0 || p > 1.0) {
        throw new OutOfRangeException(p, 0, 1);
    }
    if (means != null)
        throw new IllegalStateException("Unable to sample from more than one mean");

    return mean + standardDeviation * SQRT2 * Erf.erfInv(2 * p - 1);
}
 
Example 9
Source File: NormalDistribution.java    From nd4j with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 *
 * @since 3.2
 */
@Override
public double inverseCumulativeProbability(final double p) throws OutOfRangeException {
    if (p < 0.0 || p > 1.0) {
        throw new OutOfRangeException(p, 0, 1);
    }
    if (means != null)
        throw new IllegalStateException("Unable to sample from more than one mean");

    return mean + standardDeviation * SQRT2 * Erf.erfInv(2 * p - 1);
}
 
Example 10
Source File: LogNormalDistribution.java    From deeplearning4j with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 *
 * @since 3.2
 */
@Override
public double inverseCumulativeProbability(final double p) throws OutOfRangeException {
    if (p < 0.0 || p > 1.0) {
        throw new OutOfRangeException(p, 0, 1);
    }
    if (means != null)
        throw new IllegalStateException("Unable to sample from more than one mean");

    return mean + standardDeviation * SQRT2 * Erf.erfInv(2 * p - 1);
}
 
Example 11
Source File: TruncatedNormalDistribution.java    From deeplearning4j with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 *
 * @since 3.2
 */
@Override
public double inverseCumulativeProbability(final double p) throws OutOfRangeException {
    if (p < 0.0 || p > 1.0) {
        throw new OutOfRangeException(p, 0, 1);
    }
    if (means != null)
        throw new IllegalStateException("Unable to sample from more than one mean");

    return mean + standardDeviation * SQRT2 * Erf.erfInv(2 * p - 1);
}
 
Example 12
Source File: NormalDistribution.java    From deeplearning4j with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 *
 * @since 3.2
 */
@Override
public double inverseCumulativeProbability(final double p) throws OutOfRangeException {
    if (p < 0.0 || p > 1.0) {
        throw new OutOfRangeException(p, 0, 1);
    }
    if (means != null)
        throw new IllegalStateException("Unable to sample from more than one mean");

    return mean + standardDeviation * SQRT2 * Erf.erfInv(2 * p - 1);
}