public class Statistics
extends java.lang.Object
Constructor and Description |
---|
Statistics() |
Modifier and Type | Method and Description |
---|---|
static int |
biasedFilteredMean(java.util.List<java.lang.Integer> values,
double fractionalLimit,
double stdDevBias)
Returns a filtered mean that is biased to be conservative.
|
static int |
filteredMean(java.util.List<java.lang.Integer> values,
double fractionalLimit)
Gets the mean value of the values passed in.
|
static double |
getSampleStandardDeviation(double[] values,
double mean)
Returns the sample standard deviation for the values passed in.
|
static void |
main(java.lang.String[] args)
Just for testing
|
static double |
mean(double[] values)
Returns the mean of the array of doubles
|
static double |
mean(int[] values)
Returns the mean of the array of ints
|
static int |
mean(java.util.List<java.lang.Integer> values)
Gets the mean values of the values passed in, without doing any
filtering.
|
static int[] |
toArray(java.util.List<java.lang.Integer> list)
Converts the List
|
static double[] |
toDoubleArray(int[] array)
For converting array of ints into array of doubles so that it can
be used in the statistics functions.
|
static double[] |
toDoubleArray(java.util.List<java.lang.Integer> list)
For converting List of Integers into array of doubles so that it can
be used in the statistics functions.
|
public static int filteredMean(java.util.List<java.lang.Integer> values, double fractionalLimit)
values
- The values to be averagedfractionalLimit
- If value is further away than fractionalLimit of average it is
filtered out if there are more than 2 data points. Expressed
as a fractional value between 0.0 and 1.0 such that a value of
0.0 means no data points are filtered out and a value of 1.0
means 100% of the datapoints are filtered out. Therefore if
one uses a value of 0.5 than values below 50% or above 200% of
the average are filtered out. A value of 0.7 is likely
reasonable since that would filter out values below 70% or
above 143% (1/0.7) of the average.public static int biasedFilteredMean(java.util.List<java.lang.Integer> values, double fractionalLimit, double stdDevBias)
This method is useful for when need to be somewhat conservative, such as when determine expected stop time at a terminal. For such a situation want to take into account when vehicle really leaves the terminal so want to determine the average time. But it is really problematic if the time varies which could mean that the passenger misses the vehicle.
values
- The values to be averagedfractionalLimit
- If value is further away than fractionalLimit of average it is
filtered out if there are more than 2 data points. Expressed
as a fractional value between 0.0 and 1.0 such that a value of
0.0 means no data points are filtered out and a value of 1.0
means 100% of the datapoints are filtered out. Therefore if
one uses a value of 0.5 than values below 50% or above 200% of
the average are filtered out. A value of 0.7 is likely
reasonable since that would filter out values below 70% or
above 143% (1/0.7) of the average.stdDevBias
- How much to bias the mean. For a normal distribution (after
outliers filtered out) using a value of 1.0 standard deviation
means that will return mean - stdDevation. A value of 0.0 would
return the mean.public static int[] toArray(java.util.List<java.lang.Integer> list)
list
- public static double[] toDoubleArray(int[] array)
array
- public static double[] toDoubleArray(java.util.List<java.lang.Integer> list)
list
- public static int mean(java.util.List<java.lang.Integer> values)
values
- The values to be averagedpublic static double mean(double[] values)
values
- public static double mean(int[] values)
values
- public static double getSampleStandardDeviation(double[] values, double mean)
values
- mean
- public static void main(java.lang.String[] args)