org.apache.commons.math.stat
Class Frequency

java.lang.Object
  extended byorg.apache.commons.math.stat.Frequency
All Implemented Interfaces:
Serializable

public class Frequency
extends Object
implements Serializable

Maintains a frequency distribution.
Accepts int, long or string values, converting all to Strings and maintaining frequency counts.

Version:
$Revision: 1.10 $ $Date: 2003/11/19 03:28:23 $
See Also:
Serialized Form

Constructor Summary
Frequency()
          Default constructor.
Frequency(String name)
          Construct a frequency distribution with the given name.
 
Method Summary
 void addValue(int v)
          Adds 1 to the frequency count for v
 void addValue(long v)
          Adds 1 to the frequency count for v.
 void addValue(String v)
          Adds 1 to the frequency count for v
 void clear()
          Clears the frequency table
 long getCount(String v)
          Returns the number of values = v
 String getName()
          Getter for property name.
 double getPct(String v)
          Returns the percentage of values = v.
 long getSumFreq()
          Returns the sum of all frequencies
 void setName(String name)
          Setter for property name.
 String toString()
          Return a string representation of describing this frequency distribution.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Frequency

public Frequency()
Default constructor.


Frequency

public Frequency(String name)
Construct a frequency distribution with the given name.

Parameters:
name - the name for the new distribution.
Method Detail

toString

public String toString()
Return a string representation of describing this frequency distribution.

Returns:
a string representation.

addValue

public void addValue(String v)
Adds 1 to the frequency count for v

Parameters:
v - the value to add.

addValue

public void addValue(int v)
Adds 1 to the frequency count for v

Parameters:
v - the value to add.

addValue

public void addValue(long v)
Adds 1 to the frequency count for v.

Parameters:
v - the value to add.

getCount

public long getCount(String v)
Returns the number of values = v

Parameters:
v - the value to lookup.
Returns:
the absolute frequency of v.

getSumFreq

public long getSumFreq()
Returns the sum of all frequencies

Returns:
the aggregate frequency.

getPct

public double getPct(String v)
Returns the percentage of values = v.

Parameters:
v - the value to lookup.
Returns:
the relative frequency of v.

clear

public void clear()
Clears the frequency table


getName

public String getName()
Getter for property name.

Returns:
Value of property name.

setName

public void setName(String name)
Setter for property name.

Parameters:
name - New value of property name.


Copyright © 2003-2004 Apache Software Foundation. All Rights Reserved.