Package adams.data.statistics
Class ArrayHistogram<T extends Number>
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.core.logging.CustomLoggingLevelObject
-
- adams.core.option.AbstractOptionHandler
-
- adams.data.statistics.AbstractArrayStatistic<T>
-
- adams.data.statistics.ArrayHistogram<T>
-
- Type Parameters:
T- the data to process
- All Implemented Interfaces:
AdditionalInformationHandler,Destroyable,GlobalInfoSupporter,LoggingLevelHandler,LoggingSupporter,OptionHandler,ShallowCopySupporter<AbstractArrayStatistic>,SizeOfHandler,TechnicalInformationHandler,EqualLengthArrayStatistic,Serializable
public class ArrayHistogram<T extends Number> extends AbstractArrayStatistic<T> implements EqualLengthArrayStatistic, TechnicalInformationHandler
Generates a histogram from the given array.
The formulas for the various width/#bin calculations can be found here:
WikiPedia (2010). Histogram.
@misc{WikiPedia2010, author = {WikiPedia}, title = {Histogram}, year = {2010}, HTTP = {http://en.wikipedia.org/wiki/Histogram} }
-logging-level <OFF|SEVERE|WARNING|INFO|CONFIG|FINE|FINER|FINEST> (property: loggingLevel) The logging level for outputting errors and debugging output. default: WARNING
-bin-calc <MANUAL|FREQUENCY|DENSITY|STURGES|SCOTT|SQRT> (property: binCalculation) Defines how the number of bins are calculated. default: MANUAL
-num-bins <int> (property: numBins) The number of bins to use in case of manual bin calculation. default: 50 minimum: 1
-bin-width <double> (property: binWidth) The bin width to use for some of the calculations. default: 1.0 minimum: 1.0E-5
-normalize <boolean> (property: normalize) If set to true the data gets normalized first before the histogram is calculated. default: false
-use-fixed-min-max <boolean> (property: useFixedMinMax) If enabled, then the user-specified min/max values are used for the bin calculation rather than the min/max from the data (allows comparison of histograms when generating histograms over a range of arrays). default: false
-manual-min <double> (property: manualMin) The minimum to use when using manual binning with user-supplied min/max enabled. default: 0.0
-manual-max <double> (property: manualMax) The maximum to use when using manual binning with user-supplied max/max enabled. default: 1.0
-display-ranges <boolean> (property: displayRanges) If enabled, the bins get description according to their range, rather than a simple index. default: false
-num-decimals <int> (property: numDecimals) The number of decimals to show in the bin descriptions. default: 3 minimum: 0
- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classArrayHistogram.BinCalculationEnumeration for the bin calculation.-
Nested classes/interfaces inherited from class adams.data.statistics.AbstractArrayStatistic
AbstractArrayStatistic.StatisticContainer<T extends Serializable>
-
-
Field Summary
Fields Modifier and Type Field Description protected ArrayHistogram.BinCalculationm_BinCalculationhow to calculate the number of bins.protected doublem_BinWidththe bin width - used for some calculations.protected booleanm_DisplayRangeswhether to use the ranges as bin description.protected doublem_ManualMaxthe manual maximum.protected doublem_ManualMinthe manual minimum.protected booleanm_Normalizewhether to normalize the data.protected intm_NumBinsthe number of bins in case of manual bin calculation.protected intm_NumDecimalsthe number of decimals to show.protected booleanm_UseFixedMinMaxwhether to use fixed min/max for manual bin calculation.static StringMETADATA_BINSthe key for the bins.static StringMETADATA_BINWIDTHthe key for the bin width in the meta-data.static StringMETADATA_BINXthe key for the x-values for all the bins in the meta-data.static StringMETADATA_MAXIMUMthe key for the maximum used in the meta-data.static StringMETADATA_MINIMUMthe key for the minimum used in the meta-data.static StringMETADATA_NUMBINSthe key for the number of bins in the meta-data.-
Fields inherited from class adams.data.statistics.AbstractArrayStatistic
m_Data
-
Fields inherited from class adams.core.option.AbstractOptionHandler
m_OptionManager
-
Fields inherited from class adams.core.logging.LoggingObject
m_Logger, m_LoggingIsEnabled, m_LoggingLevel
-
-
Constructor Summary
Constructors Constructor Description ArrayHistogram()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringbinCalculationTipText()Returns the tip text for this property.StringbinWidthTipText()Returns the tip text for this property.protected double[]calcBinStarts(Number[] array, double width, int numBins, double min, double max)Calculates the starting values for the bins.protected doublecalcBinWidth(Number[] array)Calculates the bin width to use.protected intcalcNumBins(Number[] array, double width)Calculates the number of bins to use.voiddefineOptions()Adds options to the internal list of options.StringdisplayRangesTipText()Returns the tip text for this property.protected AbstractArrayStatistic.StatisticContainerdoCalculate()Generates the actual result.ArrayHistogram.BinCalculationgetBinCalculation()Returns how the number of bins is calculated.doublegetBinWidth()Returns the bin width in use (for some calculations).booleangetDisplayRanges()Returns whether to use the bin ranges as their description rather than a simple index.intgetLength()Returns the length of the stored arrays.doublegetManualMax()Returns the maximum to use when using manual binning with user-supplied max/max enabled.doublegetManualMin()Returns the minimum to use when using manual binning with user-supplied min/max enabled.intgetMax()Returns the maximum number of arrays that need to be presentintgetMin()Returns the minimum number of arrays that need to be presentbooleangetNormalize()Returns whether to normalize the data before generating the histogram.intgetNumBins()Returns the number of bins to use in manual calculation.intgetNumDecimals()Returns the number of decimals to show in the bin description.TechnicalInformationgetTechnicalInformation()Returns an instance of a TechnicalInformation object, containing detailed information about the technical background of this class, e.g., paper reference or book this class is based on.booleangetUseFixedMinMax()Returns whether to use user-supplied min/max for bin calculation rather than obtain min/max from data.StringglobalInfo()Returns a string describing the object.StringmanualMaxTipText()Returns the tip text for this property.StringmanualMinTipText()Returns the tip text for this property.StringnormalizeTipText()Returns the tip text for this property.StringnumBinsTipText()Returns the tip text for this property.StringnumDecimalsTipText()Returns the tip text for this property.voidsetBinCalculation(ArrayHistogram.BinCalculation value)Sets how the number of bins is calculated.voidsetBinWidth(double value)Sets the bin width to use (for some calculations).voidsetDisplayRanges(boolean value)Sets whether to use the bin ranges as their description rather than a simple index.voidsetManualMax(double value)Sets the maximum to use when using manual binning with user-supplied max/max enabled.voidsetManualMin(double value)Sets the minimum to use when using manual binning with user-supplied min/max enabled.voidsetNormalize(boolean value)Sets whether to normalize the data before generating the histogram.voidsetNumBins(int value)Sets the number of bins to use in manual calculation.voidsetNumDecimals(int value)Sets the number of decimals to show in the bin description.voidsetUseFixedMinMax(boolean value)Sets whether to use user-supplied min/max for bin calculation rather than obtain min/max from data.StringuseFixedMinMaxTipText()Returns the tip text for this property.-
Methods inherited from class adams.data.statistics.AbstractArrayStatistic
add, calculate, check, checkEqualLength, clear, forCommandLine, forName, get, getAdditionalInformation, getStatistics, initialize, remove, set, shallowCopy, shallowCopy, size, toString
-
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, destroy, finishInit, getDefaultLoggingLevel, getOptionManager, loggingLevelTipText, newOptionManager, reset, setLoggingLevel, toCommandLine
-
Methods inherited from class adams.core.logging.LoggingObject
configureLogger, getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled, sizeOf
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface adams.core.logging.LoggingLevelHandler
getLoggingLevel
-
-
-
-
Field Detail
-
METADATA_NUMBINS
public static final String METADATA_NUMBINS
the key for the number of bins in the meta-data.- See Also:
- Constant Field Values
-
METADATA_BINWIDTH
public static final String METADATA_BINWIDTH
the key for the bin width in the meta-data.- See Also:
- Constant Field Values
-
METADATA_BINX
public static final String METADATA_BINX
the key for the x-values for all the bins in the meta-data.- See Also:
- Constant Field Values
-
METADATA_BINS
public static final String METADATA_BINS
the key for the bins.- See Also:
- Constant Field Values
-
METADATA_MINIMUM
public static final String METADATA_MINIMUM
the key for the minimum used in the meta-data.- See Also:
- Constant Field Values
-
METADATA_MAXIMUM
public static final String METADATA_MAXIMUM
the key for the maximum used in the meta-data.- See Also:
- Constant Field Values
-
m_BinCalculation
protected ArrayHistogram.BinCalculation m_BinCalculation
how to calculate the number of bins.
-
m_NumBins
protected int m_NumBins
the number of bins in case of manual bin calculation.
-
m_BinWidth
protected double m_BinWidth
the bin width - used for some calculations.
-
m_Normalize
protected boolean m_Normalize
whether to normalize the data.
-
m_UseFixedMinMax
protected boolean m_UseFixedMinMax
whether to use fixed min/max for manual bin calculation.
-
m_ManualMin
protected double m_ManualMin
the manual minimum.
-
m_ManualMax
protected double m_ManualMax
the manual maximum.
-
m_DisplayRanges
protected boolean m_DisplayRanges
whether to use the ranges as bin description.
-
m_NumDecimals
protected int m_NumDecimals
the number of decimals to show.
-
-
Method Detail
-
globalInfo
public String globalInfo()
Returns a string describing the object.- Specified by:
globalInfoin interfaceGlobalInfoSupporter- Specified by:
globalInfoin classAbstractOptionHandler- Returns:
- a description suitable for displaying in the gui
-
getTechnicalInformation
public TechnicalInformation getTechnicalInformation()
Returns an instance of a TechnicalInformation object, containing detailed information about the technical background of this class, e.g., paper reference or book this class is based on.- Specified by:
getTechnicalInformationin interfaceTechnicalInformationHandler- Returns:
- the technical information about this class
-
defineOptions
public void defineOptions()
Adds options to the internal list of options.- Specified by:
defineOptionsin interfaceOptionHandler- Overrides:
defineOptionsin classAbstractOptionHandler
-
setBinCalculation
public void setBinCalculation(ArrayHistogram.BinCalculation value)
Sets how the number of bins is calculated.- Parameters:
value- the bin calculation
-
getBinCalculation
public ArrayHistogram.BinCalculation getBinCalculation()
Returns how the number of bins is calculated.- Returns:
- the bin calculation
-
binCalculationTipText
public String binCalculationTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setNumBins
public void setNumBins(int value)
Sets the number of bins to use in manual calculation.- Parameters:
value- the number of bins
-
getNumBins
public int getNumBins()
Returns the number of bins to use in manual calculation.- Returns:
- the number of bins
-
numBinsTipText
public String numBinsTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setBinWidth
public void setBinWidth(double value)
Sets the bin width to use (for some calculations).- Parameters:
value- the bin width
-
getBinWidth
public double getBinWidth()
Returns the bin width in use (for some calculations).- Returns:
- the bin width
-
binWidthTipText
public String binWidthTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setNormalize
public void setNormalize(boolean value)
Sets whether to normalize the data before generating the histogram.- Parameters:
value- if true the data gets normalized first
-
getNormalize
public boolean getNormalize()
Returns whether to normalize the data before generating the histogram.- Returns:
- true if the data gets normalized first
-
normalizeTipText
public String normalizeTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setUseFixedMinMax
public void setUseFixedMinMax(boolean value)
Sets whether to use user-supplied min/max for bin calculation rather than obtain min/max from data.- Parameters:
value- true if to use user-supplied min/max
-
getUseFixedMinMax
public boolean getUseFixedMinMax()
Returns whether to use user-supplied min/max for bin calculation rather than obtain min/max from data.- Returns:
- true if to use user-supplied min/max
-
useFixedMinMaxTipText
public String useFixedMinMaxTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setManualMin
public void setManualMin(double value)
Sets the minimum to use when using manual binning with user-supplied min/max enabled.- Parameters:
value- the minimum
-
getManualMin
public double getManualMin()
Returns the minimum to use when using manual binning with user-supplied min/max enabled.- Returns:
- the minimum
-
manualMinTipText
public String manualMinTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setManualMax
public void setManualMax(double value)
Sets the maximum to use when using manual binning with user-supplied max/max enabled.- Parameters:
value- the maximum
-
getManualMax
public double getManualMax()
Returns the maximum to use when using manual binning with user-supplied max/max enabled.- Returns:
- the maximum
-
manualMaxTipText
public String manualMaxTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setDisplayRanges
public void setDisplayRanges(boolean value)
Sets whether to use the bin ranges as their description rather than a simple index.- Parameters:
value- true if to display the ranges
-
getDisplayRanges
public boolean getDisplayRanges()
Returns whether to use the bin ranges as their description rather than a simple index.- Returns:
- true if to display the ranges
-
displayRangesTipText
public String displayRangesTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setNumDecimals
public void setNumDecimals(int value)
Sets the number of decimals to show in the bin description.- Parameters:
value- the number of decimals
-
getNumDecimals
public int getNumDecimals()
Returns the number of decimals to show in the bin description.- Returns:
- the number of decimals
-
numDecimalsTipText
public String numDecimalsTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
getLength
public int getLength()
Returns the length of the stored arrays.- Specified by:
getLengthin interfaceEqualLengthArrayStatistic- Returns:
- the length of the arrays, -1 if none stored
-
getMin
public int getMin()
Returns the minimum number of arrays that need to be present. -1 for unbounded.- Specified by:
getMinin classAbstractArrayStatistic<T extends Number>- Returns:
- the minimum number, -1 for unbounded
-
getMax
public int getMax()
Returns the maximum number of arrays that need to be present. -1 for unbounded.- Specified by:
getMaxin classAbstractArrayStatistic<T extends Number>- Returns:
- the maximum number, -1 for unbounded
-
calcBinWidth
protected double calcBinWidth(Number[] array)
- Parameters:
array- the array to work on- Returns:
- the width of the bins, -1 if not necessary
-
calcNumBins
protected int calcNumBins(Number[] array, double width)
Calculates the number of bins to use.
Formulas taken from here:- Parameters:
array- the array to work onwidth- the width of the bins- Returns:
- the number of bins to use
-
calcBinStarts
protected double[] calcBinStarts(Number[] array, double width, int numBins, double min, double max)
Calculates the starting values for the bins.- Parameters:
array- the array to work onwidth- the width of the binsnumBins- the number of bins to usemin- the minimum valuemax- the maximum value- Returns:
- the starting values of the bins (+ one after)
-
doCalculate
protected AbstractArrayStatistic.StatisticContainer doCalculate()
Generates the actual result.- Specified by:
doCalculatein classAbstractArrayStatistic<T extends Number>- Returns:
- the generated result
-
-