org.ow2.clif.analyze.statistics.util.data
Class StatOnLongs

java.lang.Object
  extended by org.ow2.clif.analyze.statistics.util.data.StatOnLongs
Direct Known Subclasses:
LongStatistics

public class StatOnLongs
extends java.lang.Object

Class for performances statistical calculation (data stored in ListOfLong) with median, average value, standard deviation ...

Author:
Guy Vachet

Field Summary
static double DEFAULT_FACTOR
           
static double DEFAULT_PERCENT_MIN
           
protected  java.util.logging.Logger logger
           
static int MIN_SIZE_OF_STATISTICAL_DATA
           
 
Constructor Summary
StatOnLongs()
          longStat empty constructor
StatOnLongs(int initialCapacity)
          Constructs a LongStatistics with an empty list of long contructed with the specified initial capacity.
StatOnLongs(ListOfLong listOfLong)
          longStat constructor based on existing ListOfLong.
 
Method Summary
 void addAll(ListOfLong lol)
          adds a ListOfLong in the current one managed by this LongStatistics
 void addAll(StatOnLongs ls)
          adds a copy of ListOfLong managed by the supplied StatOnLongs in the current one managed by this LongStatistics
 void addLong(long value)
          adds a long value in data
 ListOfLong getData()
          gets data as a list of long
 long getLongAt(int index)
          get long value at the specified position in this list (ith value, in chronological order)
 long getMax()
          gets the max value of raw data
 int getMaxStatSortIndex()
           
 long getMaxStatSortValue()
           
 double getMean()
          gets average of raw data
 long getMedian()
          median calculation of raw data
 long getMedian(int beginIndex, int endIndex)
          Returns median of data part.
 long getMin()
          gets the min value of raw data
 int getMinStatSortIndex()
           
 long getMinStatSortValue()
           
 long getSortedValue(int index)
           
 double getStatisticalSortFactor()
          gets the factor of statistical rejection (mean +/- factor*std)
 double getStatisticalSortPercentage()
          gets the target percentage of kept measures after statistical rejection
 int getStatSortDataNumber()
           
 double getStatSortMean()
          computes the statistical mean
 long getStatSortMedian()
          computes the statistical median (could be more robust in case of non-bell distribution).
 double getStatSortStd()
          computes the standard deviation through statistical rejection
 double getStd()
          gets the standard deviation of raw data
 double keptRate()
          keptRate the percent rate of kept values as one digit after dot
 void outputData()
          outputData the original data as one value per line
 void outputData(int numberOfColumn)
          outputData the original data as an Array of "number" columns.
 void outputSortedData()
          outputSortedData the sorted data as one value per line
 void outputSortedData(int numberOfColumn)
          outputSortedData the sorted data as an Array of "number" columns.
 void removeLongAt(int index)
          remove long value at the specified position in this list.
 void reset()
          resets the environment
 void setLogger(java.util.logging.Logger log)
          to specify a logger when you want to log something.
 void setStatisticalSortFactor(double factor)
          sets the factor of statistical sort (rejection based on mean +/- factor*std).
 void setStatisticalSortPercentage(double percentage)
          sets the target percentage of kept measures after statistical rejection in order to avoid to clear data during statistical rejection.
 int size()
          gets the data size
 long subMax(int n, int m)
          the list of the sorted values is divided in m equal parts, the median from the best value (minimal) till the n_th part (included) is returned
 double subMean(int n, int m)
          the list of the sorted values is divided in m equal parts the mean of the n_th part of the best values is returned
 double subMean(int n1, int n2, int m)
          the list of the sorted values is divided in m equal parts (m>0) mean of the sets [n1..n2] (n1 till n2, 0 < n1 < n2 <= m )
 long subMedian(int n, int m)
          the list of the sorted values is divided in m equal parts, the median from the best value (minimal) till the n_th part (included) is returned
 long subMin(int n, int m)
          the list of the sorted values is divided in m equal parts, the median from the best value (minimal) till the n_th part (included) is returned
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected java.util.logging.Logger logger

MIN_SIZE_OF_STATISTICAL_DATA

public static final int MIN_SIZE_OF_STATISTICAL_DATA
See Also:
Constant Field Values

DEFAULT_PERCENT_MIN

public static final double DEFAULT_PERCENT_MIN
See Also:
Constant Field Values

DEFAULT_FACTOR

public static final double DEFAULT_FACTOR
See Also:
Constant Field Values
Constructor Detail

StatOnLongs

public StatOnLongs()
longStat empty constructor


StatOnLongs

public StatOnLongs(int initialCapacity)
Constructs a LongStatistics with an empty list of long contructed with the specified initial capacity.

Parameters:
initialCapacity -

StatOnLongs

public StatOnLongs(ListOfLong listOfLong)
longStat constructor based on existing ListOfLong.

Parameters:
listOfLong - the ListOfLong as initial value.
Method Detail

setLogger

public void setLogger(java.util.logging.Logger log)
to specify a logger when you want to log something.


reset

public void reset()
resets the environment


getData

public ListOfLong getData()
gets data as a list of long

Returns:
ListOfLong in order as values are supplied (chronological order)

addLong

public void addLong(long value)
adds a long value in data

Parameters:
value - to be added to data

addAll

