Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #53914

Re: Weighted choices

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <oscar.j.benjamin@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.025
X-Spam-Evidence '*H*': 0.95; '*S*': 0.00; 'example:': 0.03; 'algorithm': 0.04; 'tom': 0.07; 'steve': 0.09; 'additionally': 0.09; 'exceeds': 0.09; "they've": 0.09; 'way:': 0.09; 'runs': 0.10; 'cc:addr:python-list': 0.11; 'random': 0.14; 'hat,': 0.16; 'proportion': 0.16; 'quarterback': 0.16; 'remainder': 0.16; 'tom.': 0.16; 'two,': 0.16; 'unexpected': 0.16; 'wrote:': 0.18; 'obviously': 0.18; 'variable': 0.18; 'drawing': 0.19; "hasn't": 0.19; 'cc:addr:python.org': 0.22; 'him.': 0.24; "haven't": 0.24; 'cc:2**0': 0.24; 'player': 0.26; 'least': 0.26; 'header:In-Reply- To:1': 0.27; 'idea': 0.28; 'point': 0.28; '(this': 0.29; 'tim': 0.29; 'joe': 0.30; 'message-id:@mail.gmail.com': 0.30; 'team.': 0.31; 'option.': 0.31; "they'll": 0.31; 'probably': 0.32; 'selection': 0.32; 'everyone': 0.33; "i'd": 0.34; 'could': 0.34; 'one,': 0.35; "who's": 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'really': 0.36; 'acceptable': 0.36; "he's": 0.36; 'i.e.': 0.36; 'picking': 0.36; 'next': 0.36; "didn't": 0.36; 'should': 0.36; 'half': 0.37; 'being': 0.38; 'depends': 0.38; 'hat': 0.38; 'jason': 0.38; 'whatever': 0.38; 'track': 0.38; 'rather': 0.38; 'enough': 0.39; 'either': 0.39; 'how': 0.40; 'dave': 0.60; 'john': 0.61; "you're": 0.61; "you'll": 0.62; 'guarantee': 0.63; 'choose': 0.64; 'pick': 0.64; 'strategy': 0.64; 'more': 0.64; 'total': 0.65; 'different': 0.65; 'to:addr:gmail.com': 0.65; 'saturday': 0.68; 'limit': 0.70; 'day': 0.76; 'absence,': 0.84; 'literally.': 0.84; 'oscar': 0.84; 'played': 0.84; 'tie': 0.84; 'league': 0.91; 'children.': 0.93; '2013': 0.98
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=vPJbCdXmG6w5FBbHD70SF/V9Tz48djaBH/5voG+kfBg=; b=WGhlwFtSYgf8fIsYWPKg7uNt5O9vwHaWiKWiPk7nhw6s0YHVd5kAjTwhCbfcq9g03A h7Hf1IftS9u8XJ1QF8gME/GNJv5h88H0yXVxVn55a96BFRjoEy0Un12uou6b2asEIUSl c8KU7fyZRND9UoXnYPd1In/rE6q8PwZStxiLaRyxp6Fi4tVOSG4f97dTwG2Sy2wbEUct 0Ti+zOkkRu0trSA6kOIaQ1NOEzfUW3UHsEnkhfP+vK6GztFlIBkCb4oaF1vQoejXMZub ul6ZY1un499D2t3cBiVL2fhrVUzxdbOIHim9+WZB8mLTwHaOjE3qDG4ELteP2ZXPK8s4 Z9zA==
X-Received by 10.58.118.130 with SMTP id km2mr21984224veb.0.1378808885338; Tue, 10 Sep 2013 03:28:05 -0700 (PDT)
MIME-Version 1.0
In-Reply-To <CANy1k1hQwRSH1AXyTMiQm+K+BGLOJF3k4L8pFE1tPcBSRWJWKA@mail.gmail.com>
References <CANy1k1gHFFgd82P5VZJEEZvWe_kHJvi2r1uqVh3Sr=nFZyazuQ@mail.gmail.com> <l0k4bq$jpa$1@ger.gmane.org> <CANy1k1hQwRSH1AXyTMiQm+K+BGLOJF3k4L8pFE1tPcBSRWJWKA@mail.gmail.com>
From Oscar Benjamin <oscar.j.benjamin@gmail.com>
Date Tue, 10 Sep 2013 11:27:45 +0100
Subject Re: Weighted choices
To Jason Friedman <jsf80238@gmail.com>
Content-Type text/plain; charset=ISO-8859-1
Cc python-list <python-list@python.org>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.207.1378808893.5461.python-list@python.org> (permalink)
Lines 58
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1378808893 news.xs4all.nl 15969 [2001:888:2000:d::a6]:39499
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:53914

Show key headers only | View raw


On 10 September 2013 03:27, Jason Friedman <jsf80238@gmail.com> wrote:
>>
>> OK, you're well inside the "finite" domain. Also, you probably want less
>> than the "natural" randomness. I'd probably shuffle the potential
>> quarterbacks and the others in independent lists, and then pick one half of
>> each to form a team. The other half would play in the next game.
>> Additionally you can keep track of every player's total number of games and
>> games not played in a row, and apply a correction if either exceeds a limit
>> acceptable for a kid.
>
> PIcking half to play one game and half to play the other is not an
> option.  For one, there really isn't a concept of half when a variable
> number of players are available on a given Saturday.  For two, we
> could have an unexpected absence, or during the game an injury.  For
> three, the parents paid to have their child play in the league, and
> the league runs until the end of October, not long enough for that
> strategy to work out.

Don't take the "pick half" idea so literally. Look at it a different
way: attempt to form a team from all the players who didn't play in
the last game. If that group of players isn't enough to form a team
then they're all in the team and the remainder is chosen randomly from
those that did play in the last game. Here's a concrete example:

Dave hasn't played for 3 games
John, Bob and Steve haven't played for 2 games
Baz, Joe and Tom haven't played for 1 game
James and Tim played the last game.

Those are all the players that could make it on Saturday but you need
to choose 6. You want either of Bob or Tim for quarterback. Bob hasn't
played for longer so you choose him. Obviously Dave's in because he
hasn't played for longer than everyone else. That's not enough for a
team though so you'll need John and Tom as well. That makes 4 so you
need 2 more. However there are three players left that didn't play in
the last game. At this point you put their three names in a hat and
draw out 2 giving Baz and Tom. So Joe has to sit this one out but he's
pretty much definitely in the next game.

Rather than drawing names out of a hat, you could use the total number
of games played as a tiebreaker and only resort to coin-flipping or
whatever when you get a tie for that as well. You could do the same
for quarterback selection as well but based on how often they've been
quarterback and then how many games they've played and then flip a
coin. This algorithm is not really that random but since it depends on
who's available on what day it will probably jumble up the teams over
time at the same time as being broadly fair to each of the children.

For the quarterbacks you'll always be picking the ones that played
least recently so as long as your quarterback pool is oversized in
proportion to the number of players they'll end up playing as much as
everyone else. i.e. if a team has 1 quarterback and 5 players then
your total quarterback pool should be more than 1/5 of the total
player pool (this is also probably necessary to guarantee having a
quarterback anyway).


Oscar

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Weighted choices Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2013-09-10 11:27 +0100

csiph-web