当前位置: 首页>>代码示例>>Java>>正文


Java Erf类代码示例

本文整理汇总了Java中org.apache.commons.math3.special.Erf的典型用法代码示例。如果您正苦于以下问题:Java Erf类的具体用法?Java Erf怎么用?Java Erf使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Erf类属于org.apache.commons.math3.special包,在下文中一共展示了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;
}
 
开发者ID:etomica,项目名称:etomica,代码行数:26,代码来源:EwaldSummation.java

示例2: energy

import org.apache.commons.math3.special.Erf; //导入依赖的package包/类
public double energy(IAtomList atoms) {
    IAtom atomA = atoms.getAtom(0);
    double chargeA = atomAgentManager.getAgent(atomA).charge;

    IAtom atomB = atoms.getAtom(1);
    double chargeB = atomAgentManager.getAgent(atomB).charge;
    
    Vector positionA = atomA.getPosition();
    Vector positionB = atomB.getPosition();

    rAB.Ev1Mv2(positionA, positionB);// get vector rAB
    box.getBoundary().nearestImage(rAB);// minimum image

    double r2 = rAB.squared();
    if(r2 > rCutSquared) return 0;
    double r = Math.sqrt(r2);
    return chargeA * chargeB * Erf.erfc(alpha * r) / r;//Don't worry about 1/2 factor!
}
 
开发者ID:etomica,项目名称:etomica,代码行数:19,代码来源:EwaldSummation.java

示例3: 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);
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:18,代码来源:LogNormalDistribution.java

示例4: createFirstOrderTables

import org.apache.commons.math3.special.Erf; //导入依赖的package包/类
/**
 * Creates the first order derivatives.
 *
 * @param n
 *            the peak number
 * @param max
 *            the maximum for the dimension
 * @param one_sSqrt2
 *            one over (s times sqrt(2))
 * @param one_2ss
 *            one over (2 * s^2)
 * @param I_sSqrt2pi
 *            the intensity over (s * sqrt(2*pi))
 * @param I_ssSqrt2pi
 *            the intensity over (s^2 * sqrt(2*pi))
 * @param deltaE
 *            the delta E for dimension 0 (difference between the error function at the start and end of each pixel)
 * @param du_dx
 *            the first order x derivative for dimension 0
 * @param du_ds
 *            the first order s derivative for dimension 0
 * @param u
 *            the mean of the Gaussian for dimension 0
 */
protected static void createFirstOrderTables(int n, int max, double one_sSqrt2, double one_2ss, double I_sSqrt2pi,
		double I_ssSqrt2pi, double[] deltaE, double[] du_dx, double[] du_ds, double u)
{
	// For documentation see SingleFreeCircularErfGaussian2DFunction.createSecondOrderTables(...)

	double x_u_p12 = -u;
	double erf_x_minus = 0.5 * Erf.erf(x_u_p12 * one_sSqrt2);
	double exp_x_minus = FastMath.exp(-(x_u_p12 * x_u_p12 * one_2ss));
	for (int i = 0, j = n * max; i < max; i++, j++)
	{
		double x_u_m12 = x_u_p12;
		x_u_p12 += 1.0;
		final double erf_x_plus = 0.5 * Erf.erf(x_u_p12 * one_sSqrt2);
		deltaE[j] = erf_x_plus - erf_x_minus;
		erf_x_minus = erf_x_plus;

		final double exp_x_plus = FastMath.exp(-(x_u_p12 * x_u_p12 * one_2ss));
		du_dx[j] = I_sSqrt2pi * (exp_x_minus - exp_x_plus);
		// Compute: I0 * G21(xk)
		du_ds[j] = I_ssSqrt2pi * (x_u_m12 * exp_x_minus - x_u_p12 * exp_x_plus);

		exp_x_minus = exp_x_plus;
	}
}
 
开发者ID:aherbert,项目名称:GDSC-SMLM,代码行数:49,代码来源:MultiFreeCircularErfGaussian2DFunction.java

示例5: createFirstOrderTables

import org.apache.commons.math3.special.Erf; //导入依赖的package包/类
/**
 * Creates the first order derivatives.
 *
 * @param one_sSqrt2
 *            one over (s times sqrt(2))
 * @param one_2ss
 *            one over (2 * s^2)
 * @param I_sSqrt2pi
 *            the intensity over (s * sqrt(2*pi))
 * @param I_ssSqrt2pi
 *            the intensity over (s^2 * sqrt(2*pi))
 * @param deltaE
 *            the delta E for dimension 0 (difference between the error function at the start and end of each pixel)
 * @param du_dx
 *            the first order x derivative for dimension 0
 * @param du_ds
 *            the first order s derivative for dimension 0
 * @param u
 *            the mean of the Gaussian for dimension 0
 */
protected static void createFirstOrderTables(double one_sSqrt2, double one_2ss, double I_sSqrt2pi,
		double I_ssSqrt2pi, double[] deltaE, double[] du_dx, double[] du_ds, double u)
{
	// For documentation see SingleFreeCircularErfGaussian2DFunction.createSecondOrderTables(...)

	double x_u_p12 = -u;
	double erf_x_minus = 0.5 * Erf.erf(x_u_p12 * one_sSqrt2);
	double exp_x_minus = FastMath.exp(-(x_u_p12 * x_u_p12 * one_2ss));
	for (int i = 0, n = deltaE.length; i < n; i++)
	{
		double x_u_m12 = x_u_p12;
		x_u_p12 += 1.0;
		final double erf_x_plus = 0.5 * Erf.erf(x_u_p12 * one_sSqrt2);
		deltaE[i] = erf_x_plus - erf_x_minus;
		erf_x_minus = erf_x_plus;

		final double exp_x_plus = FastMath.exp(-(x_u_p12 * x_u_p12 * one_2ss));
		du_dx[i] = I_sSqrt2pi * (exp_x_minus - exp_x_plus);
		// Compute: I0 * G21(xk)
		du_ds[i] = I_ssSqrt2pi * (x_u_m12 * exp_x_minus - x_u_p12 * exp_x_plus);

		exp_x_minus = exp_x_plus;
	}
}
 
