org.opensha.commons.data.function
Class HistogramFunction

java.lang.Object
  extended by org.opensha.commons.data.function.AbstractXY_DataSet
      extended by org.opensha.commons.data.function.AbstractDiscretizedFunc
          extended by org.opensha.commons.data.function.EvenlyDiscretizedFunc
              extended by org.opensha.commons.data.function.HistogramFunction
All Implemented Interfaces:
Serializable, Iterable<Point2D>, DiscretizedFunc, XY_DataSet, Named, PlotElement, XMLSaveable

public class HistogramFunction
extends EvenlyDiscretizedFunc

This class sets the tolerance high so that it can be used to construct histograms. It also provides some methods relevant to a histogram.

Author:
field
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.opensha.commons.data.function.EvenlyDiscretizedFunc
C, D, delta, first, maxX, minX, num, points
 
Fields inherited from class org.opensha.commons.data.function.AbstractDiscretizedFunc
tolerance, XML_METADATA_NAME, XML_METADATA_POINT_NAME, XML_METADATA_POINTS_NAME
 
Fields inherited from class org.opensha.commons.data.function.AbstractXY_DataSet
info, name, xAxisName, yAxisName
 
Constructor Summary
HistogramFunction(double min, double max, int num)
           
HistogramFunction(double min, int num, double delta)
           
 
Method Summary
 double computeCOV()
           
 double computeMean()
           
 double computeStdDev()
           
static HistogramFunction fromData(double[] data, double minBin, int num, double delta)
           
 HistogramFunction getCumulativeDistFunction()
          This returns the cumulative distribution function (total number less than and equal to each x-axis value)
 double getMode()
          This returns the x-axis value corresponding to the maximum y-axis value
static List<HistogramFunction> getStackedHists(List<HistogramFunction> hists, boolean normalize)
          This returns stacked histograms for display.
static void main(String[] args)
           
 void normalizeBySumOfY_Vals()
          This normalized the function so that the sum of Y valaues is 1.0
 
Methods inherited from class org.opensha.commons.data.function.EvenlyDiscretizedFunc
add, add, areAllXValuesInteger, clear, deepClone, equalXAndYValues, equalXValues, get, getAllInterpolatedX, getClosestXIndex, getClosestY, getDelta, getFirstInterpolatedX_afterXindex, getFirstInterpolatedX_inLogXLogYDomain, getFirstInterpolatedX, getIndex, getInterpolatedY_inLogXLogYDomain, getInterpolatedY_inLogYDomain, getInterpolatedY, getMaxX, getMaxY, getMetadataString, getMinX, getMinY, getNum, getPointsIterator, getX, getXIndex, getXindexForMaxY, getY, getY, hasPoint, hasPoint, set, set, set, set, set, toString, withinTolerance
 
Methods inherited from class org.opensha.commons.data.function.AbstractDiscretizedFunc
calcSumOfY_Vals, equals, fromXMLMetadata, getTolerance, loadFuncFromSimpleFile, loadFuncFromSimpleFile, scale, setTolerance, toXMLMetadata, toXMLMetadata, writeSimpleFuncFile, writeSimpleFuncFile
 
Methods inherited from class org.opensha.commons.data.function.AbstractXY_DataSet
getClosestX, getDatasetsToPlot, getInfo, getName, getPlotNumColorList, getXAxisName, getXValuesIterator, getYAxisName, getYValuesIterator, iterator, setInfo, setName, setXAxisName, setYAxisName, xValues, yValues
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.opensha.commons.data.function.XY_DataSet
getClosestX, getInfo, getXAxisName, getXValuesIterator, getYAxisName, getYValuesIterator, setInfo, setName, setXAxisName, setYAxisName, xValues, yValues
 
Methods inherited from interface org.opensha.commons.gui.plot.PlotElement
getDatasetsToPlot, getPlotNumColorList
 
Methods inherited from interface org.opensha.commons.data.Named
getName
 
Methods inherited from interface java.lang.Iterable
iterator
 

Constructor Detail

HistogramFunction

public HistogramFunction(double min,
                         int num,
                         double delta)
Parameters:
min -
num -
delta -

HistogramFunction

public HistogramFunction(double min,
                         double max,
                         int num)
Parameters:
min -
max -
num -
Method Detail

normalizeBySumOfY_Vals

public void normalizeBySumOfY_Vals()
This normalized the function so that the sum of Y valaues is 1.0


getCumulativeDistFunction

public HistogramFunction getCumulativeDistFunction()
This returns the cumulative distribution function (total number less than and equal to each x-axis value)

Returns:

getMode

public double getMode()
This returns the x-axis value corresponding to the maximum y-axis value

Returns:

computeMean

public double computeMean()

computeStdDev

public double computeStdDev()

computeCOV

public double computeCOV()

fromData

public static HistogramFunction fromData(double[] data,
                                         double minBin,
                                         int num,
                                         double delta)

getStackedHists

public static List<HistogramFunction> getStackedHists(List<HistogramFunction> hists,
                                                      boolean normalize)
This returns stacked histograms for display. Histograms will be stacked in the order that they are passed in, with the last one on top, and must all have the same x values.

Parameters:
hists -
normalize -
Returns:

main

public static void main(String[] args)