A very simple class wrapping an Iterable
and providing basic statistics
like mean and variance.
A very simple class wrapping an Iterable
and providing basic statistics
like mean and variance.
There is an implicit conversion from a Seq[A]
to a Stats[A]
imported
with com.github.marklister.collections. So you do not need to do anything
to use this class. Simply use the mean
, stdDev
or variance
methods on an appropriate sequence:
import com.github.marklister.collections.io._ import com.github.marklister.collections._ Welcome to Scala version 2.10.1 (OpenJDK Server VM, Java 1.7.0_21). Type in expressions to have them evaluated. Type :help for more information. scala> Seq(1,2,3).mean res0: Double = 2.0
If you know of a library that performs this function please raise an issue on GitHub
A very simple class wrapping an Iterable[Product2[A,B]]
and providing
basic weighted statistics like weighted mean and weighted variance.
A very simple class wrapping an Iterable[Product2[A,B]]
and providing
basic weighted statistics like weighted mean and weighted variance.
The first element of the Pair is the value and the second element the weight.
There is an implicit conversion from a Seq[Product2[A,B]]
to a
WeightedStats[A,B]
imported with com.github.marklister.collections. So you do
not need to do anything to use this class. Simply use the mean
, stdDev
or variance
methods on an appropriate sequence:
import com.github.marklister.collections.io._ import com.github.marklister.collections._ Welcome to Scala version 2.10.1 (OpenJDK Server VM, Java 1.7.0_21). Type in expressions to have them evaluated. Type :help for more information. scala> CollSeq((1,2),(2,1),(3,3)).mean res1: Double = 2.1666666666666665
I would really prefer to use an external library. If you know of one please raise an issue on Github
Statistics Classes
Implicit conversions in package object com.github.marklister.collections make the following promotions available:
- Seq[Numeric] => Stats[Numeric] - Seq[(Numeric,Numeric)] => WeightedStats[Numeric,Numeric]
The classes com.github.marklister.collections.util.Stats and com.github.marklister.collections.util.WeightedStats make methods like mean, variance, and stdDev available.
Example