Java Code Examples for org.apache.commons.math.special.Erf#erf()
The following examples show how to use
org.apache.commons.math.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: Math_60_NormalDistributionImpl_s.java From coming with MIT License | 6 votes |
/** * For this distribution, {@code X}, this method returns {@code P(X < x)}. * 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. * * @param x Value at which the CDF is evaluated. * @return CDF evaluated at {@code x}. * @throws MathException if the algorithm fails to converge */ public double cumulativeProbability(double x) throws MathException { final double dev = x - mean; try { return 0.5 * (1.0 + Erf.erf((dev) / (standardDeviation * FastMath.sqrt(2.0)))); } catch (MaxIterationsExceededException ex) { if (x < (mean - 20 * standardDeviation)) { // JDK 1.5 blows at 38 return 0; } else if (x > (mean + 20 * standardDeviation)) { return 1; } else { throw ex; } } }
Example 2
Source File: ReflectivityCalculator.java From ice with Eclipse Public License 1.0 | 6 votes |
/** * This operation performs the tile updates needed by the generateTile() * operation. * * @param tile * the tile to update * @param slabM1 * the slab one index less than (so above) the middle slab * @param slab * the middle slab * @param slabP1 * the slab one index greater than (so below) the middle slab * @param dist * the step distance * @throws MathException * Thrown if the error function cannot be evaluated */ private void updateTileByLayer(Tile updateSlab, Slab slabM1, Slab slab, Slab slabP1, double dist) throws MathException { // Compute the exponentials double tExpFac = Erf.erf(cE * dist / slab.interfaceWidth); double bExpFac = Erf.erf(cE * (dist - slab.thickness) / (slabP1.interfaceWidth)); // Update the slab properties updateSlab.scatteringLength = getTileValue(slabM1.scatteringLength, slab.scatteringLength, slabP1.scatteringLength, tExpFac, bExpFac); updateSlab.trueAbsLength = getTileValue(slabM1.trueAbsLength, slab.trueAbsLength, slabP1.trueAbsLength, tExpFac, bExpFac); updateSlab.incAbsLength = getTileValue(slabM1.incAbsLength, slab.incAbsLength, slabP1.incAbsLength, tExpFac, bExpFac); return; }
Example 3
Source File: NormalDistributionImpl.java From astor with GNU General Public License v2.0 | 5 votes |
/** * For this distribution, X, this method returns P(X < <code>x</code>). * @param x the value at which the CDF is evaluated. * @return CDF evaluted at <code>x</code>. * @throws MathException if the algorithm fails to converge; unless * x is more than 20 standard deviations from the mean, in which case the * convergence exception is caught and 0 or 1 is returned. */ public double cumulativeProbability(double x) throws MathException { try { return 0.5 * (1.0 + Erf.erf((x - mean) / (standardDeviation * Math.sqrt(2.0)))); } catch (MaxIterationsExceededException ex) { if (x < (mean - 20 * standardDeviation)) { // JDK 1.5 blows at 38 return 0.0d; } else if (x > (mean + 20 * standardDeviation)) { return 1.0d; } else { throw ex; } } }
Example 4
Source File: NormalDistributionImpl.java From cacheonix-core with GNU Lesser General Public License v2.1 | 5 votes |
/** * For this disbution, X, this method returns P(X < <code>x</code>). * @param x the value at which the CDF is evaluated. * @return CDF evaluted at <code>x</code>. * @throws MathException if the algorithm fails to converge; unless * x is more than 20 standard deviations from the mean, in which case the * convergence exception is caught and 0 or 1 is returned. */ public double cumulativeProbability(double x) throws MathException { try { return 0.5 * (1.0 + Erf.erf((x - mean) / (standardDeviation * Math.sqrt(2.0)))); } catch (MaxIterationsExceededException ex) { if (x < (mean - 20 * standardDeviation)) { // JDK 1.5 blows at 38 return 0.0d; } else if (x > (mean + 20 * standardDeviation)) { return 1.0d; } else { throw ex; } } }
Example 5
Source File: NormalDistributionImpl.java From astor with GNU General Public License v2.0 | 5 votes |
/** * For this distribution, X, this method returns P(X < <code>x</code>). * @param x the value at which the CDF is evaluated. * @return CDF evaluted at <code>x</code>. * @throws MathException if the algorithm fails to converge; unless * x is more than 20 standard deviations from the mean, in which case the * convergence exception is caught and 0 or 1 is returned. */ public double cumulativeProbability(double x) throws MathException { try { return 0.5 * (1.0 + Erf.erf((x - mean) / (standardDeviation * Math.sqrt(2.0)))); } catch (MaxIterationsExceededException ex) { if (x < (mean - 20 * standardDeviation)) { // JDK 1.5 blows at 38 return 0.0d; } else if (x > (mean + 20 * standardDeviation)) { return 1.0d; } else { throw ex; } } }
Example 6
Source File: NormalDistributionImpl.java From astor with GNU General Public License v2.0 | 5 votes |
/** * For this distribution, X, this method returns P(X < <code>x</code>). * @param x the value at which the CDF is evaluated. * @return CDF evaluted at <code>x</code>. * @throws MathException if the algorithm fails to converge; unless * x is more than 20 standard deviations from the mean, in which case the * convergence exception is caught and 0 or 1 is returned. */ public double cumulativeProbability(double x) throws MathException { try { return 0.5 * (1.0 + Erf.erf((x - mean) / (standardDeviation * Math.sqrt(2.0)))); } catch (MaxIterationsExceededException ex) { if (x < (mean - 20 * standardDeviation)) { // JDK 1.5 blows at 38 return 0.0d; } else if (x > (mean + 20 * standardDeviation)) { return 1.0d; } else { throw ex; } } }
Example 7
Source File: NormalDistributionImpl.java From astor with GNU General Public License v2.0 | 5 votes |
/** * For this distribution, X, this method returns P(X < <code>x</code>). * @param x the value at which the CDF is evaluated. * @return CDF evaluted at <code>x</code>. * @throws MathException if the algorithm fails to converge; unless * x is more than 20 standard deviations from the mean, in which case the * convergence exception is caught and 0 or 1 is returned. */ public double cumulativeProbability(double x) throws MathException { try { return 0.5 * (1.0 + Erf.erf((x - mean) / (standardDeviation * Math.sqrt(2.0)))); } catch (MaxIterationsExceededException ex) { if (x < (mean - 20 * standardDeviation)) { // JDK 1.5 blows at 38 return 0.0d; } else if (x > (mean + 20 * standardDeviation)) { return 1.0d; } else { throw ex; } } }
Example 8
Source File: NormalDistributionImpl.java From astor with GNU General Public License v2.0 | 5 votes |
/** * For this distribution, X, this method returns P(X < <code>x</code>). * @param x the value at which the CDF is evaluated. * @return CDF evaluted at <code>x</code>. * @throws MathException if the algorithm fails to converge; unless * x is more than 20 standard deviations from the mean, in which case the * convergence exception is caught and 0 or 1 is returned. */ public double cumulativeProbability(double x) throws MathException { try { return 0.5 * (1.0 + Erf.erf((x - mean) / (standardDeviation * Math.sqrt(2.0)))); } catch (MaxIterationsExceededException ex) { if (x < (mean - 20 * standardDeviation)) { // JDK 1.5 blows at 38 return 0.0d; } else if (x > (mean + 20 * standardDeviation)) { return 1.0d; } else { throw ex; } } }
Example 9
Source File: NormalDistributionImpl.java From astor with GNU General Public License v2.0 | 5 votes |
/** * For this distribution, X, this method returns P(X < <code>x</code>). * @param x the value at which the CDF is evaluated. * @return CDF evaluted at <code>x</code>. * @throws MathException if the algorithm fails to converge; unless * x is more than 20 standard deviations from the mean, in which case the * convergence exception is caught and 0 or 1 is returned. */ public double cumulativeProbability(double x) throws MathException { try { return 0.5 * (1.0 + Erf.erf((x - mean) / (standardDeviation * Math.sqrt(2.0)))); } catch (MaxIterationsExceededException ex) { if (x < (mean - 20 * standardDeviation)) { // JDK 1.5 blows at 38 return 0.0d; } else if (x > (mean + 20 * standardDeviation)) { return 1.0d; } else { throw ex; } } }
Example 10
Source File: NormalDistributionImpl.java From astor with GNU General Public License v2.0 | 5 votes |
/** * For this distribution, X, this method returns P(X < <code>x</code>). * @param x the value at which the CDF is evaluated. * @return CDF evaluted at <code>x</code>. * @throws MathException if the algorithm fails to converge; unless * x is more than 20 standard deviations from the mean, in which case the * convergence exception is caught and 0 or 1 is returned. */ public double cumulativeProbability(double x) throws MathException { try { return 0.5 * (1.0 + Erf.erf((x - mean) / (standardDeviation * Math.sqrt(2.0)))); } catch (MaxIterationsExceededException ex) { if (x < (mean - 20 * standardDeviation)) { // JDK 1.5 blows at 38 return 0.0d; } else if (x > (mean + 20 * standardDeviation)) { return 1.0d; } else { throw ex; } } }
Example 11
Source File: NormalDistributionImpl.java From astor with GNU General Public License v2.0 | 5 votes |
/** * For this distribution, X, this method returns P(X < <code>x</code>). * @param x the value at which the CDF is evaluated. * @return CDF evaluted at <code>x</code>. * @throws MathException if the algorithm fails to converge; unless * x is more than 20 standard deviations from the mean, in which case the * convergence exception is caught and 0 or 1 is returned. */ public double cumulativeProbability(double x) throws MathException { try { return 0.5 * (1.0 + Erf.erf((x - mean) / (standardDeviation * Math.sqrt(2.0)))); } catch (MaxIterationsExceededException ex) { if (x < (mean - 20 * standardDeviation)) { // JDK 1.5 blows at 38 return 0.0d; } else if (x > (mean + 20 * standardDeviation)) { return 1.0d; } else { throw ex; } } }
Example 12
Source File: NormalDistributionImpl.java From astor with GNU General Public License v2.0 | 5 votes |
/** * For this distribution, X, this method returns P(X < <code>x</code>). * @param x the value at which the CDF is evaluated. * @return CDF evaluted at <code>x</code>. * @throws MathException if the algorithm fails to converge; unless * x is more than 20 standard deviations from the mean, in which case the * convergence exception is caught and 0 or 1 is returned. */ public double cumulativeProbability(double x) throws MathException { try { return 0.5 * (1.0 + Erf.erf((x - mean) / (standardDeviation * Math.sqrt(2.0)))); } catch (MaxIterationsExceededException ex) { if (x < (mean - 20 * standardDeviation)) { // JDK 1.5 blows at 38 return 0.0d; } else if (x > (mean + 20 * standardDeviation)) { return 1.0d; } else { throw ex; } } }
Example 13
Source File: NormalDistributionImpl.java From astor with GNU General Public License v2.0 | 5 votes |
/** * For this distribution, X, this method returns P(X < <code>x</code>). * @param x the value at which the CDF is evaluated. * @return CDF evaluted at <code>x</code>. * @throws MathException if the algorithm fails to converge; unless * x is more than 20 standard deviations from the mean, in which case the * convergence exception is caught and 0 or 1 is returned. */ public double cumulativeProbability(double x) throws MathException { try { return 0.5 * (1.0 + Erf.erf((x - mean) / (standardDeviation * Math.sqrt(2.0)))); } catch (MaxIterationsExceededException ex) { if (x < (mean - 20 * standardDeviation)) { // JDK 1.5 blows at 38 return 0.0d; } else if (x > (mean + 20 * standardDeviation)) { return 1.0d; } else { throw ex; } } }
Example 14
Source File: Math_103_NormalDistributionImpl_t.java From coming with MIT License | 5 votes |
/** * For this disbution, X, this method returns P(X < <code>x</code>). * @param x the value at which the CDF is evaluated. * @return CDF evaluted at <code>x</code>. * @throws MathException if the algorithm fails to converge; unless * x is more than 20 standard deviations from the mean, in which case the * convergence exception is caught and 0 or 1 is returned. */ public double cumulativeProbability(double x) throws MathException { try { return 0.5 * (1.0 + Erf.erf((x - mean) / (standardDeviation * Math.sqrt(2.0)))); } catch (MaxIterationsExceededException ex) { if (x < (mean - 20 * standardDeviation)) { // JDK 1.5 blows at 38 return 0.0d; } else if (x > (mean + 20 * standardDeviation)) { return 1.0d; } else { throw ex; } } }
Example 15
Source File: ReflectivityCalculator.java From ice with Eclipse Public License 1.0 | 4 votes |
/** * This operation generates the interfacial profile using an error function * of numRough ordinate steps based on those of the hyperbolic tangent. * * @param numRough * the number of ordinate steps * @param zInt * FIXME! This array must be preallocated with a size n = * maxRoughSize. * @param rufInt * FIXME! This array must be preallocated with a size n = * maxRoughSize. * @throws MathException * Thrown if the error function cannot be calculated */ public void getInterfacialProfile(int numRough, double[] zInt, double[] rufInt) throws MathException { // cE ensures Gaussian = 0.5 when z = zhwhm final double cE = 1.665; double dist = 0.0, step = 0.0, oHalfstep = 0.0, zTemp = 0.0; int j; // Check nRough to make sure it is legitimate if (numRough < 1) { numRough = 1; } // Set the step size step = 2.0 / (numRough + 1); // Evaluate the lower half of the interface dist = -step / 2.0; // Steps calculated from inverse tanh. Note that all of the indices are // shifted by -1 from the VB code because this version is zero indexed! zInt[numRough / 2] = Math.log((1.0 + dist) / (1.0 - dist)) / (2.0 * cE); rufInt[numRough / 2] = Erf.erf(cE * zInt[numRough / 2]); for (j = numRough / 2 - 1; j >= 0; j--) { dist = dist - step; zInt[j] = Math.log((1.0 + dist) / (1.0 - dist)) / (2.0 * cE); rufInt[j] = Erf.erf(cE * zInt[j]); } // Evaluate the upper half of the interface dist = step / 2.0; // Steps calculated from inverse tanh. Note that all of the indices are // shifted by -1 from the VB code because this version is zero indexed! zInt[numRough / 2 + 1] = Math.log((1.0 + dist) / (1.0 - dist)) / (2.0 * cE); rufInt[numRough / 2 + 1] = Erf.erf(cE * zInt[numRough / 2 + 1]); for (j = numRough / 2 + 2; j <= numRough; j++) { dist = dist + step; zInt[j] = Math.log((1.0 + dist) / (1.0 - dist)) / (2.0 * cE); rufInt[j] = Erf.erf(cE * zInt[j]); } // Calculate step widths oHalfstep = 0.5 * (zInt[1] - zInt[0]); for (j = 0; j <= numRough / 2; j++) { zTemp = zInt[j]; // The zInt values are symmetric, so this loop only computes the // bottom half and sets the upper half without doing the // calculation. zInt[j] = oHalfstep + 0.5 * (zInt[j + 1] - zInt[j]); zInt[numRough - j] = zInt[j]; oHalfstep = 0.5 * (zInt[j + 1] - zTemp); } return; }
Example 16
Source File: NormalDistributionImpl.java From astor with GNU General Public License v2.0 | 3 votes |
/** * For this distribution, {@code X}, this method returns {@code P(X < x)}. * 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. * * @param x Value at which the CDF is evaluated. * @return CDF evaluated at {@code x}. * @throws MathException if the algorithm fails to converge */ public double cumulativeProbability(double x) throws MathException { 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 * FastMath.sqrt(2)))); }
Example 17
Source File: NormalDistributionImpl_t.java From coming with MIT License | 3 votes |
/** * For this distribution, {@code X}, this method returns {@code P(X < x)}. 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. * * @param x Value at which the CDF is evaluated. * @return CDF evaluated at {@code x}. * @throws MathException if the algorithm fails to converge */ public double cumulativeProbability(double x) throws MathException { final double dev = x - mean; if (FastMath.abs(dev) > 40 * standardDeviation) {// Math-60 return dev < 0 ? 0.0d : 1.0d; } return 0.5 * (1.0 + Erf.erf((dev) / (standardDeviation * FastMath.sqrt(2.0)))); }
Example 18
Source File: NormalDistributionImpl.java From astor with GNU General Public License v2.0 | 3 votes |
/** * For this distribution, {@code X}, this method returns {@code P(X < x)}. * 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. * * @param x Value at which the CDF is evaluated. * @return CDF evaluated at {@code x}. * @throws MathException if the algorithm fails to converge */ public double cumulativeProbability(double x) throws MathException { 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 * FastMath.sqrt(2)))); }
Example 19
Source File: Math_103_NormalDistributionImpl_s.java From coming with MIT License | 2 votes |
/** * For this disbution, X, this method returns P(X < <code>x</code>). * @param x the value at which the CDF is evaluated. * @return CDF evaluted at <code>x</code>. * @throws MathException if the algorithm fails to converge; unless * x is more than 20 standard deviations from the mean, in which case the * convergence exception is caught and 0 or 1 is returned. */ public double cumulativeProbability(double x) throws MathException { return 0.5 * (1.0 + Erf.erf((x - mean) / (standardDeviation * Math.sqrt(2.0)))); }
Example 20
Source File: NormalDistributionImpl.java From astor with GNU General Public License v2.0 | 2 votes |
/** * For this disbution, X, this method returns P(X < <code>x</code>). * @param x the value at which the CDF is evaluated. * @return CDF evaluted at <code>x</code>. * @throws MathException if the algorithm fails to converge. */ public double cumulativeProbability(double x) throws MathException { return 0.5 * (1.0 + Erf.erf((x - mean) / (standardDeviation * Math.sqrt(2.0)))); }