本文整理汇总了Java中org.apache.commons.math3.special.Erf.erf方法的典型用法代码示例。如果您正苦于以下问题:Java Erf.erf方法的具体用法?Java Erf.erf怎么用?Java Erf.erf使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.math3.special.Erf
的用法示例。
在下文中一共展示了Erf.erf方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: uBondCorr
import org.apache.commons.math3.special.Erf; //导入方法依赖的package包/类
public double uBondCorr(){
double uCorr = 0.0;
for (int i=0; i< moleculeList.getMoleculeCount(); i++){
IMolecule molecule = moleculeList.getMolecule(i);
int numSites = molecule.getChildList().getAtomCount();
for (int siteA=0; siteA<numSites; siteA++){
IAtom atomA = molecule.getChildList().getAtom(siteA);
Vector positionA = atomA.getPosition();
double chargeA = atomAgentManager.getAgent(atomA).charge;
if (chargeA==0) continue;
for (int siteB=siteA+1; siteB<numSites; siteB++){
IAtom atomB = molecule.getChildList().getAtom(siteB);
Vector positionB = atomB.getPosition();
double chargeB = atomAgentManager.getAgent(atomB).charge;
if (chargeB==0) continue;
rAB.Ev1Mv2(positionA, positionB);
box.getBoundary().nearestImage(rAB);
double rABMagnitudeSquared = rAB.squared();
double rABMagnitude = Math.sqrt(rABMagnitudeSquared);
uCorr -= chargeA*chargeB*Erf.erf(alpha*rABMagnitude)/rABMagnitude;
}
}
}
return uCorr;
}
示例2: probability
import org.apache.commons.math3.special.Erf; //导入方法依赖的package包/类
/** {@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);
}
if (x0 <= 0 || x1 <= 0) {
return super.probability(x0, x1);
}
final double denom = shape * SQRT2;
final double v0 = (FastMath.log(x0) - scale) / denom;
final double v1 = (FastMath.log(x1) - scale) / denom;
return 0.5 * Erf.erf(v0, v1);
}
示例3: erf
import org.apache.commons.math3.special.Erf; //导入方法依赖的package包/类
public ReflexValue erf(List<ReflexValue> params) {
if (params.size() != 1) {
throw new ReflexException(-1, "erf needs one number parameter");
}
if (!params.get(0).isNumber()) {
throw new ReflexException(-1, "erf needs one number parameter");
}
double value = params.get(0).asDouble();
return new ReflexValue(Erf.erf(value));
}
示例4: probability
import org.apache.commons.math3.special.Erf; //导入方法依赖的package包/类
/** {@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);
}
示例5: testPerformanceErf
import org.apache.commons.math3.special.Erf; //导入方法依赖的package包/类
@Test
public void testPerformanceErf() {
int n = 10000000;
long start = System.nanoTime();
double d = 0;
for(int i = 0; i < n; i++) {
d += Erf.erf(i/n);
}
long end = System.nanoTime();
System.out.println(d);
System.out.println("erf: " +(end-start)/1e6/n);
}
示例6: testPerformanceErf2
import org.apache.commons.math3.special.Erf; //导入方法依赖的package包/类
@Test
public void testPerformanceErf2() {
int n = 10000000;
long start = System.nanoTime();
double d = 0;
for(int i = 0; i < n; i++) {
d += Erf.erf(i/n/10,i/2/n/10);
}
long end = System.nanoTime();
System.out.println(d);
System.out.println("erf2: " +(end-start)/1e6/n);
}
示例7: cumulativeProbability
import org.apache.commons.math3.special.Erf; //导入方法依赖的package包/类
/**
* {@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)));
}
示例8: cumulativeProbability
import org.apache.commons.math3.special.Erf; //导入方法依赖的package包/类
/**
* {@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)));
}
示例9: probability
import org.apache.commons.math3.special.Erf; //导入方法依赖的package包/类
/**
* {@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);
}
示例10: normal
import org.apache.commons.math3.special.Erf; //导入方法依赖的package包/类
private double normal(double x) {
double arg, result, sqrt2 = 1.414213562373095048801688724209698078569672;
if (x > 0) {
arg = x / sqrt2;
result = 0.5 * (1 + Erf.erf(arg));
} else {
arg = -x / sqrt2;
result = 0.5 * (1 - Erf.erf(arg));
}
return result;
}
示例11: zscoreToPvalue
import org.apache.commons.math3.special.Erf; //导入方法依赖的package包/类
/**
* Calculate p-value given a Z-score
*
* @return double p-value
*/
public static double zscoreToPvalue(double zscore) {
zscore = zscore / Math.sqrt(2.0);
double lPvalue = 0.0;
lPvalue = Erf.erf(zscore);
return lPvalue;
}
示例12: doLeft
import org.apache.commons.math3.special.Erf; //导入方法依赖的package包/类
public static Float doLeft(Float z)
{
return (float) ((1.0+Erf.erf(z*0.707106781))/2);
}
示例13: probabilityNonTrunc
import org.apache.commons.math3.special.Erf; //导入方法依赖的package包/类
public static double probabilityNonTrunc(double a, double b, double mu, double sigma) {
final double denom = sigma * SQRT2;
final double scaledSDA = (a - mu) / denom;
final double scaledSDB = (b - mu) / denom;
return 0.5 * Erf.erf(scaledSDA, scaledSDB);
}
示例14: mortensenApproximation
import org.apache.commons.math3.special.Erf; //导入方法依赖的package包/类
private double mortensenApproximation(final double cij, final double eta)
{
// This code is adapted from the Python source code within the supplementary information of
// the paper Mortensen, et al (2010) Nature Methods 7, 377-383.
// [Poisson PMF] multiplied by the [value at zero]:
// [(eta^0 / 0!) * FastMath.exp(-eta)] * [eta * alpha]
// FastMath.exp(-eta) * [eta * alpha]
final double f0 = alpha * FastMath.exp(-eta) * eta;
// ?
final double fp0 = f0 * 0.5 * alpha * (eta - 2);
// The cumulative normal distribution of the read noise
// at the observed count
final double conv0 = 0.5 * (1 + Erf.erf(cij / (sqrt2sigma2)));
// [Noise * Gaussian PMF at observed count] +
// [observed count * cumulative distribution of read noise at observed count]
// [sigma*FastMath.exp(-cij**2/(twoSigma2))/Math.sqrt(2*pi)] + [cij*conv0]
final double conv1 = sigma * FastMath.exp(-(cij * cij) / twoSigma2) / sqrt2pi + cij * conv0;
// ?
double temp = (f0 * conv0 + fp0 * conv1 + FastMath.exp(-eta) * gauss(cij));
if (cij > 0.0)
{
// The observed count converted to photons
final double nij = alpha * cij;
if (eta * nij > 10000)
{
// Approximate Bessel function i1(x) when using large x:
// i1(x) ~ exp(x)/sqrt(2*pi*x)
// However the entire equation is logged (creating transform),
// evaluated then raised to e to prevent overflow error on
// large exp(x)
final double transform = 0.5 * Math.log(alpha * eta / cij) - nij - eta + 2 * Math.sqrt(eta * nij) -
Math.log(twoSqrtPi * Math.pow(eta * nij, 0.25));
temp += (FastMath.exp(transform) - f0 - fp0 * cij);
}
else
{
// Second part of equation 135 but not sure what the
// -f0-fp0*cij term is.
// This indicates that temp should already be the first
// part of eq.135: exp(-eta)*delta(cij)
temp += (Math.sqrt(alpha * eta / cij) * FastMath.exp(-nij - eta) * Bessel.I1(2 * Math.sqrt(eta * nij)) -
f0 - fp0 * cij);
}
}
// XXX : Debugging: Store the smallest likelihood we ever see.
// This can be used to set a limit for the likelihood
//if (pMinObserved > temp && temp > 0)
//{
// pMinObserved = temp;
//}
return (temp > minimumProbability) ? temp : minimumProbability;
}
示例15: cumulativeProbability
import org.apache.commons.math3.special.Erf; //导入方法依赖的package包/类
/**
* {@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));
}