Package org.geotools.metadata.math
Class Statistics
- Object
-
- Statistics
-
- All Implemented Interfaces:
Serializable,Cloneable,Cloneable
- Direct Known Subclasses:
Statistics.Delta
public class Statistics extends Object implements Cloneable, Serializable
Holds some statistics about a series of sample values. Given a series of sample values s0, s1, s2, s3..., this class computes minimum, maximum, mean, root mean square and standard deviation. Statistics are computed on the fly; the sample values are never stored in memory.An instance of
Statisticsis initially empty (i.e. all statistical values are set toNaN). The statistics are updated every time anadd(double)method is invoked with a non-NaN value. A typical usage of this class is:double[] data = new double[1000]; // (Compute some data values here...) Statistics stats = new Statistics(); for (int i=0; i<data.length; i++) { stats.add(data[i]); } System.out.println(stats);- Since:
- 2.0
- Author:
- Martin Desruisseaux (IRD)
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classStatistics.DeltaHolds some statistics about a series of sample values and the difference between them.
-
Constructor Summary
Constructors Constructor Description Statistics()Constructs an initially empty set of statistics.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(double sample)Updates statistics for the specified sample.voidadd(long sample)Updates statistics for the specified sample.voidadd(Statistics stats)Updates statistics with all samples from the specifiedstats.Statisticsclone()Returns a clone of this statistics.intcount()Returns the number of samples, excludingNaNvalues.intcountNaN()Returns the number ofNaNsamples.booleanequals(Object obj)Tests this statistics with the specified object for equality.inthashCode()Returns a hash code value for this statistics.doublemaximum()Returns the maximum sample value, orNaNif none.doublemean()Returns the mean value, orNaNif none.doubleminimum()Returns the minimum sample value, orNaNif none.doublerange()Returns the range of sample values.voidreset()Resets the statistics to their initialNaNvalues.doublerms()Returns the root mean square, orNaNif none.doublestandardDeviation(boolean allPopulation)Retourne l'écart type des échantillons par rapport à la moyenne.StringtoString()Returns a string representation of this statistics.StringtoString(Locale locale, boolean tabulations)Returns a localized string representation of this statistics.
-
-
-
Constructor Detail
-
Statistics
public Statistics()
Constructs an initially empty set of statistics. All statistical values are initialized toDouble.NaN.
-
-
Method Detail
-
reset
public void reset()
Resets the statistics to their initialNaNvalues. This method reset this object state as if it was just created.
-
add
public void add(double sample)
Updates statistics for the specified sample. Thisaddmethod is usually invoked inside aforloop.- Parameters:
sample- The sample value.NaNvalues are ignored.- See Also:
add(long),add(Statistics)
-
add
public void add(long sample)
Updates statistics for the specified sample. Thisaddmethod is usually invoked inside aforloop.- Parameters:
sample- The sample value.- See Also:
add(double),add(Statistics)
-
add
public void add(Statistics stats)
Updates statistics with all samples from the specifiedstats. Invoking this method is equivalent (except for rounding errors) to invokingaddfor all samples that were added tostats.- Parameters:
stats- The statistics to be added tothis, ornullif none.
-
countNaN
public int countNaN()
Returns the number ofNaNsamples.NaNsamples are ignored in all other statitical computation. This method count them for information purpose only.
-
count
public int count()
Returns the number of samples, excludingNaNvalues.
-
minimum
public double minimum()
Returns the minimum sample value, orNaNif none.- See Also:
maximum()
-
maximum
public double maximum()
Returns the maximum sample value, orNaNif none.- See Also:
minimum()
-
range
public double range()
-
mean
public double mean()
Returns the mean value, orNaNif none.
-
rms
public double rms()
Returns the root mean square, orNaNif none.
-
standardDeviation
public double standardDeviation(boolean allPopulation)
Retourne l'écart type des échantillons par rapport à la moyenne. Si les données fournies aux différentes méthodesadd(...)se distribuent selon une loi normale, alors l'écart type est la distance de part et d'autre de la moyenne dans lequel se trouveraient environ 84% des données. Le tableau ci-dessous donne le pourcentage approximatif des données que l'on trouve de part et d'autre de la moyenne à des distances telles que 2 ou 3 fois l'écart-type.0.5 69.1% 1.0 84.2% 1.5 93.3% 2.0 97.7% 3.0 99.9% - Parameters:
allPopulation- La valeurtrueindique que les données fournies aux différentes méthodesadd(...)représentent l'ensemble de la polulation. La valeurfalseindique que ces données ne représentent qu'un échantillon de la population, ce qui est généralement le cas. Si le nombre de données est élevé, alors les valeurstrueetfalsedonneront sensiblement les mêmes résultats.
-
clone
public Statistics clone()
Returns a clone of this statistics.- Specified by:
clonein interfaceCloneable- Overrides:
clonein classObject- Returns:
- A copy of this object.
- See Also:
Object.clone()
-
equals
public boolean equals(Object obj)
Tests this statistics with the specified object for equality.
-
hashCode
public int hashCode()
Returns a hash code value for this statistics.
-
toString
public final String toString()
Returns a string representation of this statistics. This method invokestoString(Locale, boolean)using the default locale and spaces separator.
-
toString
public String toString(Locale locale, boolean tabulations)
Returns a localized string representation of this statistics. This string will span multiple lines, one for each statistical value. For example:
IfCompte: 8726 Minimum: 6.853 Maximum: 8.259 Moyenne: 7.421 RMS: 7.846 Écart-type: 6.489tabulationsis true, then labels (e.g. "Minimum") and values (e.g. "6.853") are separated by tabulations. Otherwise, they are separated by spaces.
-
-