Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(119)

Unified Diff: components/ntp_snippets/user_classifier.cc

Issue 2352633002: Fix the computation of the usage metric in UserClassifier. (Closed)
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/ntp_snippets/user_classifier.cc
diff --git a/components/ntp_snippets/user_classifier.cc b/components/ntp_snippets/user_classifier.cc
index ef179b320a6bcba3e06b1a5530f06a9810dd557e..df24ec962f800f5e9c391447525979f662f3c540 100644
--- a/components/ntp_snippets/user_classifier.cc
+++ b/components/ntp_snippets/user_classifier.cc
@@ -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_);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698