Java Code Examples for org.apache.commons.math3.special.Erf#erf()
The following examples show how to use
org.apache.commons.math3.special.Erf#erf() .
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: TruncatedNormalDistribution.java From nd4j with Apache License 2.0 | 5 votes |
/** * {@inheritDoc} * <p/> * If {@code x} is more than 40 standard deviations from the mean, 0 or 1 * is returned, as in these cases the actual value is within * {@code Double.MIN_VALUE} of 0 or 1. */ public double cumulativeProbability(double x) { if (means != null) throw new IllegalStateException("Unable to sample from more than one mean"); final double dev = x - mean; if (FastMath.abs(dev) > 40 * standardDeviation) { return dev < 0 ? 0.0d : 1.0d; } return 0.5 * (1 + Erf.erf(dev / (standardDeviation * SQRT2))); }
Example 2
Source File: LogNormalDistribution.java From nd4j with Apache License 2.0 | 5 votes |
/** * {@inheritDoc} */ @Override public double probability(double x0, double x1) throws NumberIsTooLargeException { if (x0 > x1) { throw new NumberIsTooLargeException(LocalizedFormats.LOWER_ENDPOINT_ABOVE_UPPER_ENDPOINT, x0, x1, true); } final double denom = standardDeviation * SQRT2; final double v0 = (x0 - mean) / denom; final double v1 = (x1 - mean) / denom; return 0.5 * Erf.erf(v0, v1); }
Example 3
Source File: LogNormalDistribution.java From nd4j with Apache License 2.0 | 5 votes |
/** * {@inheritDoc} * <p/> * If {@code x} is more than 40 standard deviations from the mean, 0 or 1 * is returned, as in these cases the actual value is within * {@code Double.MIN_VALUE} of 0 or 1. */ public double cumulativeProbability(double x) { if (means != null) throw new IllegalStateException("Unable to sample from more than one mean"); final double dev = x - mean; if (FastMath.abs(dev) > 40 * standardDeviation) { return dev < 0 ? 0.0d : 1.0d; } return 0.5 * (1 + Erf.erf(dev / (standardDeviation * SQRT2))); }
Example 4
Source File: GaussianLowEnergySampler.java From OSPREY3 with GNU General Public License v2.0 | 5 votes |
private double radialIntegral(double a, int k){ //\int_0^a exp(-r^2/2) r^k dr if(k>1) return (k-1)*radialIntegral(a,k-2) - Math.pow(a,k-1)*Math.exp(-a*a/2); else if(k==1) return 1-Math.exp(-a*a/2); else if(k==0) return Math.sqrt(Math.PI/2) * Erf.erf(a/Math.sqrt(2)); else throw new RuntimeException("ERROR: Negative k not supported here: "+k); }
Example 5
Source File: Cardumen_00215_t.java From coming with MIT License | 5 votes |
/** * {@inheritDoc} * * If {@code x} is more than 40 standard deviations from the mean, 0 or 1 * is returned, as in these cases the actual value is within * {@code Double.MIN_VALUE} of 0 or 1. */ public double cumulativeProbability(double x) { final double dev = x - mean; if ((java.lang.Double.isNaN(SQRT2PI)) || (java.lang.Double.isNaN(dev))) { return dev < 0 ? 0.0d : 1.0d; } return 0.5 * (1 + Erf.erf(dev / (standardDeviation * SQRT2))); }
Example 6
Source File: NormalDistribution.java From astor with GNU General Public License v2.0 | 5 votes |
/** {@inheritDoc} */ @Override public double probability(double x0, double x1) throws NumberIsTooLargeException { if (x0 > x1) { throw new NumberIsTooLargeException(LocalizedFormats.LOWER_ENDPOINT_ABOVE_UPPER_ENDPOINT, x0, x1, true); } final double denom = standardDeviation * SQRT2; final double v0 = (x0 - mean) / denom; final double v1 = (x1 - mean) / denom; return 0.5 * Erf.erf(v0, v1); }
Example 7
Source File: NormalDistribution.java From nd4j with Apache License 2.0 | 5 votes |
/** * {@inheritDoc} */ @Override public double probability(double x0, double x1) throws NumberIsTooLargeException { if (x0 > x1) { throw new NumberIsTooLargeException(LocalizedFormats.LOWER_ENDPOINT_ABOVE_UPPER_ENDPOINT, x0, x1, true); } final double denom = standardDeviation * SQRT2; final double v0 = (x0 - mean) / denom; final double v1 = (x1 - mean) / denom; return 0.5 * Erf.erf(v0, v1); }
Example 8
Source File: Cardumen_00109_s.java From coming with MIT License | 5 votes |
/** * {@inheritDoc} * * If {@code x} is more than 40 standard deviations from the mean, 0 or 1 * is returned, as in these cases the actual value is within * {@code Double.MIN_VALUE} of 0 or 1. */ public double cumulativeProbability(double x) { final double dev = x - mean; if (FastMath.abs(dev) > 40 * standardDeviation) { return dev < 0 ? 0.0d : 1.0d; } return 0.5 * (1 + Erf.erf(dev / (standardDeviation * SQRT2))); }
Example 9
Source File: NormalDistribution.java From astor with GNU General Public License v2.0 | 5 votes |
/** {@inheritDoc} */ @Override public double cumulativeProbability(double x0, double x1) throws NumberIsTooLargeException { if (x0 > x1) { throw new NumberIsTooLargeException(LocalizedFormats.LOWER_ENDPOINT_ABOVE_UPPER_ENDPOINT, x0, x1, true); } final double denom = standardDeviation * SQRT2; final double v0 = (x0 - mean) / denom; final double v1 = (x1 - mean) / denom; return 0.5 * Erf.erf(v0, v1); }
Example 10
Source File: MathFunctions.java From presto with Apache License 2.0 | 5 votes |
@Description("Normal cdf given a mean, standard deviation, and value") @ScalarFunction @SqlType(StandardTypes.DOUBLE) public static double normalCdf( @SqlType(StandardTypes.DOUBLE) double mean, @SqlType(StandardTypes.DOUBLE) double standardDeviation, @SqlType(StandardTypes.DOUBLE) double value) { checkCondition(standardDeviation > 0, INVALID_FUNCTION_ARGUMENT, "standardDeviation must be > 0"); return 0.5 * (1 + Erf.erf((value - mean) / (standardDeviation * Math.sqrt(2)))); }
Example 11
Source File: Cardumen_00259_t.java From coming with MIT License | 5 votes |
/** {@inheritDoc} */ @Override public double cumulativeProbability(double x0, double x1) throws NumberIsTooLargeException { if (x0 > x1) { throw new NumberIsTooLargeException(LocalizedFormats.LOWER_ENDPOINT_ABOVE_UPPER_ENDPOINT, x0, x1, true); } final double denom = standardDeviation * SQRT2; final double v0 = (x0 - mean) / denom; final double v1 = (x1 - mean) / denom; return 0.5 * Erf.erf(v0, v1); }
Example 12
Source File: NormalDistribution.java From astor with GNU General Public License v2.0 | 5 votes |
/** {@inheritDoc} */ @Override public double cumulativeProbability(double x0, double x1) throws NumberIsTooLargeException { if (x0 > x1) { throw new NumberIsTooLargeException(LocalizedFormats.LOWER_ENDPOINT_ABOVE_UPPER_ENDPOINT, x0, x1, true); } final double denom = standardDeviation * SQRT2; final double v0 = (x0 - mean) / denom; final double v1 = (x1 - mean) / denom; return 0.5 * Erf.erf(v0, v1); }
Example 13
Source File: NormalDistribution.java From deeplearning4j with Apache License 2.0 | 5 votes |
/** * {@inheritDoc} */ @Override public double probability(double x0, double x1) throws NumberIsTooLargeException { if (x0 > x1) { throw new NumberIsTooLargeException(LocalizedFormats.LOWER_ENDPOINT_ABOVE_UPPER_ENDPOINT, x0, x1, true); } final double denom = standardDeviation * SQRT2; final double v0 = (x0 - mean) / denom; final double v1 = (x1 - mean) / denom; return 0.5 * Erf.erf(v0, v1); }
Example 14
Source File: Cardumen_00165_t.java From coming with MIT License | 5 votes |
/** {@inheritDoc} */ @Override public double cumulativeProbability(double x0, double x1) throws NumberIsTooLargeException { if (x0 > x1) { throw new NumberIsTooLargeException(LocalizedFormats.LOWER_ENDPOINT_ABOVE_UPPER_ENDPOINT, x0, x1, true); } final double denom = standardDeviation * SQRT2; final double v0 = (x0 - mean) / denom; final double v1 = (x1 - mean) / denom; return 0.5 * Erf.erf(v0, v1); }
Example 15
Source File: Cardumen_00259_s.java From coming with MIT License | 5 votes |
/** {@inheritDoc} */ @Override public double cumulativeProbability(double x0, double x1) throws NumberIsTooLargeException { if (x0 > x1) { throw new NumberIsTooLargeException(LocalizedFormats.LOWER_ENDPOINT_ABOVE_UPPER_ENDPOINT, x0, x1, true); } final double denom = standardDeviation * SQRT2; final double v0 = (x0 - mean) / denom; final double v1 = (x1 - mean) / denom; return 0.5 * Erf.erf(v0, v1); }
Example 16
Source File: NormalDistribution.java From astor with GNU General Public License v2.0 | 5 votes |
/** {@inheritDoc} */ @Override public double probability(double x0, double x1) throws NumberIsTooLargeException { if (x0 > x1) { throw new NumberIsTooLargeException(LocalizedFormats.LOWER_ENDPOINT_ABOVE_UPPER_ENDPOINT, x0, x1, true); } final double denom = standardDeviation * SQRT2; final double v0 = (x0 - mean) / denom; final double v1 = (x1 - mean) / denom; return 0.5 * Erf.erf(v0, v1); }
Example 17
Source File: NormalDistribution.java From astor with GNU General Public License v2.0 | 5 votes |
/** {@inheritDoc} */ @Override public double probability(double x0, double x1) throws NumberIsTooLargeException { if (x0 > x1) { throw new NumberIsTooLargeException(LocalizedFormats.LOWER_ENDPOINT_ABOVE_UPPER_ENDPOINT, x0, x1, true); } final double denom = standardDeviation * SQRT2; final double v0 = (x0 - mean) / denom; final double v1 = (x1 - mean) / denom; return 0.5 * Erf.erf(v0, v1); }
Example 18
Source File: NormalDistribution.java From astor with GNU General Public License v2.0 | 5 votes |
/** * {@inheritDoc} * * If {@code x} is more than 40 standard deviations from the mean, 0 or 1 * is returned, as in these cases the actual value is within * {@code Double.MIN_VALUE} of 0 or 1. */ public double cumulativeProbability(double x) { final double dev = x - mean; if (FastMath.abs(dev) > 40 * standardDeviation) { return dev < 0 ? 0.0d : 1.0d; } return 0.5 * (1 + Erf.erf(dev / (standardDeviation * SQRT2))); }
Example 19
Source File: LogNormalDistribution.java From astor with GNU General Public License v2.0 | 3 votes |
/** * {@inheritDoc} * * For scale {@code m}, and shape {@code s} of this distribution, the CDF * is given by * <ul> * <li>{@code 0} if {@code x <= 0},</li> * <li>{@code 0} if {@code ln(x) - m < 0} and {@code m - ln(x) > 40 * s}, as * in these cases the actual value is within {@code Double.MIN_VALUE} of 0, * <li>{@code 1} if {@code ln(x) - m >= 0} and {@code ln(x) - m > 40 * s}, * as in these cases the actual value is within {@code Double.MIN_VALUE} of * 1,</li> * <li>{@code 0.5 + 0.5 * erf((ln(x) - m) / (s * sqrt(2))} otherwise.</li> * </ul> */ public double cumulativeProbability(double x) { if (x <= 0) { return 0; } final double dev = FastMath.log(x) - scale; if (FastMath.abs(dev) > 40 * shape) { return dev < 0 ? 0.0d : 1.0d; } return 0.5 + 0.5 * Erf.erf(dev / (shape * SQRT2)); }
Example 20
Source File: LogNormalDistribution.java From astor with GNU General Public License v2.0 | 3 votes |
/** * {@inheritDoc} * * For scale {@code m}, and shape {@code s} of this distribution, the CDF * is given by * <ul> * <li>{@code 0} if {@code x <= 0},</li> * <li>{@code 0} if {@code ln(x) - m < 0} and {@code m - ln(x) > 40 * s}, as * in these cases the actual value is within {@code Double.MIN_VALUE} of 0, * <li>{@code 1} if {@code ln(x) - m >= 0} and {@code ln(x) - m > 40 * s}, * as in these cases the actual value is within {@code Double.MIN_VALUE} of * 1,</li> * <li>{@code 0.5 + 0.5 * erf((ln(x) - m) / (s * sqrt(2))} otherwise.</li> * </ul> */ public double cumulativeProbability(double x) { if (x <= 0) { return 0; } final double dev = FastMath.log(x) - scale; if (FastMath.abs(dev) > 40 * shape) { return dev < 0 ? 0.0d : 1.0d; } return 0.5 + 0.5 * Erf.erf(dev / (shape * SQRT2)); }