com.twitter.algebird

AveragedValue

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 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, Serializable, Product, Equals, AnyRef, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. AveragedValue
  2. Serializable
  3. Serializable
  4. Product
  5. Equals
  6. AnyRef
  7. Any
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

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: AnyRef): Boolean

    Definition Classes
    AnyRef
  2. final def !=(arg0: Any): Boolean

    Definition Classes
    Any
  3. final def ##(): Int

    Definition Classes
    AnyRef → Any
  4. 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.

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

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

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

  8. final def ==(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  9. final def ==(arg0: Any): Boolean

    Definition Classes
    Any
  10. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  11. def clone(): AnyRef

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  12. val count: Long

    the number of aggregated items

  13. final def eq(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  14. def finalize(): Unit

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  15. final def getClass(): Class[_]

    Definition Classes
    AnyRef → Any
  16. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  17. final def ne(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  18. final def notify(): Unit

    Definition Classes
    AnyRef
  19. final def notifyAll(): Unit

    Definition Classes
    AnyRef
  20. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  21. 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
  22. val value: Double

    the average value of all aggregated items

  23. final def wait(): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  24. final def wait(arg0: Long, arg1: Int): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  25. final def wait(arg0: Long): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from Serializable

Inherited from Serializable

Inherited from Product

Inherited from Equals

Inherited from AnyRef

Inherited from Any

Ungrouped