Skip to content

Commit

Permalink
Merge pull request #238 from jcoveney/jco/fix_decayed
Browse files Browse the repository at this point in the history
Fix DecayedValue
  • Loading branch information
johnynek committed Nov 13, 2013
2 parents 123ba06 + b01e7b8 commit f80088f
Showing 1 changed file with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ object DecayedValue extends java.io.Serializable {

case class DecayedValueMonoid(eps:Double) extends Monoid[DecayedValue] {
override val zero = DecayedValue(0.0, Double.NegativeInfinity)
override def plus(left : DecayedValue, right : DecayedValue) = {
override def plus(left : DecayedValue, right : DecayedValue) =
if (left < right) {
//left is older:
DecayedValue.scale(right, left, eps)
Expand All @@ -55,10 +55,9 @@ case class DecayedValueMonoid(eps:Double) extends Monoid[DecayedValue] {
DecayedValue.scale(left, right, eps)
}

// Returns value if timestamp is less than value's timestamp
def valueAsOf(value : DecayedValue, halfLife : Double, timestamp : Double): Double = {
plus(DecayedValue.build(0, timestamp, halfLife), value).value
}
// Returns value if timestamp is less than value's timestamp
def valueAsOf(value : DecayedValue, halfLife : Double, timestamp : Double): Double = {
plus(DecayedValue.build(0, timestamp, halfLife), value).value
}
}

Expand Down

0 comments on commit f80088f

Please sign in to comment.