Skip to content

Commit

Permalink
Make rank more random
Browse files Browse the repository at this point in the history
  • Loading branch information
julianweng committed Oct 11, 2024
1 parent 27f0dc0 commit 9ebd5da
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
9 changes: 6 additions & 3 deletions backend/clubs/management/commands/rank.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import datetime
import random
from math import floor

import bleach
import numpy as np
from django.core.management.base import BaseCommand
from django.utils import timezone

Expand Down Expand Up @@ -220,8 +220,11 @@ def rank(self):
if num_testimonials >= 3:
ranking += 5

# rng
ranking += random.random() * 10
# random number, mostly shuffles similar clubs with average of 15 points
# but with long right tail to periodically feature less popular clubs
# given ~700 active clubs, multiplier c, expected # clubs with rand > cd
# is 257, 95, 35, 13, 5, 2, 1 for c = 1, 2, 3, 4, 5, 6, 7
ranking += np.random.standard_exponential() * 15

club.rank = floor(ranking)
club.skip_history_when_saving = True
Expand Down
5 changes: 4 additions & 1 deletion frontend/pages/rank.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,10 @@ const Rank = (): ReactElement => (
name: 'Random Factor',
description: `A random factor is applied periodically in order to ensure that students see new ${OBJECT_NAME_PLURAL} when they visit ${SITE_NAME}.`,
points: [
[10, 'Random number between 0 and this number, updated daily'],
[
15,
'Standard exponential random number scaled to average this number, updated daily',
],
],
},
]}
Expand Down

0 comments on commit 9ebd5da

Please sign in to comment.