Class StatOnLongs
- java.lang.Object
-
- org.ow2.clif.analyze.statistics.util.data.StatOnLongs
-
- Direct Known Subclasses:
LongStatistics
public class StatOnLongs extends java.lang.ObjectClass for performances statistical calculation (data stored in ListOfLong) with median, average value, standard deviation ...- Author:
- Guy Vachet, Bruno Dillenseger
-
-
Field Summary
Fields Modifier and Type Field Description static doubleDEFAULT_FACTORstatic doubleDEFAULT_PERCENT_MINprotected java.util.logging.Loggerloggerstatic intMIN_SIZE_OF_STATISTICAL_DATA
-
Constructor Summary
Constructors Constructor Description StatOnLongs()longStat empty constructorStatOnLongs(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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddAll(ListOfLong lol)adds a ListOfLong in the current one managed by this LongStatisticsvoidaddAll(StatOnLongs ls)adds a copy of ListOfLong managed by the supplied StatOnLongs in the current one managed by this LongStatisticsvoidaddLong(long value)adds a long value in dataListOfLonggetData()gets data as a list of longlonggetLongAt(int index)get long value at the specified position in this list (ith value, in chronological order)java.lang.LonggetMax()gets the max value of raw dataintgetMaxStatSortIndex()longgetMaxStatSortValue()doublegetMean()gets average of raw datajava.lang.LonggetMedian()median calculation of raw datajava.lang.LonggetMedian(int beginIndex, int endIndex)Returns median of data part.java.lang.LonggetMin()gets the min value of raw dataintgetMinStatSortIndex()longgetMinStatSortValue()doublegetNumberOfValues(ListOfLong data, int timeStartCurrent, int timeEndCurrent)Get the number of values in intervalListOfLonggetSortedData()longgetSortedValue(int index)doublegetStatisticalSortFactor()gets the factor of statistical rejection (mean +/- factor*std)doublegetStatisticalSortPercentage()gets the target percentage of kept measures after statistical rejectionintgetStatSortDataNumber()doublegetStatSortMean()computes the statistical meanlonggetStatSortMedian()computes the statistical median (could be more robust in case of non-bell distribution).doublegetStatSortStd()computes the standard deviation through statistical rejectiondoublegetStd()gets the standard deviation of raw datadoublekeptRate()keptRate the percent rate of kept values as one digit after dotvoidoutputData()outputData the original data as one value per linevoidoutputData(int numberOfColumn)outputData the original data as an Array of "number" columns.voidoutputSortedData()outputSortedData the sorted data as one value per linevoidoutputSortedData(int numberOfColumn)outputSortedData the sorted data as an Array of "number" columns.voidremoveLongAt(int index)remove long value at the specified position in this list.voidreset()resets the environmentvoidsetLogger(java.util.logging.Logger log)to specify a logger when you want to log something.voidsetStatisticalSortFactor(double factor)sets the factor of statistical sort (rejection based on mean +/- factor*std).voidsetStatisticalSortPercentage(double percentage)sets the target percentage of kept measures after statistical rejection in order to avoid to clear data during statistical rejection.intsize()gets the data sizelongsubMax(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 returneddoublesubMean(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 returneddoublesubMean(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 )longsubMedian(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 returnedlongsubMin(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
-
-
-
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)
-
getSortedData
public ListOfLong getSortedData()
-
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.IllegalArgumentExceptionsets 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.IllegalArgumentExceptionsets 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 java.lang.Long getMin()
gets the min value of raw data- Returns:
- long min value
-
getMax
public java.lang.Long getMax()
gets the max value of raw data- Returns:
- long max value
-
getMedian
public java.lang.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 java.lang.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.Exceptionthe 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 partm- 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.Exceptionthe 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 partn2- end partm- m equal parts- Throws:
java.lang.Exception
-
subMin
public long subMin(int n, int m) throws java.lang.Exceptionthe 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 partm- equal parts- Returns:
- long subMin
- Throws:
java.lang.Exception
-
subMax
public long subMax(int n, int m) throws java.lang.Exceptionthe 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 partm- equal parts- Returns:
- long subMax
- Throws:
java.lang.Exception
-
subMedian
public long subMedian(int n, int m) throws java.lang.Exceptionthe 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 partm- 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)
-
getNumberOfValues
public double getNumberOfValues(ListOfLong data, int timeStartCurrent, int timeEndCurrent)
Get the number of values in interval- Parameters:
data-timeStartCurrent-timeEndCurrent-- Returns:
- number of values in interval
-
-