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


Groups > comp.lang.python > #66555

Re: random.sample with large weighted sample-sets?

Newsgroups comp.lang.python
From Charles Allen <ca137tmp@earthlink.net>
Subject Re: random.sample with large weighted sample-sets?
References <20140215224145.68c82eb4@bigbox.christie.dr> <mailman.7036.1392527326.18130.python-list@python.org>
Message-ID <slrnlg1q7e.3nv.ca137tmp@zorro.local> (permalink)
Date 2014-02-16 10:35 -0600

Show all headers | View raw


How efficient does this thing need to be?

You can always just turn it into a two-dimensional sampling problem by
thinking of the data as a function f(x=item), generating a random x=xr
in [0,x], then generating a random y in [0,max(f(x))].  The xr is
accepted if 0 < y <= max(f(xr)), or rejected (and another attempt made) if
y > max(f(xr)).

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


Thread

Re: random.sample with large weighted sample-sets? Ben Finney <ben+python@benfinney.id.au> - 2014-02-16 16:08 +1100
  Re: random.sample with large weighted sample-sets? duncan smith <buzzard@invalid.invalid> - 2014-02-16 16:01 +0000
  Re: random.sample with large weighted sample-sets? Charles Allen <ca137tmp@earthlink.net> - 2014-02-16 10:35 -0600
    Re: random.sample with large weighted sample-sets? duncan smith <buzzard@invalid.invalid> - 2014-02-16 17:38 +0000

csiph-web