public class PamHistogram extends TimedObservable
As well as basic histogramming functions, functions exist for downscaling the histogram data and extracting parameters such as variance, skew, etc.
Constructor and Description |
---|
PamHistogram(double minVal,
double maxVal,
int nBins)
Constructs a histogram object with minVal
and maxVal, specifying the low edge of the lowest bin and
the high edge of the highest bin respectively.
|
PamHistogram(double minVal,
double maxVal,
int nBins,
boolean binCentres)
Constructs a histogram object where minVal and maxVal specify the centres of the lower and
upper bins (true) or the lower edge of the lowest bin and the upper edge of the highest bin (false)
|
Modifier and Type | Method and Description |
---|---|
void |
addData(double newData)
Add a single point of data to the histogram
but don't notify observers
|
void |
addData(double newData,
boolean notify)
Add a single unit value to the histogram
and optionally notify all observers
|
void |
addData(double newData,
double weight)
Add weighted data to the histogram
|
void |
clear()
Clear all histogram contents
|
int |
getBin(double dataValue)
Work out which bin a particular value will call into.
|
double |
getBinCentre(int iBin) |
double[] |
getData()
GEt the histograms data array.
|
double |
getHiBin() |
double |
getKurtosis()
Get the kurtosis of the distribution (fourth moment)
taking the definition from Numerical recipes in C p 612
|
double |
getLoBin() |
double |
getMaxContent()
Get max bin content, including lo and high fields.
|
double |
getMaxVal()
Get the maximum range value of the histogram
|
double |
getMean()
Calculate the mean of the histogram data
|
double |
getMinVal()
Get the minimum range value of the histogram
|
double |
getMode()
Get's the modal value of the distribution
|
java.lang.String |
getName() |
int |
getNBins()
Get the number of histogram bins
|
double |
getScaleMaxVal()
Where to plot to if bin centres were specified.
|
double |
getScaleMinVal()
Where to plot from if bin centres were specified.
|
double |
getSkew()
Get the skewness of the distribution (third moment)
|
double |
getSTD()
Return the standard deviation of the histogram data
|
double |
getStep()
Step size between sucessive bins.
|
double |
getTotalContent()
Get's the sum total of all bin contents, excluding lo and high bins
|
double |
getVariance()
Return the variance of the histogram data
|
boolean |
isBinCentres() |
void |
scaleData(double scaleFactor)
Scale the data in the histogram by the given factor
|
void |
setBinCentres(boolean binCentres) |
void |
setName(java.lang.String name) |
void |
setRange(double minVal,
double maxVal,
int nBins)
Sets the histogram bin ranges.
|
java.lang.String |
toString() |
getDelay, notifyObservers, notifyObservers, notifyObservers, setDelay
public PamHistogram(double minVal, double maxVal, int nBins)
minVal
- min ValuemaxVal
- max ValuenBins
- number of binspublic PamHistogram(double minVal, double maxVal, int nBins, boolean binCentres)
minVal
- minimum value (low edge or low bin centre, depending on binCentres parameter)maxVal
- maximum value (high edge or high bin centre, depending on binCentres parameter)nBins
- total number of binsbinCentres
- specifies whether the minVal and maxVal specify the centres of the lower and
upper bins (true) or the lower edge of the lowest bin and the upper edge of the highest bin (false)public void setRange(double minVal, double maxVal, int nBins)
Note that calling this function will reset the histogram data.
minVal
- minimum value (low edge or low bin centre, depending on binCentres parameter)maxVal
- maximum value (high edge or high bin centre, depending on binCentres parameter)nBins
- total number of binspublic int getBin(double dataValue)
dataValue
- public double getBinCentre(int iBin)
public void addData(double newData, boolean notify)
newData
- value of the new datapublic void addData(double newData)
newData
- new data pointpublic void addData(double newData, double weight)
newData
- value of the dataweight
- weight to applypublic void clear()
public void scaleData(double scaleFactor)
This is used in various parts of PAMGUARD which wish to keep a decaying average distribution - every few seconds the data are halved (or some such) so that all data are represented, but recent data will carry more weight in the distributions.
scaleFactor
- FActor to scale data by (generally < 1)public double getMaxContent()
public double getMean()
public double getSTD()
public double getVariance()
public double getSkew()
public double getKurtosis()
public double getMode()
public double getTotalContent()
public double[] getData()
public double getMaxVal()
public double getMinVal()
public double getScaleMinVal()
public double getScaleMaxVal()
public int getNBins()
public double getStep()
public java.lang.String getName()
public void setName(java.lang.String name)
public java.lang.String toString()
toString
in class java.lang.Object
public double getHiBin()
public double getLoBin()
public boolean isBinCentres()
public void setBinCentres(boolean binCentres)