开发者ID:aherbert,项目名称:GDSC-SMLM,代码行数:45,代码来源:SingleFreeCircularErfGaussian2DFunction.java

示例6: testRuns

import org.apache.commons.math3.special.Erf; //导入依赖的package包/类
/**
 * Run Test
 * <p>
 * The focus of the test is the total number of runs in the sequence,
 * where a run is an uninterrupted sequence of identical bits. A run
 * of length k consists of exactly k identical bits and is bounded
 * before and after with a bit of the opposite value. The purpose of
 * the runs test is to determined whether the number of runs of ones
 * and zeros of various lengths is as expected for a random sequence.
 * In particular, this test determines whether the oscillation between
 * such zeros and ones is too fast or too slow.
 */
private void testRuns(final int[] epsilon) {
    final int n = epsilon.length;

    int s = 0;
    for (int k = 0; k < n; k++)
        if (epsilon[k] == 0)
            ++s;
    double pi = (double) s / (double) n;

    double p_value;
    if (Math.abs(pi - 0.5) > (2.0 / Math.sqrt(n))) {
        p_value = 0.0;
    } else {
        double v = 1;
        for (int k = 1; k < n; k++)
            if (epsilon[k] != epsilon[k - 1])
                ++v;
        double erfc_arg = Math.abs(v - 2.0 * n * pi * (1 - pi))
                / (2.0 * pi * (1 - pi) * Math.sqrt(2 * n));
        p_value = Erf.erfc(erfc_arg);
    }
    assertTrue("RNG test failed, test runs.", p_value >= 0.01);
}
 
开发者ID:intel-hadoop,项目名称:diceros,代码行数:36,代码来源:DRNGTest.java

示例7: gradient

import org.apache.commons.math3.special.Erf; //导入依赖的package包/类
public Vector[] gradient(IAtomList atoms) {
    //Real gradient  //Cross Interaction
    IAtom atomA = atoms.getAtom(0);
    double chargeA = atomAgentManager.getAgent(atomA).charge;
    Vector positionA = atomA.getPosition();
    IAtom atomB = atoms.getAtom(1);

    double chargeB = atomAgentManager.getAgent(atomB).charge;

    Vector positionB = atomB.getPosition();
    rAB.Ev1Mv2(positionA, positionB); //rAB == rA - rB
    box.getBoundary().nearestImage(rAB);

    double rAB2 = rAB.squared();
    if (rAB2 > rCutSquared) {
        gradient2[0].E(0);
        gradient2[1].E(0);
        return gradient2;
    }

    double rABMagnitude = Math.sqrt(rAB2);
    double rAB3 = rABMagnitude*rAB2;
    double B = Erf.erfc(alpha*rABMagnitude) + 2.0*alpha*rABMagnitude/sqrtPI * Math.exp(-alpha2*rAB2) ;
    double realCoeff = - chargeA*chargeB * B / rAB3; // gradU = -F
    gradient2[0].Ea1Tv1(realCoeff, rAB);
    gradient2[1].Ea1Tv1(-realCoeff, rAB);
    return gradient2;
}
 
开发者ID:etomica,项目名称:etomica,代码行数:29,代码来源:EwaldSummation.java

示例8: 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));
}
 
开发者ID:RapturePlatform,项目名称:Rapture,代码行数:11,代码来源:ReflexErf.java

示例9: erfc

import org.apache.commons.math3.special.Erf; //导入依赖的package包/类
public ReflexValue erfc(List<ReflexValue> params) {
    if (params.size() != 1) {
        throw new ReflexException(-1, "erfc needs one number parameter");
    }
    if (!params.get(0).isNumber()) {
        throw new ReflexException(-1, "erfc needs one number parameter");
    }
    double value = params.get(0).asDouble();
    return new ReflexValue(Erf.erfc(value));
}
 
开发者ID:RapturePlatform,项目名称:Rapture,代码行数:11,代码来源:ReflexErf.java

示例10: inverseCumulativeProbability

import org.apache.commons.math3.special.Erf; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public double inverseCumulativeProbability(final double p) throws OutOfRangeException {
    if (p < 0.0 || p > 1.0) {
        throw new OutOfRangeException(p, 0, 1);
    }
    final double t = Erf.erfcInv(p);
    return mu + halfC / (t * t);
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:10,代码来源:LevyDistribution.java

示例11: 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 * Erf.erfc(-dev / (standardDeviation * SQRT2));
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:15,代码来源:NormalDistribution.java

示例12: inverseCumulativeProbability

import org.apache.commons.math3.special.Erf; //导入依赖的package包/类
/** {@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);
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:11,代码来源:NormalDistribution.java

示例13: 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);
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:15,代码来源:NormalDistribution.java

示例14: 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);
}
 
开发者ID:zitmen,项目名称:thunderstorm,代码行数:13,代码来源:IntegratedSymmetricGaussianPSFTest.java

示例15: 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);
}
 
开发者ID:zitmen,项目名称:thunderstorm,代码行数:13,代码来源:IntegratedSymmetricGaussianPSFTest.java


注:本文中的org.apache.commons.math3.special.Erf类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。