From ba5932c1dd4eaff2d6e61a9b4dabc3e52dc5e36b Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 11 Apr 2025 02:11:45 +0900 Subject: [PATCH] Revert "Use median for statistic display" This reverts commit fa06643bb6c0aacde659640ae0a65c68ab9b0c61. Revert "Remove mean hit error calculation" This reverts commit b3c578e5455c572e34e2def301ba657182747149. --- osu.Game/Rulesets/Scoring/HitEventExtensions.cs | 17 +++++++++++++++++ .../Ranking/Statistics/AverageHitError.cs | 6 +++--- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/osu.Game/Rulesets/Scoring/HitEventExtensions.cs b/osu.Game/Rulesets/Scoring/HitEventExtensions.cs index 39fc8b357b..01d800a351 100644 --- a/osu.Game/Rulesets/Scoring/HitEventExtensions.cs +++ b/osu.Game/Rulesets/Scoring/HitEventExtensions.cs @@ -54,6 +54,23 @@ namespace osu.Game.Rulesets.Scoring return result; } + /// + /// Calculates the average hit offset/error for a sequence of s, where negative numbers mean the user hit too early on average. + /// + /// + /// A non-null value if unstable rate could be calculated, + /// and if unstable rate cannot be calculated due to being empty. + /// + public static double? CalculateAverageHitError(this IEnumerable hitEvents) + { + double[] timeOffsets = hitEvents.Where(AffectsUnstableRate).Select(ev => ev.TimeOffset).ToArray(); + + if (timeOffsets.Length == 0) + return null; + + return timeOffsets.Average(); + } + /// /// Calculates the median hit offset/error for a sequence of s, where negative numbers mean the user hit too early on average. /// diff --git a/osu.Game/Screens/Ranking/Statistics/AverageHitError.cs b/osu.Game/Screens/Ranking/Statistics/AverageHitError.cs index 29df085c62..fb7107cc88 100644 --- a/osu.Game/Screens/Ranking/Statistics/AverageHitError.cs +++ b/osu.Game/Screens/Ranking/Statistics/AverageHitError.cs @@ -8,18 +8,18 @@ using osu.Game.Rulesets.Scoring; namespace osu.Game.Screens.Ranking.Statistics { /// - /// Displays the average hit error statistic for a given play. + /// Displays the unstable rate statistic for a given play. /// public partial class AverageHitError : SimpleStatisticItem { /// /// Creates and computes an statistic. /// - /// Sequence of s to calculate the average hit error based on. + /// Sequence of s to calculate the unstable rate based on. public AverageHitError(IEnumerable hitEvents) : base("Average Hit Error") { - Value = hitEvents.CalculateMedianHitError(); + Value = hitEvents.CalculateAverageHitError(); } protected override string DisplayValue(double? value) => value == null ? "(not available)" : $"{Math.Abs(value.Value):N2} ms {(value.Value < 0 ? "early" : "late")}";