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

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

Introduction

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

Prototype

public double density(double x) 

Source Link

Usage

From source file:akori.Normal.java

static public void main(String[] args) {
    NormalDistribution n = new NormalDistribution(0, 0.4);

    for (double i = 0; i < 1; i = i + (1.0 / 50.0)) {
        System.out.println("i: " + i);
        System.out.println("densidad: " + n.density(i));
    }//from   w w w  .  j  a va  2  s. co m
}

From source file:com.mycompany.app.VariousTest.java

public static void normalDistribution() {
    NormalDistribution normalDistribution = new NormalDistribution(-2, 2.5);
    System.out.println(normalDistribution.density(-3) * 25);

}

From source file:com.example.PJS.java

public static double PDF(double z) {
    NormalDistribution nD = new NormalDistribution();
    double pdf;// w w w. java  2 s. co  m
    pdf = nD.density(z);
    return pdf;

}

From source file:akori.Impact.java

static public void normalMatrix(double[][] matrix, int x, int y, int std) {
    double max = 0;
    NormalDistribution n = new NormalDistribution(0, 0.4);
    for (int i = x - std; i < x + std && matrix.length > i && i >= 0; ++i) {
        for (int j = y - std; j < y + std && matrix[0].length > j && j >= 0; ++j) {
            double r = Math.sqrt((i - x) * (i - x) + (j - y) * (j - y));
            if (r > 0 && r <= std) {
                matrix[i][j] = matrix[i][j] + n.density(r / std);
            }/*from  w w  w .j  a  v a 2s.  c om*/
        }
    }
}

From source file:it.cnr.isti.smartfed.test.DatacenterFacilities.java

public static List<FederationDatacenter> getNormalDistribution(int numOfDatacenters, int numHost) {
    Random r = new Random(13213);

    int core_variance = maxNumOfCores - minNumOfCores;
    int delta_cores = core_variance > 0 ? r.nextInt(core_variance) : 0;

    List<FederationDatacenter> list = new ArrayList<FederationDatacenter>();
    NormalDistribution nd = new NormalDistribution(numOfDatacenters / 2d, numOfDatacenters / 4d);

    // System.out.println("Aa"+numHost);

    for (int i = 0; i < numOfDatacenters; i++) {
        // create the virtual processor (PE)
        List<Pe> peList = new ArrayList<Pe>();
        int mips = 25000;
        for (int j = 0; j < minNumOfCores + delta_cores; j++) {
            peList.add(new Pe(j, new PeProvisionerSimple(mips)));
        }/*from  w w  w .j  a  va2  s. c om*/

        // create the hosts
        List<Host> hostList = new ArrayList<Host>();
        HostProfile prof = HostProfile.getDefault();
        prof.set(HostParams.RAM_AMOUNT_MB, 16 * 1024 + "");

        int num;
        if (numOfDatacenters == 1) {
            num = numHost;
        } else {
            Double value = new Double(nd.density(i)) * numHost;
            num = value.intValue();
        }

        if (num < 1)
            num = 1;

        for (int k = 0; k < num; k++) {
            hostList.add(HostFactory.get(prof, peList));
        }

        // create the storage
        List<Storage> storageList = new ArrayList<Storage>(); // if empty, no SAN attached

        // create the datacenters
        list.add(FederationDatacenterFactory.getDefault(hostList, storageList));
    }

    return list;
}

From source file:de.bund.bfr.math.LodFunction.java

