Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix DecayedValue #238

Merged
merged 1 commit into from
Nov 13, 2013
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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