Example usage for org.apache.commons.math3.distribution NormalDistribution NormalDistribution

List of usage examples for org.apache.commons.math3.distribution NormalDistribution NormalDistribution

Introduction

In this page you can find the example usage for org.apache.commons.math3.distribution NormalDistribution NormalDistribution.

Prototype

public NormalDistribution() 

Source Link

Document

Create a normal distribution with mean equal to zero and standard deviation equal to one.

Usage

From source file:com.itemanalysis.psychometrics.statistics.NormalScores.java

public NormalScores() {
    norm = new NormalDistribution();
}

From source file:blackscholes.EuropeanCall.java

public double ValuationMethod() {
    NormalDistribution N = new NormalDistribution();
    double _b = r - b;
    double d1 = (Math.log(S / X) + (b + 0.5 * Math.pow(sigma, 2)) * T) / (sigma * Math.sqrt(T));
    double d2 = d1 - sigma * Math.sqrt(T);

    double Nd1 = N.cumulativeProbability(d1);
    double Nd2 = N.cumulativeProbability(d2);
    return S * Nd1 - X * Nd2 * Math.exp((b - r) * T);
}

From source file:com.itemanalysis.psychometrics.statistics.NormalDensity.java

public NormalDensity() {
    normal = new NormalDistribution();
}

From source file:com.itemanalysis.psychometrics.statistics.RobustZ.java

private void compute(double x, double median, double iqr) {
    NormalDistribution normal = new NormalDistribution();
    if (iqr > 0.0) {
        z = (x - median) / (0.74 * iqr);
        pvalue = normal.cumulativeProbability(z);
        if (z > 0.0) {
            pvalue = 1.0 - pvalue;/*from   ww  w  . j av  a  2  s  . com*/
        }
    }
}

From source file:com.itemanalysis.psychometrics.polycor.PolyserialPlugin.java

public PolyserialPlugin() {
    r = new PearsonCorrelation();
    sdX = new StandardDeviation();
    sdY = new StandardDeviation();
    freqY = new Frequency();
    norm = new NormalDistribution();
}

From source file:com.itemanalysis.psychometrics.scaling.NormalizedScore.java

/**
 * Creates a TreeMap<Integer, Double> lookup table of normalized scores.
 * The key is a raw score level and the rho is a normalized score. This
 * method is useful when finding normalized scores that correspond to an examinee's
 * raw score. After calling this method, individual elements in the
 * TreeMap can be accessed with getNormalizedScoreAt(int rho) or
 * valueIterator()./*from   w w  w.j  a  va 2 s .  c o m*/
 *
 */
public void createLookupTable(PercentileRank prank, LinearTransformation linear) {
    this.prank = prank;
    NormalDistribution normal = new NormalDistribution();
    normScoreTable = new TreeMap<Integer, Double>();
    prank.createLookupTable();
    Iterator<Integer> iter = prank.valueIterator();
    double p = 0.0;
    double q = 0.0;
    Integer i = null;
    while (iter.hasNext()) {
        i = iter.next();
        p = prank.getPercentileRankAt(i) / 100.0;
        q = normal.inverseCumulativeProbability(p);
        normScoreTable.put(i, linear.transform(q));
    }
}

From source file:com.itemanalysis.psychometrics.polycor.PolyserialLogLikelihoodTwoStep.java

public PolyserialLogLikelihoodTwoStep(double[] dataX, int[] dataY) {
    this.dataX = dataX;
    this.dataY = dataY;
    this.normal = new NormalDistribution();
    alpha = new double[nrow];
}

From source file:com.example.PJS.java

/** Nuevas funciones usando la lib de Apache Commons
* http://commons.apache.org/proper/commons-math/apidocs/index.html
    * @param z/*from  ww w  .  j  ava2 s  .  co  m*/
    * @return 
*/
public static double CNDF(double z) {

    NormalDistribution nD = new NormalDistribution();
    double cndf;

    cndf = nD.cumulativeProbability(z);
    return cndf;

}

From source file:com.github.thorbenlindhauer.cluster.ep.TruncatedGaussianPotentialResolver.java

public TruncatedGaussianPotentialResolver(ContinuousVariable predictionVariable, double lowerBound,
        double upperBound) {
    this.lowerBound = lowerBound;
    this.upperBound = upperBound;
    this.predictionVariable = predictionVariable;
    this.standardNormal = new NormalDistribution();
}

From source file:cn.edu.pku.cbi.mosaichunter.math.WilcoxonRankSumTest.java

public static double twoSided(double[] x, double[] y) {
    int nx = x.length;
    int ny = y.length;
    double[] v = new double[nx + ny];
    Arrays.sort(x);/*  w ww.j  a va 2s  .  c  o m*/
    System.arraycopy(x, 0, v, 0, nx);
    System.arraycopy(y, 0, v, nx, ny);
    Arrays.sort(v);

    double[] u = new double[v.length];
    double[] rank = new double[v.length];
    int[] cnt = new int[v.length];
    int n = 0;
    for (int i = 0; i < v.length; ++i) {
        if (i == 0 || v[i] - v[i - 1] > EPS) {
            u[n] = v[i];
            n++;
        }
        cnt[n - 1]++;
        rank[n - 1] += i + 1;
    }
    for (int i = 0; i < n; ++i) {
        rank[i] /= cnt[i];
    }

    double stats = 0;
    int j = 0;
    for (int i = 0; i < nx; ++i) {
        while (x[i] > u[j] + EPS) {
            j++;
        }
        stats += rank[j];
    }
    stats -= nx * (nx + 1) / 2;
    double z = stats - x.length * y.length / 2;

    double tmp = 0;
    for (int i = 0; i < n; ++i) {
        tmp += (double) cnt[i] * cnt[i] * cnt[i] - cnt[i];
    }
    double sigma = Math.sqrt(((double) nx * ny / 12) * (nx + ny + 1 - tmp / (nx + ny) / (nx + ny - 1)));
    if (z > EPS) {
        z -= 0.5;
    } else if (z < -EPS) {
        z += 0.5;
    }
    z /= sigma;

    double p = new NormalDistribution().cumulativeProbability(z);
    double pValue = 2 * Math.min(p, 1 - p);
    if (Double.isNaN(pValue)) {
        return 1;
    }
    return pValue;
}