in algebird-core/src/main/scala/com/twitter/algebird/Approximate.scala [104:127]
def -(right: Approximate[N]): Approximate[N] =
this.+(right.negate)
/**
* This is not distributive, because: a*(b+c) has two probability multiplications while (a*b + a*b) has
* three Some kind of general formula solver could possibly make this distributive, but in the mean time,
* it's only a group
*/
def *(right: Approximate[N]): Approximate[N] =
if (right.isZero || isOne) {
right
} else if (isZero || right.isOne) {
this
} else {
val n = numeric
val ends = for {
leftv <- List(min, max)
rightv <- List(right.min, right.max)
} yield n.times(leftv, rightv)
val newProb = probWithinBounds * right.probWithinBounds
Approximate(ends.min, n.times(estimate, right.estimate), ends.max, newProb)
}