Example usage for org.apache.commons.math3.stat.descriptive.rank Min evaluate

List of usage examples for org.apache.commons.math3.stat.descriptive.rank Min evaluate

Introduction

In this page you can find the example usage for org.apache.commons.math3.stat.descriptive.rank Min evaluate.

Prototype

@Override
public double evaluate(final double[] values) throws MathIllegalArgumentException 

Source Link

Document

This default implementation calls #clear , then invokes #increment in a loop over the the input array, and then uses #getResult to compute the return value.

Usage

From source file:com.itemanalysis.psychometrics.kernel.LeastSquaresCrossValidation.java

private void computeBounds() throws Exception {
    StandardDeviation stdev = new StandardDeviation();
    this.sd = stdev.evaluate(x);
    Min min = new Min();
    double from = min.evaluate(x);
    Max max = new Max();
    double to = max.evaluate(x);

}

From source file:br.unicamp.ic.recod.gpsi.measures.gpsiDualScore.java

@Override
public double score(double[][][] input) {

    int least;//from   w  w w  .  ja  v  a  2s  .c om

    Min min = new Min();
    Max max = new Max();

    double dist[][] = new double[2][];
    double limits[][] = new double[2][2];

    for (int i = 0; i <= 1; i++) {
        dist[i] = MatrixUtils.createRealMatrix(input[i]).getColumn(0);
        limits[i] = new double[] { min.evaluate(dist[i]), max.evaluate(dist[i]) };
    }

    least = limits[0][0] <= limits[1][0] ? 0 : 1;
    double sep = limits[1 - least][0] - limits[least][1];

    if (sep >= 0)
        return sep / (max.evaluate(new double[] { limits[0][1], limits[1][1] })
                - min.evaluate(new double[] { limits[0][0], limits[1][0] }));

    double n = 0;

    for (int j = 0; j <= 1; j++)
        for (int i = 0; i < dist[j].length; i++) {
            if (dist[j][i] >= limits[1 - least][0] && dist[j][i] <= limits[least][1])
                n++;
        }

    return -n / (dist[0].length + dist[1].length);

}

From source file:com.itemanalysis.jmetrik.graph.irt.IrtPlotAnalysis.java

private XYSeries getSmoothedProportions(double[][] table, double[] rowMargin, int category) {
    XYSeries series = new XYSeries(category + "p");

    double N = 0;
    for (int i = 0; i < nscores; i++) {
        N += rowMargin[i];//  www. ja  va 2s  . co m
    }

    Max max = new Max();
    Min min = new Min();
    UniformDistributionApproximation dist = new UniformDistributionApproximation(min.evaluate(eapScore),
            max.evaluate(eapScore), thin);
    NonparametricIccBandwidth bw = new NonparametricIccBandwidth(N, 1);
    KernelRegression kreg = new KernelRegression(new GaussianKernel(), bw, dist);

    for (int i = 0; i < nscores; i++) {
        if (rowMargin[i] != 0) {
            //                kreg.increment(eapScore[index], table[index][category]/rowMargin[index]);
            kreg.increment(eapScore[i], 1, table[i][category]);
            kreg.increment(eapScore[i], 0, rowMargin[i] - table[i][category]);
        }
    }

    double[] x = kreg.getPoints();
    double[] y = kreg.value();
    for (int i = 0; i < x.length; i++) {
        series.add(x[i], y[i]);
    }

    return series;
}

From source file:com.itemanalysis.jmetrik.graph.density.DensityAnalysis.java

public XYSeriesCollection summarize() throws SQLException, IllegalArgumentException {
    Statement stmt = null;/*  www  . ja  v a 2  s .c  o m*/
    ResultSet rs = null;
    TreeMap<String, ResizableDoubleArray> data = new TreeMap<String, ResizableDoubleArray>();

    //set progress bar information
    int nrow = 0;
    JmetrikPreferencesManager pref = new JmetrikPreferencesManager();
    String dbType = pref.getDatabaseType();
    if (DatabaseType.APACHE_DERBY.toString().equals(dbType)) {
        JmetrikDatabaseFactory dbFactory = new JmetrikDatabaseFactory(DatabaseType.APACHE_DERBY);
        nrow = dao.getRowCount(conn, tableName);
    } else {
        //add other databases here when functionality is added
    }
    maxProgress = (double) nrow;

    Table sqlTable = new Table(tableName.getNameForDatabase());
    SelectQuery select = new SelectQuery();
    select.addColumn(sqlTable, variable.getName().nameForDatabase());
    if (hasGroupingVariable)
        select.addColumn(sqlTable, groupVar.getName().nameForDatabase());
    stmt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
    rs = stmt.executeQuery(select.toString());

    String conditionalName = "";
    ResizableDoubleArray cData = null;
    double value = Double.NaN;

    while (rs.next()) {
        if (groupVar != null) {
            String groupName = rs.getString(groupVar.getName().nameForDatabase());
            if (rs.wasNull()) {
                groupName = "";
            }
            conditionalName = groupName;
        } else {
            conditionalName = "Series 1";
        }

        cData = data.get(conditionalName);
        if (cData == null) {
            cData = new ResizableDoubleArray((int) maxProgress);
            data.put(conditionalName, cData);
        }
        value = rs.getDouble(variable.getName().nameForDatabase());
        if (!rs.wasNull()) {
            cData.addElement(value);
        }
        updateProgress();
    }
    rs.close();
    stmt.close();

    String kType = command.getSelectOneOption("kernel").getSelectedArgument();
    double adjustment = command.getFreeOption("adjust").getDouble();
    KernelFactory kernelFactory = new KernelFactory(kType);

    KernelFunction kernelFunction = kernelFactory.getKernelFunction();
    Bandwidth bandwidth = null;
    KernelDensity density = null;
    UniformDistributionApproximation uniform = null;
    Min min = new Min();
    Max max = new Max();
    double[] x = null;

    this.firePropertyChange("progress-ind-on", null, null);

    XYSeriesCollection seriesCollection = new XYSeriesCollection();
    XYSeries series = null;
    for (String s : data.keySet()) {
        series = new XYSeries(s);
        x = data.get(s).getElements();
        bandwidth = new ScottsBandwidth(x, adjustment);
        uniform = new UniformDistributionApproximation(min.evaluate(x), max.evaluate(x), KERNEL_POINTS);
        density = new KernelDensity(kernelFunction, bandwidth, uniform);

        double[] dens = density.evaluate(x);
        double[] points = density.getPoints();
        for (int i = 0; i < dens.length; i++) {
            series.add(points[i], dens[i]);
        }
        seriesCollection.addSeries(series);
    }
    return seriesCollection;

}