Commit 452fd4f3 authored by jkrcal's avatar jkrcal Committed by Commit bot

Fix the computation of the usage metric.

Before this CL, the computation in UserClassifier::UpdateMetricOnEvent() did not
reflect the math outlined in the same function.

This CL fixes the problem.

BUG=648200

Review-Url: https://codereview.chromium.org/2352633002
Cr-Commit-Position: refs/heads/master@{#419437}
parent 9095d34f
......@@ -115,7 +115,7 @@ void UserClassifier::UpdateMetricOnEvent(const char* metric_pref_name,
// avg_events := 1 + e^{-discount_rate_per_hour * hours_since} * avg_events.
double new_avg_events_per_hour =
1 +
std::exp(discount_rate_per_hour_ * hours_since_last_time) *
std::exp(-discount_rate_per_hour_ * hours_since_last_time) *
avg_events_per_hour;
pref_service_->SetDouble(metric_pref_name, new_avg_events_per_hour);
}
......@@ -131,7 +131,11 @@ double UserClassifier::GetEstimateHoursBetweenEvents(
// This is the estimate with the assumption that last event happened right
// now and the system is in the steady-state. Solve estimate_hours in the
// steady-state equation:
// avg_events = 1 + e^{-discount_rate * estimate_hours} * avg_events.
// avg_events = 1 + e^{-discount_rate * estimate_hours} * avg_events,
// i.e.
// -discount_rate * estimate_hours = log((avg_events - 1) / avg_events),
// discount_rate * estimate_hours = log(avg_events / (avg_events - 1)),
// estimate_hours = log(avg_events / (avg_events - 1)) / discount_rate.
return std::min(kMaxHours,
std::log(avg_events_per_hour / (avg_events_per_hour - 1)) /
discount_rate_per_hour_);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment