Package jsl.utilities.statistic
Class IntegerFrequency
- java.lang.Object
-
- jsl.utilities.statistic.IntegerFrequency
-
public class IntegerFrequency extends java.lang.Object
This class tabulates the frequency associated with the integers presented to it via the collect() method Every value presented is interpreted as an integer For every value presented a count is maintained. There could be space/time performance issues if the number of different values presented is large.This class can be useful for tabulating a discrete histogram over the values (integers) presented.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
IntegerFrequency.Cell
Holds the values and their counts
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.String
myName
protected Statistic
myStatistic
Collects statistical information
-
Constructor Summary
Constructors Constructor Description IntegerFrequency()
Can tabulate any integer valueIntegerFrequency(int lowerLimit, int upperLimit)
IntegerFrequency(int lowerLimit, int upperLimit, java.lang.String name)
IntegerFrequency(java.lang.String name)
Can tabulate any integer value
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
collect(double i)
void
collect(double[] array)
void
collect(int i)
Tabulates the count of the number of i's presented.void
collect(int[] intArray)
DEmpiricalCDF
createDEmpiricalCDF()
java.util.List<IntegerFrequency.Cell>
getCellList()
Returns a copy of the cells in a list ordered by the value of each cell, 0th element is cell with smallest value, etcprotected java.util.SortedSet<IntegerFrequency.Cell>
getCells()
Returns a sorted set containing the cellsint
getCumulativeFrequency(int i)
Returns the cumulative frequency up to an including idouble
getCumulativeProportion(int i)
Returns the cumulative proportion up to an including iint[]
getFrequencies()
Returns an array of size getNumberOfCells() containing the frequencies by valueint[]
getFrequencies(int[] x)
Interprets the elements of x[] as values and returns an array representing the frequency for each valueint
getFrequency(int x)
Returns the current frequency for the provided integerjava.lang.String
getName()
int
getNumberOfCells()
Returns the number of cells tabulatedint
getOverFlowCount()
The number of observations that fell past the last bin's upper limitdouble
getProportion(int x)
Gets the proportion of the observations that are equal to the supplied integerdouble[]
getProportions()
Returns an array of size getNumberOfCells() containing the proportion by valueStatistic
getStatistic()
int
getTotalCount()
The total count associated with the valuesint
getUnderFlowCount()
The number of observations that fell below the first bin's lower limitdouble[][]
getValueCumulativeProportions()
Returns a 2 by n array of value, cumulative proportion pairs where n = getNumberOfCells() row 0 is the values row 1 is the cumulative proportionsint[][]
getValueFrequencies()
Returns a n by 2 array of value, frequency pairs where n = getNummberOfCells()double[][]
getValueProportions()
Returns a 2 by n array of value, proportion pairs where n = getNumberOfCells() row 0 is the values row 1 is the proportionsint[]
getValues()
Returns an array of size getNumberOfCells() containing the values increasing by valuevoid
reset()
Resets the statistical collectionvoid
setName(java.lang.String name)
java.lang.String
toString()
-
-
-
Field Detail
-
myStatistic
protected Statistic myStatistic
Collects statistical information
-
myName
protected java.lang.String myName
-
-
Constructor Detail
-
IntegerFrequency
public IntegerFrequency()
Can tabulate any integer value
-
IntegerFrequency
public IntegerFrequency(java.lang.String name)
Can tabulate any integer value- Parameters:
name
- a name for the instance
-
IntegerFrequency
public IntegerFrequency(int lowerLimit, int upperLimit)
- Parameters:
lowerLimit
- the defined lower limit of the integers, values less than this are not tabulatedupperLimit
- the defined upper limit of the integers, values less than this are not tabulated
-
IntegerFrequency
public IntegerFrequency(int lowerLimit, int upperLimit, java.lang.String name)
- Parameters:
lowerLimit
- the defined lower limit of the integers, values less than this are not tabulatedupperLimit
- the defined upper limit of the integers, values less than this are not tabulatedname
- a name for the instance
-
-
Method Detail
-
getName
public final java.lang.String getName()
- Returns:
- the assigned name
-
setName
public final void setName(java.lang.String name)
- Parameters:
name
- the name to assign
-
collect
public final void collect(int[] intArray)
- Parameters:
intArray
- collects on the values in the array
-
collect
public void collect(int i)
Tabulates the count of the number of i's presented.- Parameters:
i
- the presented integer
-
collect
public void collect(double i)
- Parameters:
i
- casts the double down to an int
-
collect
public void collect(double[] array)
- Parameters:
array
- casts the doubles to ints
-
reset
public void reset()
Resets the statistical collection
-
getUnderFlowCount
public final int getUnderFlowCount()
The number of observations that fell below the first bin's lower limit- Returns:
- number of observations that fell below the first bin's lower limit
-
getOverFlowCount
public final int getOverFlowCount()
The number of observations that fell past the last bin's upper limit- Returns:
- number of observations that fell past the last bin's upper limit
-
getValues
public final int[] getValues()
Returns an array of size getNumberOfCells() containing the values increasing by value- Returns:
- the array of values observed or an empty array
-
getFrequencies
public final int[] getFrequencies()
Returns an array of size getNumberOfCells() containing the frequencies by value- Returns:
- the array of frequencies observed or an empty array
-
getProportions
public final double[] getProportions()
Returns an array of size getNumberOfCells() containing the proportion by value- Returns:
- the array of proportions observed or an empty array
-
getCumulativeFrequency
public final int getCumulativeFrequency(int i)
Returns the cumulative frequency up to an including i- Parameters:
i
- the integer for the desired frequency- Returns:
- the cumulative frequency
-
getCumulativeProportion
public final double getCumulativeProportion(int i)
Returns the cumulative proportion up to an including i- Parameters:
i
- the integer for the desired proportion- Returns:
- the cumulative proportion
-
getValueFrequencies
public final int[][] getValueFrequencies()
Returns a n by 2 array of value, frequency pairs where n = getNummberOfCells()- Returns:
- the array or an empty array
-
getValueProportions
public final double[][] getValueProportions()
Returns a 2 by n array of value, proportion pairs where n = getNumberOfCells() row 0 is the values row 1 is the proportions- Returns:
- the array or an empty array
-
getValueCumulativeProportions
public final double[][] getValueCumulativeProportions()
Returns a 2 by n array of value, cumulative proportion pairs where n = getNumberOfCells() row 0 is the values row 1 is the cumulative proportions- Returns:
- the array or an empty array
-
getNumberOfCells
public final int getNumberOfCells()
Returns the number of cells tabulated- Returns:
- the number of cells tabulated
-
getTotalCount
public final int getTotalCount()
The total count associated with the values- Returns:
- total count associated with the values
-
getFrequency
public final int getFrequency(int x)
Returns the current frequency for the provided integer- Parameters:
x
- the provided integer- Returns:
- the frequency
-
getProportion
public final double getProportion(int x)
Gets the proportion of the observations that are equal to the supplied integer- Parameters:
x
- the integer- Returns:
- the proportion
-
getFrequencies
public final int[] getFrequencies(int[] x)
Interprets the elements of x[] as values and returns an array representing the frequency for each value- Parameters:
x
- the values for the frequencies- Returns:
- the returned frequencies
-
getCellList
public final java.util.List<IntegerFrequency.Cell> getCellList()
Returns a copy of the cells in a list ordered by the value of each cell, 0th element is cell with smallest value, etc- Returns:
- the list
-
createDEmpiricalCDF
public DEmpiricalCDF createDEmpiricalCDF()
- Returns:
- a DEmpirical based on the frequencies
-
getCells
protected final java.util.SortedSet<IntegerFrequency.Cell> getCells()
Returns a sorted set containing the cells- Returns:
- the sorted set of cells
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
getStatistic
public final Statistic getStatistic()
- Returns:
- a Statistic over the observed integers
-
-