NYCPHP Meetup

NYPHP.org

[nycphp-talk] [ot] some math help i think

jon baer jonbaer at jonbaer.net
Sun Jan 11 19:11:39 EST 2004


greetings ...

thank you for all the great suggestions for my other problems, i currently
have a small math problem that maybe someone could help me out with ...

basically for the hockey league i created a rating system where each player
can rate another player on their team (from 1 to 10) and submit it ... then
in turn it will calculate a rating on their hockey card from 70 (lowest) to
100 (hightest) ...

what i do is combine the average rating from all the players votes received
(x + y / total) and add the points per game (goals + assists / games) ...

i did a very small test below but not being familiar with php math functions
im sure there is something i can do to get a range/median value:

$peer_average = $_GET['peer'];
$goals = $_GET['goals'];
$assists = $_GET['assists'];
$games = $_GET['games'];

$ppg = (($goals+$assists) / $games) * $peer_average;

$rating = round(($ppg) + 70);

// ugly i know
if ($rating < 70) $rating = 70;
if ($rating > 100) $rating = 100;

echo "rating: " . $rating;

pgp key: http://www.jonbaer.net/jonbaer.asc
fingerprint: F438 A47E C45E 8B27 F68C 1F9B 41DB DB8B 9A0C AF47




More information about the talk mailing list