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


Java Erf.erfc方法代码示例

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


在下文中一共展示了Erf.erfc方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: 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

示例6: probabilityTruncZero

import org.apache.commons.math3.special.Erf; //导入方法依赖的package包/类
/**
 * returns the probability of x falling within the range of a to b
 * under a normal distribution with mean mu and standard deviation sigma
 * if the distribution is truncated below 0 and renormalized
 * 
 *  a and b should both be greater than or equal to 0 but this is not checked
 */
public static double probabilityTruncZero(double a, double b, double mu, double sigma) {
    // clip at zero
    a = Math.max(a, 0.0);
    b = Math.max(b, 0.0);
    final double denom = sigma * SQRT2;
    final double scaledSDA = (a - mu) / denom; 
    final double scaledSDB = (b - mu) / denom; 
    // compute prob 
    final double probNormTimes2 = Erf.erf(scaledSDA, scaledSDB); 
    // renormalize
    final double scaledSD0 = -mu / denom; 
    final double reZTimes2 = Erf.erfc(scaledSD0);
    return probNormTimes2 / reZTimes2; 
}
 
开发者ID:mgormley,项目名称:pacaya,代码行数:22,代码来源:TruncatedNormal.java

示例7: normalCdf

import org.apache.commons.math3.special.Erf; //导入方法依赖的package包/类
public static double normalCdf(double x, double mean, double sd) {
    final double dev = x - mean;
    if (FastMath.abs(dev) > 40 * sd) {
        return dev < 0 ? 0.0d : 1.0d;
    }
    return 0.5 * Erf.erfc(-dev / (sd * SQRT2));
}
 
开发者ID:mikessh,项目名称:mageri,代码行数:8,代码来源:AuxiliaryStats.java

示例8: testFrequency

import org.apache.commons.math3.special.Erf; //导入方法依赖的package包/类
/**
 * Frequency(Monobit) Test
 * <p/>
 * The focus of the test is the proportion of zeros and ones for
 * the entire sequence. The purpose of this test is to determine
 * whether the number of ones and zeros in a sequence are approximately
 * the same as would be expected for a truly random sequence.
 */
private void testFrequency(final int[] epsilon) {
    final int n = epsilon.length;

    double sum = 0.0;
    for (int i = 0; i < n; i++) {
        sum += 2 * epsilon[i] - 1;
    }
    double s_obs = Math.abs(sum) / Math.sqrt(n);
    double f = s_obs / Math.sqrt(2);
    double p_value = Erf.erfc(f);

    assertTrue("RNG test failed, test frequency.", p_value >= 0.01);
}
 
开发者ID:intel-hadoop,项目名称:diceros,代码行数:22,代码来源:DRNGTest.java

示例9: testDiscreteFourierTransform

import org.apache.commons.math3.special.Erf; //导入方法依赖的package包/类
/**
 * Discrete Fourier Transform (Spectral) Test
 * <p>
 * The focus of this test is the peak heights in the Discrete Fourier
 * Transform of the sequence. The purpose of this test is to detect
 * periodic features (i.e., repetitive patterns that are near each other)
 * in the tested sequence that would indicate a deviation from the
 * assumption of randomness. The intention is to detect whether the number
 * of peaks exceeding the 95% threshold is significantly different than 5%.
 */
private void testDiscreteFourierTransform(final int[] epsilon) {
    final int n = epsilon.length;

    double p_value, upperBound, N_l, N_o, d;
    double[] m = new double[n / 2 + 1], X = new double[n];
    int i, count;

    for (i = 0; i < n; i++)
        X[i] = 2 * epsilon[i] - 1;

    double[] X1 = new double[n];
    for (i = 0; i < X.length; i++) {
        X1[i] = X[i];
    }

    FastFourierTransformer fft = new FastFourierTransformer(DftNormalization.STANDARD);
    Complex[] Xc = fft.transform(X, TransformType.FORWARD);
    m[0] = Math.sqrt(Xc[0].getReal() * Xc[0].getReal());

    for (i = 0; i < n / 2; i++)
        m[i + 1] = Math.sqrt(
                Math.pow(Xc[2 * i].getReal(), 2)
                        + Math.pow(Xc[2 * i + 1].getReal(), 2));
    count = 0;
    upperBound = Math.sqrt(2.995732274 * n);
    for (i = 0; i < n / 2; i++)
        if (m[i] < upperBound) count++;
    N_l = (double) count;
    N_o = 0.95 * n / 2.0;
    d = (N_l - N_o) / Math.sqrt(n / 4.0 * 0.95 * 0.05);
    p_value = Erf.erfc(Math.abs(d) / Math.sqrt(2.0));

    assertTrue("RNG test failed, test discrete fourier transform.", p_value >= 0.01);
}
 
