Packages

case class AveragedValue(count: Long, value: Double) extends Product with Serializable

Tracks the count and mean value of Doubles in a data stream.

Adding two instances of AveragedValue with + is equivalent to taking an average of the two streams, with each stream weighted by its count.

The mean calculation uses a numerically stable online algorithm suitable for large numbers of records, similar to Chan et. al.'s parallel variance algorithm on Wikipedia. As long as your count doesn't overflow a Long, the mean calculation won't overflow.

count

the number of aggregated items

value

the average value of all aggregated items

See also

MomentsGroup.getCombinedMean for implementation of +

Linear Supertypes
Serializable, Product, Equals, AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. AveragedValue
  2. Serializable
  3. Product
  4. Equals
  5. AnyRef
  6. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Instance Constructors

  1. new AveragedValue(count: Long, value: Double)

    count

    the number of aggregated items

    value

    the average value of all aggregated items

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##: Int
    Definition Classes
    AnyRef → Any
  3. def +[N](that: N)(implicit num: Numeric[N]): AveragedValue

    Returns a new instance that averages that into this instance.

    Returns a new instance that averages that into this instance.

    that

    value to average into this instance

    returns

    an instance representing the mean of this instance and that.

  4. def +(that: Double): AveragedValue

    Returns a new instance that averages that into this instance.

    Returns a new instance that averages that into this instance.

    that

    value to average into this instance

    returns

    an instance representing the mean of this instance and that.

  5. def +(r: AveragedValue): AveragedValue

    Averages this instance with another AveragedValue instance.

    Averages this instance with another AveragedValue instance.

    r

    the other instance

    returns

    an instance representing the mean of this instance and r.

  6. def -(r: AveragedValue): AveragedValue

    Averages this instance with the *opposite* of the supplied AveragedValue instance, effectively subtracting out that instance's contribution to the mean.

    Averages this instance with the *opposite* of the supplied AveragedValue instance, effectively subtracting out that instance's contribution to the mean.

    r

    the instance to subtract

    returns

    an instance with r's stream subtracted out

  7. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  8. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  9. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @native()
  10. val count: Long
  11. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  12. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable])
  13. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  14. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  15. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  16. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  17. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  18. def productElementNames: Iterator[String]
    Definition Classes
    Product
  19. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  20. def unary_-: AveragedValue

    Returns a copy of this instance with a negative value.

    Returns a copy of this instance with a negative value. Note that

    a + -b == a - b
  21. val value: Double
  22. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  23. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  24. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()

Inherited from Serializable

Inherited from Product

Inherited from Equals

Inherited from AnyRef

Inherited from Any

Ungrouped