1
0
mirror of https://github.com/ppy/osu.git synced 2026-05-18 08:30:00 +08:00

Revert "Use median for statistic display"

This reverts commit fa06643bb6.

Revert "Remove mean hit error calculation"

This reverts commit b3c578e545.
This commit is contained in:
Dean Herbert
2025-04-11 02:11:45 +09:00
Unverified
parent 430b22b383
commit ba5932c1dd
2 changed files with 20 additions and 3 deletions
@@ -54,6 +54,23 @@ namespace osu.Game.Rulesets.Scoring
return result;
}
/// <summary>
/// Calculates the average hit offset/error for a sequence of <see cref="HitEvent"/>s, where negative numbers mean the user hit too early on average.
/// </summary>
/// <returns>
/// A non-null <see langword="double"/> value if unstable rate could be calculated,
/// and <see langword="null"/> if unstable rate cannot be calculated due to <paramref name="hitEvents"/> being empty.
/// </returns>
public static double? CalculateAverageHitError(this IEnumerable<HitEvent> hitEvents)
{
double[] timeOffsets = hitEvents.Where(AffectsUnstableRate).Select(ev => ev.TimeOffset).ToArray();
if (timeOffsets.Length == 0)
return null;
return timeOffsets.Average();
}
/// <summary>
/// Calculates the median hit offset/error for a sequence of <see cref="HitEvent"/>s, where negative numbers mean the user hit too early on average.
/// </summary>
@@ -8,18 +8,18 @@ using osu.Game.Rulesets.Scoring;
namespace osu.Game.Screens.Ranking.Statistics
{
/// <summary>
/// Displays the average hit error statistic for a given play.
/// Displays the unstable rate statistic for a given play.
/// </summary>
public partial class AverageHitError : SimpleStatisticItem<double?>
{
/// <summary>
/// Creates and computes an <see cref="AverageHitError"/> statistic.
/// </summary>
/// <param name="hitEvents">Sequence of <see cref="HitEvent"/>s to calculate the average hit error based on.</param>
/// <param name="hitEvents">Sequence of <see cref="HitEvent"/>s to calculate the unstable rate based on.</param>
public AverageHitError(IEnumerable<HitEvent> 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")}";