/** * Returns the number of values equal to v. * * @param v the value to lookup. * @return the frequency of v. */ public long getCount(char v) { return getCount(Character.valueOf(v)); }
/** * Returns the number of values equal to v. * * @param v the value to lookup. * @return the frequency of v. */ public long getCount(int v) { return getCount(Long.valueOf(v)); }
/** * Returns the number of values equal to v. * * @param v the value to lookup. * @return the frequency of v. */ public long getCount(long v) { return getCount(Long.valueOf(v)); }
/** * Returns the number of values equal to v. * Returns 0 if the value is not comparable. * * @param v the value to lookup. * @return the frequency of v. */ public long getCount(Comparable<?> v) { if (v instanceof Integer) { return getCount(((Integer) v).longValue()); } long result = 0; try { Long count = freqTable.get(v); if (count != null) { result = count.longValue(); } } catch (ClassCastException ex) { // NOPMD // ignore and return 0 -- ClassCastException will be thrown if value is not comparable } return result; }
/** * Returns the percentage of values that are 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 equal to v */ public double getPct(Comparable<?> v) { final long sumFreq = getSumFreq(); if (sumFreq == 0) { return Double.NaN; } return (double) getCount(v) / (double) sumFreq; }
/** * Return a string representation of this frequency distribution. * * @return a string representation. */ @Override public String toString() { NumberFormat nf = NumberFormat.getPercentInstance(); StringBuilder outBuffer = new StringBuilder(); outBuffer.append("Value \t Freq. \t Pct. \t Cum Pct. \n"); Iterator<Comparable<?>> iter = freqTable.keySet().iterator(); while (iter.hasNext()) { Comparable<?> value = iter.next(); outBuffer.append(value); outBuffer.append('\t'); outBuffer.append(getCount(value)); outBuffer.append('\t'); outBuffer.append(nf.format(getPct(value))); outBuffer.append('\t'); outBuffer.append(nf.format(getCumPct(value))); outBuffer.append('\n'); } return outBuffer.toString(); }
Comparable<?> nextValue = values.next(); if (c.compare(v, nextValue) > 0) { result += getCount(nextValue); } else { return result;
/** * For computing common odds ratio * * @return */ public double wrongFrequency(){ Double wrong = 0.0; return columns.getCount(wrong); }
/** * For computing common odds ratio * * @return */ public double rightFrequecy(){ Double right = 1.0; return columns.getCount(right); }
public double freqAt(Double score){ return columns.getCount(score); }
public long getRowCount(Comparable<?> rowValue){ if(rowValue instanceof Integer){ return rowMargin.getCount(((Integer) rowValue).longValue()); } long result = 0; try{ result = rowMargin.getCount(rowValue); }catch(ClassCastException ex){ //ignore and return 0 -- ClassCastException will be thrown if rho is not comparable } return result; }
public long getColCount(Comparable<?> colValue){ if(colValue instanceof Integer){ return colMargin.getCount(((Integer) colValue).longValue()); } long result = 0; try{ result = colMargin.getCount(colValue); }catch(ClassCastException ex){ //ignore and return 0 -- ClassCastException will be thrown if rho is not comparable } return result; }
/** * Returns the number of values equal to v. * * @param v the value to lookup. * @return the frequency of v. */ public long getCount(int v) { return getCount(Long.valueOf(v)); }
/** * Returns the number of values equal to v. * * @param v the value to lookup. * @return the frequency of v. */ public long getCount(long v) { return getCount(Long.valueOf(v)); }
/** * Returns the number of values equal to v. * * @param v the value to lookup. * @return the frequency of v. */ public long getCount(char v) { return getCount(Character.valueOf(v)); }
/** * Returns the number of values equal to v. * * @param v the value to lookup. * @return the frequency of v. */ public long getCount(int v) { return getCount(Long.valueOf(v)); }
/** * Returns the number of values equal to v. * * @param v the value to lookup. * @return the frequency of v. */ public long getCount(char v) { return getCount(Character.valueOf(v)); }
/** * Returns the number of values equal to v. * * @param v the value to lookup. * @return the frequency of v. */ public long getCount(long v) { return getCount(Long.valueOf(v)); }
@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(); }
public ReflexValue frequency_count(List<ReflexValue> params) { if (params.size() != 2) { throw new ReflexException(-1, "frequency_count needs one frequency parameter and one value parameter"); } Frequency f = params.get(0).asObjectOfType(Frequency.class); double value = params.get(1).asDouble(); return new ReflexValue(f.getCount(value)); }