Skip to content

Commit

Permalink
fix: update stddev to be sample and top snr to be sorted reverse
Browse files Browse the repository at this point in the history
  • Loading branch information
ebachle committed Apr 3, 2024
1 parent 1c8d82f commit fc120cd
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions models.py
Original file line number Diff line number Diff line change
@@ -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]])
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)

0 comments on commit fc120cd

Please sign in to comment.