开发者ID:intel-hadoop,项目名称:diceros,代码行数:45,代码来源:DRNGTest.java

示例10: testRandomExcursionsVariant

import org.apache.commons.math3.special.Erf; //导入方法依赖的package包/类
/**
     * Random Excursions Variant Test
     * <p>
     * The focus of this test is the total number of times that a particular
     * state is visited (i.e., occurs) in a cumulative sum random walk. The
     * purpose of this test is to detect deviations from the expected number
     * of visits to various states in the random walk. This test is actually
     * a series of eighteen tests (and conclusions), one test and conclusion
     * for each of the states: -9, -8, …, -1 and +1, +2, …, +9.
     */
    public void testRandomExcursionsVariant(final int[] epsilon) {
        final int n = epsilon.length;
        int[] stateX = {-9, -8, -7, -6, -5, -4, -3, -2, -1, 1, 2, 3, 4, 5, 6, 7, 8, 9};
        int[] S_k = new int[n];
        int J = 0, i;
        S_k[0] = 2 * epsilon[0] - 1;
        for (i = 1; i < n; i++) {
            S_k[i] = S_k[i - 1] + 2 * epsilon[i] - 1;
            if (0 == S_k[i]) {
                J++;
            }
        }
        if (0 != S_k[n - 1]) {
            J++;
        }
//        int constraint = (int) Math.max(0.005 * Math.pow(n, 0.5), 500);
        int p, x, count;
        double p_value;
        for (p = 0; p < 18; p++) {
            x = stateX[p];
            count = 0;
            for (i = 0; i < n; i++) {
                if (S_k[i] == x) {
                    count++;
                }
            }
            p_value = Erf.erfc(Math.abs(count - J) / (Math.sqrt(2.0 * J * (4.0 * Math.abs(x) - 2))));
            assertTrue("RNG test failed, test random excursions variant.", p_value >= 0.01);
        }
    }
 
开发者ID:intel-hadoop,项目名称:diceros,代码行数:41,代码来源:DRNGTest.java

示例11: merge

import org.apache.commons.math3.special.Erf; //导入方法依赖的package包/类
private static void merge(DataPoint[] orderedByMz, DataPoint[] orderedByInt) {
    // we assume a rather large deviation as signal peaks should be contained in more than one
    // measurement
    final List<DataPoint> append = new ArrayList<>();
    final double absoluteDeviation = 0.005;
    for (int k = 0; k < orderedByInt.length; ++k) {
        final DataPoint peak = orderedByInt[k];
        final double dev = Math.max(absoluteDeviation, peak.getMZ() * 10e-6);
        final double lb = peak.getMZ() - dev, ub = peak.getMZ() + dev;
        int mz1 = Arrays.binarySearch(orderedByMz, peak, CompareDataPointsByMz);
        if (mz1 < 0) {
            mz1 = -(mz1 + 1);
        }
        int mz0 = mz1 - 1;
        while (mz1 < orderedByMz.length && orderedByMz[mz1].getMZ() <= ub) ++mz1;
        --mz1;
        while (mz0 >= 0 && orderedByMz[mz0].getMZ() >= lb) --mz0;
        ++mz0;
        if (mz0 <= mz1) {
            // merge!
            int mostIntensive = mz0;
            double bestScore = Double.NEGATIVE_INFINITY;
            for (int i = mz0; i <= mz1; ++i) {
                final double massDiff = orderedByMz[i].getMZ() - peak.getMZ();
                final double score = Erf.erfc(3 * massDiff) / (dev * Math.sqrt(2)) * orderedByMz[i].getIntensity();
                if (score > bestScore) {
                    bestScore = score;
                    mostIntensive = i;
                }
            }
            final double mzValue = peak.getIntensity() > orderedByMz[mostIntensive].getIntensity() ? peak.getMZ() : orderedByMz[mostIntensive].getMZ();
            orderedByMz[mostIntensive] = new SimpleDataPoint(mzValue, peak.getIntensity() + orderedByMz[mostIntensive].getIntensity());
        } else {
            // append
            append.add(peak);
        }
    }
    if (append.size() > 0) {
        int offset = orderedByMz.length;
        orderedByMz = Arrays.copyOf(orderedByMz, orderedByMz.length + append.size());
        for (DataPoint p : append) {
            orderedByMz[offset++] = p;
        }
        Arrays.sort(orderedByMz, CompareDataPointsByMz);
    }
}
 
