lt.monarch.chart.spc.math
Class HistogramValuesCalculator

java.lang.Object
  extended by lt.monarch.chart.spc.math.ValuesCalculator
      extended by lt.monarch.chart.spc.math.HistogramValuesCalculator
Direct Known Subclasses:
CpkValuesCalculator

public class HistogramValuesCalculator
extends ValuesCalculator

Calculates values for histogram chart. Values are calculated using formulas: http://www.singleton-labs.com/doc/mcharts/guide/#guide/chart-types/4.5.1.html


Field Summary
Modifier and Type Field and Description
 
Fields inherited from class lt.monarch.chart.spc.math.ValuesCalculator
nullName
 
Constructor Summary
Constructor and Description
HistogramValuesCalculator()
           
 
Method Summary
Modifier and Type Method and Description
 int getCount(ChartDataModel dataModel)
          Calculates the number of values in the data model.
 ChartDataInfo getDataModel(ChartDataModel srcModel, java.util.List<BinCenter> binCenters, int bins, ChartDataModel dstModel)
          Calculates histogram data model.
 double getMean(ChartDataModel dataModel)
          Calculates the average value of the data.
 void getNormalDistributionModel(double from, double to, double step, double mean, double std, double scale, ChartDataModel dstModel)
          Fills normal distribution values to a data model, from specified interval and multiplies the calculated value by the scale parameter
 double getStdDev(ChartDataModel dataModel)
          Calculates standard deviation value from the data.
protected  void validateDataModel(ChartDataModel dataModel)
          Checks if histogram data satisfied the minimal requirements.
 
Methods inherited from class lt.monarch.chart.spc.math.ValuesCalculator
average, fill, fill, fillColumn, fillColumn, fillConstant, fillConstant, getAverage, getc4, getColumn, getd2, getd3, getD3, getD4, getDouble, getE, getF, getG, getH, isEmpty, isNconstant, validateDataModel, validateDataModel
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HistogramValuesCalculator

public HistogramValuesCalculator()
Method Detail

getMean

public double getMean(ChartDataModel dataModel)
               throws DataFormatException
Calculates the average value of the data.

Throws:
DataFormatException

getCount

public int getCount(ChartDataModel dataModel)
Calculates the number of values in the data model. Empty data values are ignored

Parameters:
dataModel -

getStdDev

public double getStdDev(ChartDataModel dataModel)
                 throws DataFormatException
Calculates standard deviation value from the data. The used equation: sqrt(sum((x_i - x_mean)^2)) / (n - 1).

Parameters:
dataModel -
Throws:
DataFormatException

getDataModel

public ChartDataInfo getDataModel(ChartDataModel srcModel,
                                  java.util.List<BinCenter> binCenters,
                                  int bins,
                                  ChartDataModel dstModel)
                           throws DataFormatException
Calculates histogram data model. Groups data into specified number bins and calculates the count of values which fall into the specific bin.

Parameters:
srcModel - input chart data model.
binCenters - the list of bins center values (return value).
bins - the number of bins the data to divide to.
dstModel - the resulting chart data model (return value).
Returns:
some additional information about calculated data: area size (data count * binWidth / bins), binWidth, actual values count in the source model.
Throws:
DataFormatException - if the input data are invalid.

getNormalDistributionModel

public void getNormalDistributionModel(double from,
                                       double to,
                                       double step,
                                       double mean,
                                       double std,
                                       double scale,
                                       ChartDataModel dstModel)
Fills normal distribution values to a data model, from specified interval and multiplies the calculated value by the scale parameter

Parameters:
from - interval start
to - interval end
step - interval division step
mean - normal distribution mean
std - normal distribution standard deviation
scale - scale parameter (multiplies the calculated distribution value by it)
dstModel - data model to contain calculated values

validateDataModel

protected void validateDataModel(ChartDataModel dataModel)
                          throws DataFormatException
Checks if histogram data satisfied the minimal requirements. Data Should contain at least 2 data values.

Specified by:
validateDataModel in class ValuesCalculator
Parameters:
dataModel -
Throws:
DataFormatException - when the data is invalid.