From fc120cd2ed3a9a16541623fe9a00c5f5827fef03 Mon Sep 17 00:00:00 2001 From: Eddie Bachle Date: Tue, 2 Apr 2024 21:53:07 -0400 Subject: [PATCH] fix: update stddev to be sample and top snr to be sorted reverse --- models.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/models.py b/models.py index b690fb3..be1e3c7 100644 --- a/models.py +++ b/models.py @@ -10,17 +10,24 @@ class DivisionTeam: class Division: name: str teams: list[DivisionTeam] - + def strength(self) -> float: return numpy.average([team.district_points for team in self.teams]) # type: ignore - + @staticmethod def __snr(point_list: list[int]) -> float: - return 10 * numpy.log10(numpy.average(point_list)**2 / numpy.std(point_list)**2) # type: ignore - + return 10 * numpy.log10(numpy.average(point_list) ** 2 / numpy.std(point_list, ddof=1) ** 2) # type: ignore + + def stddev(self) -> float: + return numpy.std([team.district_points for team in self.teams], ddof=1) + + def avg(self) -> float: + return numpy.average([team.district_points for team in self.teams]) + def snr(self) -> float: return Division.__snr([team.district_points for team in self.teams]) - + def top_snr(self) -> float: '''Calculates the signal-to-noise ratio of the top 25% of teams''' - return Division.__snr([team.district_points for team in sorted(self.teams, key=lambda t: t.district_points)[:len(self.teams)//4]]) \ No newline at end of file + points = [team.district_points for team in sorted(self.teams, key=lambda t: t.district_points, reverse=True)[:len(self.teams)//4]] + return Division.__snr(points)