@Override
public double value(double[] point) {
    double sd = Double.NaN;

    for (int ip = 0; ip < nParams; ip++) {
        if (parameters.get(ip).equals(sdParam)) {
            sd = Math.abs(point[ip]);
        } else {/*w ww .  j a  v  a2  s . co  m*/
            parser.setVarValue(parameters.get(ip), point[ip]);
        }
    }

    if (sd == 0.0) {
        return Double.NaN;
    }

    double logLikelihood = 0.0;

    for (int iv = 0; iv < nValues; iv++) {
        for (Map.Entry<String, List<Double>> entry : variableValues.entrySet()) {
            parser.setVarValue(entry.getKey(), entry.getValue().get(iv));
        }

        try {
            double value = parser.evaluate(function);

            if (!Double.isFinite(value)) {
                return Double.NaN;
            }

            NormalDistribution normDist = new NormalDistribution(value, sd);

            logLikelihood += targetValues.get(iv) > levelOfDetection
                    ? Math.log(normDist.density(targetValues.get(iv)))
                    : Math.log(normDist.cumulativeProbability(levelOfDetection));
        } catch (ParseException e) {
            e.printStackTrace();
            return Double.NaN;
        }
    }

    return logLikelihood;
}

From source file:com.itemanalysis.psychometrics.distribution.NormalDistributionApproximation.java

private void initialize(double min, double max, double mean, double sd) {
    //create points
    double range = max - min;
    points = new double[numberOfPoints];
    double step = range / ((double) numberOfPoints - 1.0);
    points[0] = min;//  w ww  .  j ava 2  s  . c  o  m
    for (int i = 1; i < numberOfPoints; i++) {
        points[i] = points[i - 1] + step;
    }

    //compute density
    NormalDistribution normal = new NormalDistribution(mean, sd);
    density = new double[numberOfPoints];
    double densitySum = 0.0;
    for (int i = 0; i < numberOfPoints; i++) {
        density[i] = normal.density(points[i]);
        densitySum += density[i];
    }

    //make sure probabilities sum to unity
    for (int i = 0; i < numberOfPoints; i++) {
        density[i] = density[i] / densitySum;
    }

}

From source file:DataPreProcess.ConvertedTrace.java

private void fill_activity(int row, int st, int ed) {
    int mid = (ed + st) / 2;
    double sd = (double) (ed - st) / 4;
    NormalDistribution ND = new NormalDistribution(mid, sd);
    for (int col = 0; col < Length; col++) {
        double pro_density = ND.density(col);
        Matrix[row][col] += pro_density;
    }/*from ww w  . java 2  s  .  com*/
    //        for (int col = st; col < ed; col++) {
    //            Matrix[row][col] = 1;
    //        }
}

From source file:es.us.isa.sedl.module.statcharts.renderer.HighChartsRenderer.java

private String[][] generateNormalDistribution(HistogramResult histogramResult) {
    Integer total = 0;//from  w  ww  . java 2 s  .  c  om
    for (String value : histogramResult.getCounts())
        total += Integer.valueOf(value);
    Double mean = Double.valueOf(histogramResult.getMean());
    Double sigma = Double.valueOf(histogramResult.getSigma());
    NormalDistribution normal = new NormalDistribution(mean, sigma);
    Double[] xPoints = { -3.2807020192309, -3.0425988742109, -2.8044957291909, -2.5663925841709,
            -2.3282894391509, -2.0901862941309, -1.8520831491109, -1.6139800040909, -1.3758768590709,
            -1.1377737140509, -0.89967056903087, -0.66156742401087, -0.42346427899086, -0.18536113397085,
            0.052742011049155, 0.29084515606916, 0.52894830108917, 0.76705144610918, 1.0051545911292,
            1.2432577361492, 1.4813608811692, 1.7194640261892, 1.9575671712092, 2.1956703162292,
            2.4337734612492, 2.6718766062692, 2.9099797512892, 3.1480828963092 };
    String[][] result = new String[xPoints.length][2];
    for (int i = 0; i < xPoints.length; i++) {
        result[i][0] = String.valueOf(mean + xPoints[i] * sigma);
        result[i][1] = String.valueOf(normal.density(mean + xPoints[i] * sigma) * total);
    }
    return result;
}

From source file:Option2017Interface.DistFunctions.java

public static double PDF(double z) {

    NormalDistribution nD = new NormalDistribution();
    double pdf;/*from  w  w  w .  j a  v  a2s  .  co m*/
    pdf = nD.density(z);
    return pdf;

}