|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.commons.math.stat.Frequency
Maintains a frequency distribution.
Accepts int, long, char or Object values. New values added must be comparable to those that have been added, otherwise the add method will throw an IllegalArgumentException.
Integer values (int, long, Integer, Long) are not distinguished by type --
i.e. addValue(new Long(2)), addValue(2), addValue(2l)
all have
the same effect (similarly for arguments to getCount,
etc.).
The values are ordered using the default (natural order), unless a
Comparator
is supplied in the constructor.
Field Summary | |
(package private) static long |
serialVersionUID
Serializable version identifier |
Constructor Summary | |
Frequency()
Default constructor. |
|
Frequency(Comparator comparator)
Constructor allowing values Comparator to be specified. |
Method Summary | |
void |
addValue(char v)
Adds 1 to the frequency count for v. |
void |
addValue(int v)
Adds 1 to the frequency count for v. |
void |
addValue(Integer v)
Adds 1 to the frequency count for v. |
void |
addValue(long v)
Adds 1 to the frequency count for v. |
void |
addValue(Object v)
Adds 1 to the frequency count for v. |
void |
clear()
Clears the frequency table |
long |
getCount(char v)
Returns the number of values = v. |
long |
getCount(int v)
Returns the number of values = v. |
long |
getCount(long v)
Returns the number of values = v. |
long |
getCount(Object v)
Returns the number of values = v. |
long |
getCumFreq(char v)
Returns the cumulative frequency of values less than or equal to v. |
long |
getCumFreq(int v)
Returns the cumulative frequency of values less than or equal to v. |
long |
getCumFreq(long v)
Returns the cumulative frequency of values less than or equal to v. |
long |
getCumFreq(Object v)
Returns the cumulative frequency of values less than or equal to v. |
double |
getCumPct(char v)
Returns the cumulative percentage of values less than or equal to v (as a proportion between 0 and 1). |
double |
getCumPct(int v)
Returns the cumulative percentage of values less than or equal to v (as a proportion between 0 and 1). |
double |
getCumPct(long v)
Returns the cumulative percentage of values less than or equal to v (as a proportion between 0 and 1). |
double |
getCumPct(Object v)
Returns the cumulative percentage of values less than or equal to v (as a proportion between 0 and 1). |
double |
getPct(char v)
Returns the percentage of values that are equal to v (as a proportion between 0 and 1). |
double |
getPct(int v)
Returns the percentage of values that are equal to v (as a proportion between 0 and 1). |
double |
getPct(long v)
Returns the percentage of values that are equal to v (as a proportion between 0 and 1). |
double |
getPct(Object v)
Returns the percentage of values that are equal to v (as a proportion between 0 and 1). |
long |
getSumFreq()
Returns the sum of all frequencies. |
String |
toString()
Return a string representation of this frequency distribution. |
Iterator |
valuesIterator()
Returns an Iterator over the set of values that have been added. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
static final long serialVersionUID
Constructor Detail |
public Frequency()
public Frequency(Comparator comparator)
comparator
- Comparator used to order valuesMethod Detail |
public String toString()
public void addValue(Object v)
v
- the value to add.
IllegalArgumentException
- if v
is not comparable.public void addValue(int v)
v
- the value to add.public void addValue(Integer v)
v
- the value to add.public void addValue(long v)
v
- the value to add.public void addValue(char v)
v
- the value to add.public void clear()
public Iterator valuesIterator()
If added values are itegral (i.e., integers, longs, Integers, or Longs), they are converted to Longs when they are added, so the objects returned by the Iterator will in this case be Longs.
public long getSumFreq()
public long getCount(Object v)
v
- the value to lookup.
public long getCount(int v)
v
- the value to lookup.
public long getCount(long v)
v
- the value to lookup.
public long getCount(char v)
v
- the value to lookup.
public double getPct(Object v)
Returns Double.NaN
if no values have been added.
v
- the value to lookup
public double getPct(int v)
v
- the value to lookup
public double getPct(long v)
v
- the value to lookup
public double getPct(char v)
v
- the value to lookup
public long getCumFreq(Object v)
Returns 0 if v is not comparable to the values set.
v
- the value to lookup.
public long getCumFreq(int v)
Returns 0 if v is not comparable to the values set.
v
- the value to lookup
public long getCumFreq(long v)
Returns 0 if v is not comparable to the values set.
v
- the value to lookup
public long getCumFreq(char v)
Returns 0 if v is not comparable to the values set.
v
- the value to lookup
public double getCumPct(Object v)
Returns Double.NaN
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.
v
- the value to lookup
public double getCumPct(int v)
Returns 0 if v is not comparable to the values set.
v
- the value to lookup
public double getCumPct(long v)
Returns 0 if v is not comparable to the values set.
v
- the value to lookup
public double getCumPct(char v)
Returns 0 if v is not comparable to the values set.
v
- the value to lookup
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |