com.github.marklister.collections

util

package util

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
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

scala> CollSeq((1,2),(2,1),(3,3)).mean
res1: Double = 2.1666666666666665

scala> (2.0+2.0+9.0)/6.0
res2: Double = 2.1666666666666665
Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. util
  2. AnyRef
  3. Any
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Type Members

  1. class Stats[A] extends AnyRef

    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

  2. class WeightedStats[A, B] extends AnyRef

    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

Inherited from AnyRef

Inherited from Any

Ungrouped