|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectpapaya.Frequency
public class Frequency
Class for getting the frequency distribution, cumulative frequency distribution, and other
distribution-related parameters of a given array of
Frequency freq= new Frequency(dataArray, minimumVal,maximumVal,widthOfEachBin);
Once initialized, it stores 3 things:
getFrequency()
).
A number of different methods are available for computing other distribution-related parameters (e.g. the relative frequency distribution, the cumulative frequency distribution, etc).
See the FrequencyExample in the examples folder for an example.
Constructor Summary | |
---|---|
Frequency(float[] _inputDat,
float _minVal,
float _maxVal,
float _binWidth)
Initialize the class by setting the minimum value, maximum value, and the bin width. |
|
Frequency(int[] _inputDat,
int _minVal,
int _maxVal,
int _binWidth)
Initialize the class by setting the minimum value, maximum value, and the bin width. |
Method Summary | |
---|---|
float[] |
compCumFrequency()
Computes the cumulative frequency of the data. |
float[] |
compRelCumFrequency()
Computes the cumulative relative frequency of the data. |
float[] |
compRelCumFrequencyPct()
Computes the cumulative frequency of the data as a percentage. |
float[] |
compRelFrequency()
Computes the fraction of the total data that's in each bin. |
float[] |
compRelFrequencyPct()
Computes the percents of the total data that's in each bin. |
float[] |
getFrequency()
Returns the pre-computed frequency array. |
int |
getLength()
returns the length of the dataset. |
int |
getNumBins()
Returns the number of bins. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Frequency(float[] _inputDat, float _minVal, float _maxVal, float _binWidth)
getFrequency()
function.
How is the number of bins computed?
Like this:
bins = floor[ (max - min) / binWidth ] +1
,
as opposed to ceil[ (max - min) / binWidth ]
.
Why? The latter algorithm is problematic when [ (max - min) / binWidth ]
is a whole number.
E.g. let min = 0.0, max = 100.0, and binWidth = 10.0. We get 10 bins with
What element goes into what bin?
Let value = data[i];
value
will go into bin number floor( (_inputDat[i]-_minVal)/_binWidth );
_inputDat
- the input data_minVal
- the minimum value in the array_maxVal
- the maximum value in the array_binWidth
- the width of each of the binspublic Frequency(int[] _inputDat, int _minVal, int _maxVal, int _binWidth)
getFrequency()
function.
See Frequency(float[] _inputDat, float _minVal, float _maxVal, float _binWidth)
for
more details.
Method Detail |
---|
public float[] compRelFrequency()
public float[] compRelFrequencyPct()
public float[] compCumFrequency()
public float[] compRelCumFrequency()
compCumFrequency()
) by
the number of elements in the data array.
public float[] compRelCumFrequencyPct()
compCumFrequency()
) by
the number of elements in the data array x 100%.
public float[] getFrequency()
public int getNumBins()
public int getLength()
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |