danielcrenna/metrics-net — Issue #7: ExponentiallyDecayingSample.Weight() returns Infinity
Author: timjstewart
Created: 2012-02-08 19:19:31+00:00
State: open

Thanks for porting the Metrics library to C#!

I'm having a problem and I would love to get your advice about it.

The ExponentiallyDecayingSample.Weight(long t) function takes the difference between the _startTime member variable and the current time in ticks. I'm seeing values for Weight's t parameter in the neighborhood of 400,000. Multiplying that by alpha (0.25) yields numbers around 100,000. Somewhere around the value 4,700, Math.Exp() starts returning Infinity. This results in the priority variable in the Update method being set to Infinity most of the time. Because priority is used as the key for the _values member variable, most of the data I'm collecting is ending up in the _values map under a key of Infinity (which just overwrites the previously collected value).

Should I just reduce alpha? This will reduce the bias towards newer values, but maybe that would be just fine.

Should I change the Weight function so that it takes milliseconds instead of nanoseconds (Ticks)?

Even if I make either of these changes, I can think of cases where the weight of a new sample could end up as Infinity. That's the case where a "long time" has elapsed between samples (making t a number greater than ~4,700).

Should Weight return something else if Math.Exp returns Infinity? E.g. Double.MaxValue?

Thanks.

Tim

Thanks!

Tim