public void addAll(StatOnLongs ls)
adds a copy of ListOfLong managed by the supplied StatOnLongs in the current one managed by this LongStatistics

Parameters:
ls - the LongStatistics to be added in the current one

addAll

public void addAll(ListOfLong lol)
adds a ListOfLong in the current one managed by this LongStatistics

Parameters:
lol - the ListOfLong to be added in the current one

removeLongAt

public void removeLongAt(int index)
remove long value at the specified position in this list.

Parameters:
index - the position

getLongAt

public long getLongAt(int index)
get long value at the specified position in this list (ith value, in chronological order)

Parameters:
index - the position
Returns:
long value

size

public int size()
gets the data size

Returns:
size

getStatisticalSortFactor

public double getStatisticalSortFactor()
gets the factor of statistical rejection (mean +/- factor*std)

Returns:
factor

setStatisticalSortFactor

public void setStatisticalSortFactor(double factor)
                              throws java.lang.IllegalArgumentException
sets the factor of statistical sort (rejection based on mean +/- factor*std).

Parameters:
factor - that must be greater than 0.
Throws:
java.lang.IllegalArgumentException - if an input parameter is illegal

getStatisticalSortPercentage

public double getStatisticalSortPercentage()
gets the target percentage of kept measures after statistical rejection

Returns:
rate

setStatisticalSortPercentage

public void setStatisticalSortPercentage(double percentage)
                                  throws java.lang.IllegalArgumentException
sets the target percentage of kept measures after statistical rejection in order to avoid to clear data during statistical rejection.

Parameters:
percentage - (0.0 < rate <= 100.0)
Throws:
java.lang.IllegalArgumentException - if an input parameter is illegal

outputData

public void outputData()
outputData the original data as one value per line


outputData

public void outputData(int numberOfColumn)
outputData the original data as an Array of "number" columns.

Parameters:
numberOfColumn - to format the values.

outputSortedData

public void outputSortedData()
outputSortedData the sorted data as one value per line


outputSortedData

public void outputSortedData(int numberOfColumn)
outputSortedData the sorted data as an Array of "number" columns.

Parameters:
numberOfColumn - to format the values.

getMin

public long getMin()
gets the min value of raw data

Returns:
long min value

getMax

public long getMax()
gets the max value of raw data

Returns:
long max value

getMedian

public long getMedian(int beginIndex,
                      int endIndex)
Returns median of data part. The sub-data begins at the specified beginIndex and ends at endIndex. Thus the size of the sub-data is (endIndex-beginIndex+1).

Parameters:
beginIndex - - the beginning index, inclusive.
endIndex - - the ending index, inclusive.
Returns:
median of value within [beginIndex..endIndex]

getMedian

public long getMedian()
median calculation of raw data

Returns:
long median

getMean

public double getMean()
gets average of raw data

Returns:
double average

getStd

public double getStd()
gets the standard deviation of raw data

Returns:
double standard deviation

subMean

public double subMean(int n,
                      int m)
               throws java.lang.Exception
the list of the sorted values is divided in m equal parts the mean of the n_th part of the best values is returned

Parameters:
n - n_th part
m - m equal parts
Returns:
double n_th average
Throws:
java.lang.Exception

subMean

public double subMean(int n1,
                      int n2,
                      int m)
               throws java.lang.Exception
the list of the sorted values is divided in m equal parts (m>0) mean of the sets [n1..n2] (n1 till n2, 0 < n1 < n2 <= m )

Parameters:
n1 - start part
n2 - end part
m - m equal parts
Throws:
java.lang.Exception

subMin

public long subMin(int n,
                   int m)
            throws java.lang.Exception
the list of the sorted values is divided in m equal parts, the median from the best value (minimal) till the n_th part (included) is returned

Parameters:
n - n_th part
m - equal parts
Returns:
long subMin
Throws:
java.lang.Exception

subMax

public long subMax(int n,
                   int m)
            throws java.lang.Exception
the list of the sorted values is divided in m equal parts, the median from the best value (minimal) till the n_th part (included) is returned

Parameters:
n - n_th part
m - equal parts
Returns:
long subMax
Throws:
java.lang.Exception

subMedian

public long subMedian(int n,
                      int m)
               throws java.lang.Exception
the list of the sorted values is divided in m equal parts, the median from the best value (minimal) till the n_th part (included) is returned

Parameters:
n - n_th part
m - equal parts
Returns:
long submedian
Throws:
java.lang.Exception

getStatSortMedian

public long getStatSortMedian()
computes the statistical median (could be more robust in case of non-bell distribution).

Returns:
the statistical median

getStatSortMean

public double getStatSortMean()
computes the statistical mean

Returns:
the statistical average

getStatSortStd

public double getStatSortStd()
computes the standard deviation through statistical rejection

Returns:
the standard deviation

keptRate

public double keptRate()
keptRate the percent rate of kept values as one digit after dot

Returns:
rate of nonRejection

getMinStatSortIndex

public int getMinStatSortIndex()

getMaxStatSortIndex

public int getMaxStatSortIndex()

getStatSortDataNumber

public int getStatSortDataNumber()

getMinStatSortValue

public long getMinStatSortValue()

getMaxStatSortValue

public long getMaxStatSortValue()

getSortedValue

public long getSortedValue(int index)