spockito

Tiny Java utility to incrementally calculate Mean and Standard Deviation with a numerically stable algorithm. Contains a simple utility class to incrementally calculate moving average and moving standard deviation of a data series.

License

License

GroupId

GroupId

org.tools4j
ArtifactId

ArtifactId

tools4j-meanvar
Last Version

Last Version

1.1
Release Date

Release Date

Type

Type

jar
Description

Description

spockito
Tiny Java utility to incrementally calculate Mean and Standard Deviation with a numerically stable algorithm. Contains a simple utility class to incrementally calculate moving average and moving standard deviation of a data series.
Project URL

Project URL

https://github.com/tools4j/meanvar
Source Code Management

Source Code Management

https://github.com/tools4j/meanvar.git

Download tools4j-meanvar

How to add to project

<!-- https://jarcasting.com/artifacts/org.tools4j/tools4j-meanvar/ -->
<dependency>
    <groupId>org.tools4j</groupId>
    <artifactId>tools4j-meanvar</artifactId>
    <version>1.1</version>
</dependency>
// https://jarcasting.com/artifacts/org.tools4j/tools4j-meanvar/
implementation 'org.tools4j:tools4j-meanvar:1.1'
// https://jarcasting.com/artifacts/org.tools4j/tools4j-meanvar/
implementation ("org.tools4j:tools4j-meanvar:1.1")
'org.tools4j:tools4j-meanvar:jar:1.1'
<dependency org="org.tools4j" name="tools4j-meanvar" rev="1.1">
  <artifact name="tools4j-meanvar" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.tools4j', module='tools4j-meanvar', version='1.1')
)
libraryDependencies += "org.tools4j" % "tools4j-meanvar" % "1.1"
[org.tools4j/tools4j-meanvar "1.1"]

Dependencies

test (1)

Group / Artifact Type Version
junit : junit jar 4.12

Project Modules

There are no modules declared in this project.

Build Status Coverage Status Maven Central Javadocs

tools4j-meanvar

Tiny Java utility to incrementally calculate Mean and Standard Deviation with a numerically stable algorithm. Contains a simple utility class to incrementally calculate moving average and moving standard deviation of a data series.

The implementation is based on Welford’s Algorithm given in Knuth Vol 2, p 232.

Examples

MeanVarianceSampler
final MeanVarianceSampler sampler = new MeanVarianceSampler();

double mean, var, stdDev;

sampler.add(1);
sampler.add(2.5);
sampler.add(3.22);
sampler.add(-6.72);
mean = sampler.getMean();
var = sampler.getVariance();
stdDev = sampler.getStdDev();

sampler.remove(2.5);
mean = sampler.getMean();
var = sampler.getVariance();
stdDev = sampler.getStdDev();

sampler.replace(3.22, 4.22);
mean = sampler.getMean();
var = sampler.getVariance();
stdDev = sampler.getStdDev();
MeanVarianceSlidingWindow
final int windowSize = 3;
final MeanVarianceSlidingWindow win = new MeanVarianceSlidingWindow(windowSize);

double mean, var, stdDev;

win.update(1);
win.update(2);
win.update(3);
mean = win.getMean();
var = win.getVariance();
stdDev = win.getStdDev();

//1 drops out now
win.update(4);
mean = win.getMean();
var = win.getVariance();
stdDev = win.getStdDev();

//2 drops out now
win.update(5);
mean = win.getMean();
var = win.getVariance();
stdDev = win.getStdDev();

Maven

Add the following dependency to your maven pom.xml file:

<dependency>
    <groupId>org.tools4j</groupId>
    <artifactId>tools4j-meanvar</artifactId>
    <version>1.1</version>
</dependency>

Gradle

Add the following entry to the dependencies section in your build.gradle file:

dependencies {
    compile 'org.tools4j:tools4j-meanvar:1.1'
}

Download

Sources and binaries can be downloaded from maven central:

API Javadoc

Javadocs

More Information

org.tools4j
tools4j.org is a collection of Java libraries and tools.

Versions

Version
1.1