metrics_data_validation.h 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. // Copyright 2021 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef COMPONENTS_METRICS_METRICS_DATA_VALIDATION_H_
  5. #define COMPONENTS_METRICS_METRICS_DATA_VALIDATION_H_
  6. #include "base/feature_list.h"
  7. #include "base/metrics/field_trial_params.h"
  8. #include "base/time/time.h"
  9. // Features and functions in this file are necessary to set up artificial A / B
  10. // experiments that help us better assess the accuracy and power of our field
  11. // trial data. All code in this file should not have any impact on client's
  12. // experience.
  13. namespace metrics {
  14. // Only used for testing.
  15. namespace internal {
  16. extern const base::Feature kPseudoMetricsEffectFeature;
  17. } // namespace internal
  18. // Used to assess the reliability of field trial data by sending artificial
  19. // non-uniform data drawn from a log normal distribution.
  20. extern const base::Feature kNonUniformityValidationFeature;
  21. // The parameters for the log normal distribution. They refer to the default
  22. // mean, the delta that would be applied to the default mean (the actual mean
  23. // equals mean + log(1 + delta)) and the standard deviation of the distribution
  24. // that's being generated. These parameters are carefully calculated so that
  25. // ~0.01% of data drawn from the distribution would fall in the underflow bucket
  26. // and ~0.01% of data in the overflow bucket. And they also leave us enough
  27. // wiggle room to shift mean using delta in experiments without losing precision
  28. // badly because of data in the overflow bucket.
  29. //
  30. // The way we get these numbers are based on the following calculation:
  31. // u := the lower threshold for the overflow bucket (in this case, 10000).
  32. // l := the upper threshold for the smallest bucket (in this case, 1).
  33. // p := the probability that an observation will fall in the highest bucket (in
  34. // this case, 0.01%) and also the probability that an observation will fall in
  35. // the lowest bucket.
  36. //
  37. // mean = (log(u) + log(l)) / 2
  38. // sd = (log(u) - log(l)) / (2 * qnorm(1-p))
  39. //
  40. // At this point, experiments should only control the delta but not mean and
  41. // stdDev. Putting them in feature params so that we can configure them from the
  42. // server side if we want.
  43. extern const base::FeatureParam<double> kLogNormalMean;
  44. extern const base::FeatureParam<double> kLogNormalDelta;
  45. extern const base::FeatureParam<double> kLogNormalStdDev;
  46. // In order to assess if we're able to accurately detect a statistically
  47. // significant difference in our field trial data, we set up pseudo metrics for
  48. // some of our key metrics. Values of these pseudo metrics are the linear
  49. // transformation (ax + b) of real values (x). The multiplicative factor (a) and
  50. // additive factor (b) are controlled by field trial experiments.
  51. //
  52. // Returns the sample value for a pseudo metric given the |sample| from the real
  53. // metric and the assigned field trial group. The input type is double because
  54. // we don't want to lose precision before applying transformation.
  55. double GetPseudoMetricsSample(double sample);
  56. // Returns the TimeDelta for a pseudo metric given the |sample| from the real
  57. // metric and the assigned field trial group. The unit of the additive factor
  58. // (b) is milliseconds.
  59. base::TimeDelta GetPseudoMetricsSample(base::TimeDelta sample);
  60. } // namespace metrics
  61. #endif // COMPONENTS_METRICS_METRICS_DATA_VALIDATION_H_