Iterator<Comparable<?>> values = valuesIterator(); while (values.hasNext()) { Comparable<?> nextValue = values.next();
public Iterator<Comparable<?>> colValuesIterator(){ return colMargin.valuesIterator(); }
public Iterator<Comparable<?>> rowValuesIterator(){ return rowMargin.valuesIterator(); }
/** * Computes the sum of scores for those values in columns. * * @return sum of scores */ public double sumOfScores(){ double sum = 0.0; Iterator<Comparable<?>> iter = columns.valuesIterator(); Double score = null; while(iter.hasNext()){ score = (Double)iter.next(); sum += score*columns.getCount(score); } return sum; }
@Override public String toString(){ StringBuilder sb = new StringBuilder(); Formatter f = new Formatter(sb); f.format("%-10s", rowValue); f.format("%5s", ""); Iterator<Comparable<?>> iter =columns.valuesIterator(); double freq = 0; while(iter.hasNext()){ freq = columns.getCount(iter.next()); f.format("%10.0f", freq); f.format("%5s", ""); } return f.toString(); }
/** * Computes the marginal sum of squared scores. This computation * is needed for the Cochran-Mantel-Haenszel statistic. * * @return sum of scores for the column margin */ public double sumOfSquaredScores(){ Iterator<Comparable<?>> iter = columnMargin.valuesIterator(); Double d = null; double sum = 0.0; while(iter.hasNext()){ d = (Double)iter.next(); sum += Math.pow(d,2)*columnMargin.getCount(d); } return sum; }
/** * Computes the marginal sum of scores. This computation * is needed for the Cochran-Mantel-Haenszel statistic. * * @return sum of scores for the column margin. */ public double sumOfScores(){ Iterator<Comparable<?>> iter = columnMargin.valuesIterator(); Double d = null; double sum = 0.0; while(iter.hasNext()){ d = (Double)iter.next(); sum += d*columnMargin.getCount(d); } return sum; }
@Override public String toString(){ StringBuilder sb = new StringBuilder(); Formatter f = new Formatter(sb); double score = 0.0; Iterator<Comparable<?>> iter = columnMargin.valuesIterator(); f.format("%26s", " "); while(iter.hasNext()){ score = ((Double)iter.next()).doubleValue(); f.format("%10.0f", score); f.format("%5s", " "); } f.format("%n"); f.format("%51s", "-------------------------"); iter = columnMargin.valuesIterator(); int index=0; while(iter.hasNext()){ score = ((Double)iter.next()).doubleValue(); if(index>1) f.format("%15s", "---------------"); index++; } f.format("%n"); f.format("%11s", "Reference: "); f.format("%-100s", referenceRow.toString()); f.format("%n"); f.format("%11s", "Focal: "); f.format("%-100s", focalRow.toString()); f.format("%n"); return f.toString(); }
/** * For r number of score levels between min and max, inclusive, this method * returns a r x 2 array with integer based scores in first column * and percentile ranks in the second column. This method is useful when * only the raw scores and corresponding percentile ranks are needed. * * @return two-way array of raw scores scores and percentile ranks. */ public double[][] evaluate(){ double[][] prank = new double[freqTable.getUniqueCount()][2]; int xstar; int index = 0; Iterator<Comparable<?>> iter = freqTable.valuesIterator(); int x = 0; while(iter.hasNext()){ x = ((Long)iter.next()).intValue(); xstar = Double.valueOf(Math.floor(x+0.5)).intValue(); prank[index][0] = xstar; prank[index][1] = percentileRank(x, xstar); index++; // System.out.println("x: " + x + " xstar: " + xstar + " Fexstar: " + Fxstar + " Fxstarm1: " + Fxstarm1 + " px: " + px + " cp: " + getCummulativeProportion(xstar)); } return prank; }
public double[][] getTable(){ int nrow = rowMargin.getUniqueCount(); int ncol = colMargin.getUniqueCount(); double[][] table = new double[nrow][ncol]; Iterator<Comparable<?>> rows = rowMargin.valuesIterator(); Iterator<Comparable<?>> cols = null; Comparable<?> rTemp = null; int i=0; int j=0; while(rows.hasNext()){ cols = colMargin.valuesIterator(); rTemp = rows.next(); j=0; while(cols.hasNext()){ table[i][j] = (double)getCount(rTemp, cols.next()); j++; } i++; } return table; }
public double[] getThresholds(){ double[] alpha = new double[freqY.getUniqueCount()-1]; Iterator<Comparable<?>> iter = freqY.valuesIterator(); Comparable<?> v = null; int index = 0; while(iter.hasNext()){ v = iter.next(); if(iter.hasNext()){ alpha[index] = norm.inverseCumulativeProbability(freqY.getCumPct(v)); index++; } } return alpha; }
Iterator iterator = frequency.valuesIterator();
Iterator<Comparable<?>> iter = freq.valuesIterator(); int index = 0;
Iterator<Comparable<?>> values = valuesIterator(); while (values.hasNext()) { Comparable<?> nextValue = values.next();
Iterator<Comparable<?>> iter = freq.valuesIterator(); int index = 0; byte[] rv = null;
Iterator<Comparable<?>> values = valuesIterator(); while (values.hasNext()) { Comparable<?> nextValue = values.next();
Iterator<Comparable<?>> iter = freqTable.valuesIterator();
/** * Checks whether the observations conform to a Poisson process with the * specified intensity. Uses a chi square test with the specified confidence. * The null hypothesis is that the observations are the result of a poisson * process. * @param observations * @param intensity * @param confidence * @return <code>true</code> if the observations */ static boolean isPoissonProcess(Frequency observations, double intensity, double length, double confidence) { final PoissonDistribution pd = new PoissonDistribution(length * intensity); final Iterator<?> it = observations.valuesIterator(); final long[] observed = new long[observations.getUniqueCount()]; final double[] expected = new double[observations.getUniqueCount()]; int index = 0; while (it.hasNext()) { final Long l = (Long) it.next(); observed[index] = observations.getCount(l); expected[index] = pd.probability(l.intValue()) * observations.getSumFreq(); if (expected[index] == 0) { return false; } index++; } final double chi = TestUtils.chiSquareTest(expected, observed); return !(chi < confidence); }
Iterator<Comparable<?>> itr = f.valuesIterator(); while (itr.hasNext()) { String s = (String) itr.next(); Iterator<Comparable<?>> itr = f.valuesIterator(); while (itr.hasNext()) { MyDouble n = (MyDouble) itr.next();
Iterator<Comparable<?>> itr = f.valuesIterator(); String strMax = (String) itr.next(); String strMin = strMax; itr = f.valuesIterator(); Iterator<Comparable<?>> itr = f.valuesIterator(); numMax = (Double) itr.next(); numMin = numMax; itr = f.valuesIterator();