/** * Returns the cumulative frequency of values less than or equal to v. * <p> * Returns 0 if v is not comparable to the values set.</p> * * @param v the value to lookup * @return the proportion of values equal to v */ public long getCumFreq(int v) { return getCumFreq(Long.valueOf(v)); }
/** * Returns the cumulative frequency of values less than or equal to v. * <p> * Returns 0 if v is not comparable to the values set.</p> * * @param v the value to lookup * @return the proportion of values equal to v */ public long getCumFreq(char v) { return getCumFreq(Character.valueOf(v)); }
/** * Returns the cumulative frequency of values less than or equal to v. * <p> * Returns 0 if v is not comparable to the values set.</p> * * @param v the value to lookup * @return the proportion of values equal to v */ public long getCumFreq(long v) { return getCumFreq(Long.valueOf(v)); }
/** * Returns the cumulative percentage of values less than or equal to v * (as a proportion between 0 and 1). * <p> * Returns <code>Double.NaN</code> if no values have been added. * Returns 0 if at least one value has been added, but v is not comparable * to the values set.</p> * * @param v the value to lookup * @return the proportion of values less than or equal to v */ public double getCumPct(Comparable<?> v) { final long sumFreq = getSumFreq(); if (sumFreq == 0) { return Double.NaN; } return (double) getCumFreq(v) / (double) sumFreq; }
return getCumFreq(((Integer) v).longValue());
/** * Returns the cumulative frequency of values less than or equal to v. * <p> * Returns 0 if v is not comparable to the values set.</p> * * @param v the value to lookup * @return the proportion of values equal to v */ public long getCumFreq(char v) { return getCumFreq(Character.valueOf(v)); }
/** * Returns the cumulative frequency of values less than or equal to v. * <p> * Returns 0 if v is not comparable to the values set.</p> * * @param v the value to lookup * @return the proportion of values equal to v */ public long getCumFreq(char v) { return getCumFreq(Character.valueOf(v)); }
/** * Returns the cumulative frequency of values less than or equal to v. * <p> * Returns 0 if v is not comparable to the values set.</p> * * @param v the value to lookup * @return the proportion of values equal to v */ public long getCumFreq(int v) { return getCumFreq(Long.valueOf(v)); }
/** * Returns the cumulative frequency of values less than or equal to v. * <p> * Returns 0 if v is not comparable to the values set.</p> * * @param v the value to lookup * @return the proportion of values equal to v */ public long getCumFreq(long v) { return getCumFreq(Long.valueOf(v)); }
/** * Returns the cumulative frequency of values less than or equal to v. * <p> * Returns 0 if v is not comparable to the values set.</p> * * @param v the value to lookup * @return the proportion of values equal to v */ public long getCumFreq(int v) { return getCumFreq(Long.valueOf(v)); }
/** * Returns the cumulative frequency of values less than or equal to v. * <p> * Returns 0 if v is not comparable to the values set.</p> * * @param v the value to lookup * @return the proportion of values equal to v */ public long getCumFreq(long v) { return getCumFreq(Long.valueOf(v)); }
public long getRowCumFreq(Comparable<?> rowValue){ if(rowMargin.getSumFreq()==0){ return 0; } if(rowValue instanceof Integer){ return rowMargin.getCumFreq((((Integer)rowValue).longValue())); } return rowMargin.getCumFreq(rowValue); }
public long getColCumFreq(Comparable<?> colValue){ if(colMargin.getSumFreq()==0){ return 0; } if(colValue instanceof Integer){ return colMargin.getCumFreq((((Integer)colValue).longValue())); } return colMargin.getCumFreq(colValue); }
public double getRowCumPct(Comparable<?> rowValue){ final long sumFreq = rowMargin.getSumFreq(); if(sumFreq==0){ return Double.NaN; } return (double)rowMargin.getCumFreq(rowValue)/(double)sumFreq; }
public double getColCumPct(Comparable<?> colValue){ final long sumFreq = colMargin.getSumFreq(); if(sumFreq==0){ return Double.NaN; } return (double)colMargin.getCumFreq(colValue)/(double)sumFreq; }
/** * Returns the cumulative percentage of values less than or equal to v * (as a proportion between 0 and 1). * <p> * Returns <code>Double.NaN</code> if no values have been added. * Returns 0 if at least one value has been added, but v is not comparable * to the values set.</p> * * @param v the value to lookup * @return the proportion of values less than or equal to v */ public double getCumPct(Comparable<?> v) { final long sumFreq = getSumFreq(); if (sumFreq == 0) { return Double.NaN; } return (double) getCumFreq(v) / (double) sumFreq; }
/** * Returns the cumulative percentage of values less than or equal to v * (as a proportion between 0 and 1). * <p> * Returns <code>Double.NaN</code> if no values have been added. * Returns 0 if at least one value has been added, but v is not comparable * to the values set.</p> * * @param v the value to lookup * @return the proportion of values less than or equal to v */ public double getCumPct(Comparable<?> v) { final long sumFreq = getSumFreq(); if (sumFreq == 0) { return Double.NaN; } return (double) getCumFreq(v) / (double) sumFreq; }
map.put("value", value.longValue()); map.put("count", frequency.getCount(value)); map.put("cumFreq", frequency.getCumFreq(value)); map.put("cumPct", frequency.getCumPct(value)); map.put("pct", frequency.getPct(value));
public void summarize(double[] x, int[] y){ if(x.length!=y.length) throw new IllegalArgumentException("X and Y are of different lengths."); N = (double) x.length; Mean meanX = new Mean(); StandardDeviation sdX = new StandardDeviation(); PearsonCorrelation rxy = new PearsonCorrelation(); Frequency table = new Frequency(); for(int i=0;i<N;i++){ meanX.increment(x[i]); sdX.increment(x[i]); rxy.increment(x[i], (double)y[i]); table.addValue(y[i]); } //compute thresholds int nrow = table.getUniqueCount(); double[] freqDataY = new double[nrow]; double ntotal = table.getSumFreq(); for(int i=0;i<(nrow-1);i++){ freqDataY[i] = table.getCumFreq(i+1); thresholds[i] = norm.inverseCumulativeProbability(freqDataY[i]/ntotal); } thresholds[nrow-1] = 10;//set last threshold to a large number less than infinity }
public void summarize()throws DimensionMismatchException{ if(dataX.length!=dataY.length) throw new DimensionMismatchException(dataX.length, dataY.length); Frequency table = new Frequency(); meanX = new Mean(); sdX = new StandardDeviation(); rxy = new PearsonCorrelation(); for(int i=0;i<nrow;i++){ meanX.increment(dataX[i]); sdX.increment(dataX[i]); rxy.increment(dataX[i], (double)dataY[i]); table.addValue(dataY[i]); } //compute thresholds nrow = table.getUniqueCount(); freqDataY = new double[nrow]; double ntotal = table.getSumFreq(); for(int i=0;i<(nrow-1);i++){ freqDataY[i] = table.getCumFreq(i+1); alpha[i] = normal.inverseCumulativeProbability(freqDataY[i]/ntotal); } alpha[nrow-1] = 10;//set last threshold to a large number less than infinity }