com.mizar.statistics
Class SimpleStatistics

java.lang.Object
  extended by com.mizar.statistics.SimpleStatistics

public class SimpleStatistics
extends java.lang.Object

The class accepts a list of Numbers and computes count, mininum, maximum, average, standard deviation and ranks a test value.


Constructor Summary
SimpleStatistics()
           
SimpleStatistics(java.util.Collection collection)
          Use this method when the input is a Map.values() or some other Collection
SimpleStatistics(java.util.List list)
          This constructor is best used when list is List<Number>
SimpleStatistics(java.lang.String propertyName)
           
SimpleStatistics(java.lang.String propertyName, java.util.List list)
           
SimpleStatistics(java.lang.String propertyName, java.util.List list, java.lang.Double testValue)
           
 
Method Summary
 java.lang.Double getAvg()
           
 int getCount()
          The count may be less than the total size of list depending on ignoreNull, ignoreZero and the contents of list
 java.util.List getList()
           
 java.lang.Double getMax()
           
 java.lang.Double getMin()
           
 java.lang.String getPropertyName()
           
 int getRanking()
          If the list were 1, 3, 5, 8, 9, 11, 12 and the testValue was 5 or 6 the ranking would be 4.
 java.lang.Double getSdev()
           
 java.lang.Double getSum()
           
 java.lang.Double getTestValue()
           
 boolean isIgnoreNull()
           
 boolean isIgnoreZero()
           
 void setIgnoreNull(boolean ignoreNull)
           
 void setIgnoreZero(boolean ignoreZero)
           
 void setList(java.util.List list)
           
 void setPropertyName(java.lang.String propertyName)
           
 void setTestValue(java.lang.Double testValue)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleStatistics

public SimpleStatistics()

SimpleStatistics

public SimpleStatistics(java.util.List list)
This constructor is best used when list is List<Number>

Parameters:
list - a List of beans that have that property

SimpleStatistics

public SimpleStatistics(java.util.Collection collection)
Use this method when the input is a Map.values() or some other Collection

Parameters:
collection -

SimpleStatistics

public SimpleStatistics(java.lang.String propertyName)
Parameters:
propertyName - the name of the property to compute statistics for. If null the class expects a List<Number>

SimpleStatistics

public SimpleStatistics(java.lang.String propertyName,
                        java.util.List list)
Parameters:
propertyName - the name of the property to compute statistics for. If null the class expects a List<Number>
list - a List of beans that have that property

SimpleStatistics

public SimpleStatistics(java.lang.String propertyName,
                        java.util.List list,
                        java.lang.Double testValue)
Parameters:
propertyName - the name of the property to compute statistics for. If null the class expects a List<Number>
list - a List of beans that have that property
testValue - a test value to compare against all tested beans to compute a ranking
Method Detail

getCount

public int getCount()
The count may be less than the total size of list depending on ignoreNull, ignoreZero and the contents of list

Returns:
the count of tested beans

getRanking

public int getRanking()
If the list were 1, 3, 5, 8, 9, 11, 12 and the testValue was 5 or 6 the ranking would be 4. If testValue was -1 the ranking would be zero.

Returns:
the position in a sorted list of testValue

getMin

public java.lang.Double getMin()
Returns:
the minimum value of the property found in the list

getMax

public java.lang.Double getMax()
Returns:
the maximum value of the property found in the list

getAvg

public java.lang.Double getAvg()
Returns:
the average (mean) value of the property found in the list

getSum

public java.lang.Double getSum()
Returns:
the sum of all values found in the list

getSdev

public java.lang.Double getSdev()
Returns:
the Standard Deviation of the values of property found in the list

setPropertyName

public void setPropertyName(java.lang.String propertyName)
Parameters:
propertyName - the name of the property to compute statistics for. If null the class expects a List<Number>

getPropertyName

public java.lang.String getPropertyName()
Returns:
propertyName the name of the property to compute statistics for. If null the class expects a List<Number>

setIgnoreNull

public void setIgnoreNull(boolean ignoreNull)
Parameters:
ignoreNull - if true then ignore all null instance of property, if false assume a zero value

isIgnoreNull

public boolean isIgnoreNull()
Returns:
if true then all null instance of property are ignored else they are assumed to be zero

setIgnoreZero

public void setIgnoreZero(boolean ignoreZero)
Parameters:
ignoreZero - if true then ignore all members of list where property value is zero

isIgnoreZero

public boolean isIgnoreZero()
Returns:
if true then ignore all members of list where property value is zero

setList

public void setList(java.util.List list)
Parameters:
list - a List of beans that have property

getList

public java.util.List getList()
Returns:
the list used to compute the statistics

setTestValue

public void setTestValue(java.lang.Double testValue)
Parameters:
testValue - a test value to compare to all other values

getTestValue

public java.lang.Double getTestValue()
Returns:
the test value used to compute the rank