开发者ID:mzmine,项目名称:mzmine2,代码行数:47,代码来源:SiriusExportTask.java

示例12: cumulativeNonTrunc

import org.apache.commons.math3.special.Erf; //导入方法依赖的package包/类
public static double cumulativeNonTrunc(double x, double mu, double sigma) {
    final double denom = sigma * SQRT2;
    return 0.5 * Erf.erfc((mu - x) / denom);
}
 
开发者ID:mgormley,项目名称:pacaya,代码行数:5,代码来源:TruncatedNormal.java

示例13: testUniversal

import org.apache.commons.math3.special.Erf; //导入方法依赖的package包/类
/**
 * Maurer's "Universal Statistical" Test
 * <p>
 * The focus of this test is the number of bits between matching patterns
 * (a measure that is related to the length of a compressed sequence). The
 * purpose of the test is to detect whether or not the sequence can be
 * significantly compressed without loss of information. A significantly
 * compressible sequence is considered to be non-random.
 */
private void testUniversal(final int[] epsilon) {
    int i, j, p, L, Q, K, n = epsilon.length;
    double arg, sqrt2, sigma, phi, sum, p_value, c;
    int decRep;
    long[] T;
    double[] expected_value = {
            0, 0, 0, 0, 0, 0, 5.2177052, 6.1962507,
            7.1836656, 8.1764248, 9.1723243, 10.170032,
            11.168765, 12.168070, 13.167693, 14.167488,
            15.167379
    };
    double[] variance = {
            0, 0, 0, 0, 0, 0, 2.954, 3.125, 3.238, 3.311,
            3.356, 3.384, 3.401, 3.410, 3.416, 3.419, 3.421
    };

    L = 5;
    if (n >= 387840) L = 6;
    if (n >= 904960) L = 7;
    if (n >= 2068480) L = 8;
    if (n >= 4654080) L = 9;
    if (n >= 10342400) L = 10;
    if (n >= 22753280) L = 11;
    if (n >= 49643520) L = 12;
    if (n >= 107560960) L = 13;
    if (n >= 231669760) L = 14;
    if (n >= 496435200) L = 15;
    if (n >= 1059061760) L = 16;

    Q = 10 * (int) Math.pow(2, L);
    K = (int) (Math.floor(n / L) - (double) Q);	 		    /* BLOCKS TO TEST */

    p = (int) Math.pow(2, L);
    T = new long[p];
    assertTrue("L is out of range.", L >= 6 && L <= 16);
    assertTrue("Q is less than " + (10 * Math.pow(2, L)), ((double) Q >= 10 * Math.pow(2, L)));

    c = 0.7 - 0.8 / (double) L + (4 + 32 / (double) L) * Math.pow(K, -3 / (double) L) / 15;
    sigma = c * Math.sqrt(variance[L] / (double) K);
    sqrt2 = Math.sqrt(2);
    sum = 0.0;
    for (i = 0; i < p; i++)
        T[i] = 0;
    for (i = 1; i <= Q; i++) {		/* INITIALIZE TABLE */
        decRep = 0;
        for (j = 0; j < L; j++)
            decRep += epsilon[(i - 1) * L + j] * (long) Math.pow(2, L - 1 - j);
        T[decRep] = i;
    }
    for (i = Q + 1; i <= Q + K; i++) { 	/* PROCESS BLOCKS */
        decRep = 0;
        for (j = 0; j < L; j++)
            decRep += epsilon[(i - 1) * L + j] * (long) Math.pow(2, L - 1 - j);
        sum += Math.log(i - T[decRep]) / Math.log(2);
        T[decRep] = i;
    }
    phi = sum / (double) K;

    arg = Math.abs(phi - expected_value[L]) / (sqrt2 * sigma);
    p_value = Erf.erfc(arg);

    assertTrue("RNG test failed, test universal.", p_value >= 0.01);
}
 
开发者ID:intel-hadoop,项目名称:diceros,代码行数:73,代码来源:DRNGTest.java

示例14: cumulativeProbability

import org.apache.commons.math3.special.Erf; //导入方法依赖的package包/类
/** {@inheritDoc}
 * <p>
 * From Wikipedia: the cumulative distribution function is
 * </p>
 * <pre>
 * f(x; u, c) = erfc (&radic; (c / 2 (x - u )))
 * </pre>
 */
public double cumulativeProbability(final double x) {
    if (x < mu) {
        return Double.NaN;
    }
    return Erf.erfc(FastMath.sqrt(halfC / (x - mu)));
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:15,代码来源:LevyDistribution.java


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