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")}";