E nvironment for Deve L oping K DD-Applications Supported by I ndex-Structures

## de.lmu.ifi.dbs.elki.math Class MeanVariance

```java.lang.Object
de.lmu.ifi.dbs.elki.math.MeanVariance
```

`public final class MeanVarianceextends Object`

Do some simple statistics (mean, average). This class can repeatedly be fed with data using the add() methods, The resulting values for mean and average can be queried at any time using getMean() and getVariance(). Trivial code, but replicated a lot. The class is final so it should come at low cost.

Author:
Erich Schubert

Field Summary
` double` `count`
Number of Samples.
` double` `sqrSum`
Sum of Squares
` double` `sum`
Sum of values

Constructor Summary
`MeanVariance()`
Empty constructor
```MeanVariance(double sum, double sqrSum, double count)```
Constructor from full internal data.
`MeanVariance(MeanVariance other)`
Constructor from other instance

Method Summary
` double` `denormalizeValue(double val)`
Return the unnormalized value (centered at the mean, distance normalized by standard deviation)
` double` `getCount()`
Get the number of points the average is based on.
` double` `getMean()`
Return mean
` double` `getStddev()`
Return standard deviation
` double` `getVariance()`
Return variance
`static MeanVariance[]` `newArray(int dimensionality)`
Create and initialize a new array of MeanVariance
` double` `normalizeValue(double val)`
Return the normalized value (centered at the mean, distance normalized by standard deviation)
` void` `put(double val)`
Add a single value with weight 1.0
` void` ```put(double val, double weight)```
Add data with a given weight
` void` `put(MeanVariance other)`
Join the data of another MeanVariance instance.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### sum

`public double sum`
Sum of values

### sqrSum

`public double sqrSum`
Sum of Squares

### count

`public double count`
Number of Samples.

Constructor Detail

### MeanVariance

`public MeanVariance()`
Empty constructor

### MeanVariance

```public MeanVariance(double sum,
double sqrSum,
double count)```
Constructor from full internal data.

Parameters:
`sum` - sum
`sqrSum` - sum of squared values
`count` - sum of weights

### MeanVariance

`public MeanVariance(MeanVariance other)`
Constructor from other instance

Parameters:
`other` - other instance to copy data from.
Method Detail

### put

```public void put(double val,
double weight)```
Add data with a given weight

Parameters:
`val` - data
`weight` - weight

### put

`public void put(double val)`
Add a single value with weight 1.0

Parameters:
`val` - Value

### put

`public void put(MeanVariance other)`
Join the data of another MeanVariance instance.

Parameters:
`other` - Data to join with

### getCount

`public double getCount()`
Get the number of points the average is based on.

Returns:
number of data points

### getMean

`public double getMean()`
Return mean

Returns:
mean

### getVariance

`public double getVariance()`
Return variance

Returns:
variance

### getStddev

`public double getStddev()`
Return standard deviation

Returns:
stddev

### normalizeValue

`public double normalizeValue(double val)`
Return the normalized value (centered at the mean, distance normalized by standard deviation)

Parameters:
`val` - original value
Returns:
normalized value

### denormalizeValue

`public double denormalizeValue(double val)`
Return the unnormalized value (centered at the mean, distance normalized by standard deviation)

Parameters:
`val` - normalized value
Returns:
de-normalized value

### newArray

`public static MeanVariance[] newArray(int dimensionality)`
Create and initialize a new array of MeanVariance

Parameters:
`dimensionality` - Dimensionality
Returns:
New and initialized Array

 Release 0.3 (2010-03-31_1612)