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


Groups > comp.programming > #3340

Re: Compare two methods of random permutations

From Mok-Kong Shen <mok-kong.shen@t-online.de>
Newsgroups comp.programming
Subject Re: Compare two methods of random permutations
Date 2013-05-19 13:26 +0200
Organization albasani.net
Message-ID <knacse$s0u$1@news.albasani.net> (permalink)
References (13 earlier) <cc477dbf-401f-4e44-b52b-1a2c8756f091@tz3g2000pbb.googlegroups.com> <kn56po$83m$1@news.albasani.net> <d40069e8-8b3d-4514-877f-d50c7bef874b@pd6g2000pbc.googlegroups.com> <kna4ld$bvh$1@news.albasani.net> <6011f878-5273-441e-81f5-43cf65c2898e@ys5g2000pbc.googlegroups.com>

Show all headers | View raw


Am 19.05.2013 12:14, schrieb James Dow Allen:
> On May 19, 4:06 pm, Mok-Kong Shen <mok-kong.s...@t-online.de> wrote:
>> Am 17.05.2013 17:13, schrieb James Dow Allen:> On May 17, 7:11 pm, Mok-Kong Shen <mok-kong.s...@t-online.de> wrote:
>>> The method maintains variables a, b
>>> where a is known to be a uniform variate
>>> on {0, 1, 2, ..., b-1}
>>> Initially, a=0, b=1.
>>
>> My first question was: You use rand(), presumably from
>> a certain programming language and that is fixed/unique
>> at least for a given compiler. Does one know in which
>> range [0, b-1] is rand() a uniform variate?
>
>  From your question, I'm afraid you failed to understand
> my method.  :-(
>
> Anyway, for POSIX systems, rand() is uniform on
>    (0, 1, ..., RANDMAX}
> HOWEVER, simplest, when you want best control and flexibility
> is to link a specific PRNG into your application.
> There are several such with source code easily found on-line.
> Most return from {0, 1, ..., 2^32 - 1}
>
> HOWEVER, this is unrelated to {0, ..., b-1} in the description
> of the method I posted.  That method maintains a variate
> of ever-diminishing range, replenishing it by calling a PRNG
> when the range becomes too small.
> Hence the b in that description is variable.

But you do first get a number, say, R, from rand(), don't you?
If so, I think (at least till now) that the range of R, in
which R is (assumed to be) a uniform random variate, is of
significance.

Suppose now that R is uniformly distributed in [0, 2^32-1]. Then
as clearly shown in the post of Patricia Shanahan, one couldn't
"simply" use R%m to get a value that is uniformly distributed in
[0, m-1] for arbitrary m (which was my point of argument 4 years ago).

M. K. Shen

Back to comp.programming | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Compare two methods of random permutations Mok-Kong Shen <mok-kong.shen@t-online.de> - 2013-05-08 23:35 +0200
  Re: Compare two methods of random permutations James Dow Allen <jdallen2000@yahoo.com> - 2013-05-11 21:31 -0700
    Re: Compare two methods of random permutations Mok-Kong Shen <mok-kong.shen@t-online.de> - 2013-05-13 08:07 +0200
      Re: Compare two methods of random permutations James Dow Allen <jdallen2000@yahoo.com> - 2013-05-13 02:34 -0700
  Re: Compare two methods of random permutations Mok-Kong Shen <mok-kong.shen@t-online.de> - 2013-05-13 08:01 +0200
  Re: Compare two methods of random permutations bob <bob@coolfone.comze.com> - 2013-05-13 08:26 -0700
    Re: Compare two methods of random permutations James Dow Allen <jdallen2000@yahoo.com> - 2013-05-13 11:42 -0700
      Re: Compare two methods of random permutations bob <bob@coolfone.comze.com> - 2013-05-16 13:46 -0700
    Re: Compare two methods of random permutations Mok-Kong Shen <mok-kong.shen@t-online.de> - 2013-05-13 21:09 +0200
      Re: Compare two methods of random permutations bob <bob@coolfone.comze.com> - 2013-05-13 12:57 -0700
        Re: Compare two methods of random permutations Mok-Kong Shen <mok-kong.shen@t-online.de> - 2013-05-13 22:59 +0200
          Re: Compare two methods of random permutations bob <bob@coolfone.comze.com> - 2013-05-13 15:28 -0700
            Re: Compare two methods of random permutations Mok-Kong Shen <mok-kong.shen@t-online.de> - 2013-05-14 10:54 +0200
              Re: Compare two methods of random permutations James Dow Allen <jdallen2000@yahoo.com> - 2013-05-14 05:32 -0700
                Re: Compare two methods of random permutations Mok-Kong Shen <mok-kong.shen@t-online.de> - 2013-05-14 22:46 +0200
                Re: Compare two methods of random permutations James Dow Allen <jdallen2000@yahoo.com> - 2013-05-14 14:19 -0700
                Re: Compare two methods of random permutations James Dow Allen <jdallen2000@yahoo.com> - 2013-05-14 15:06 -0700
                Re: Compare two methods of random permutations Mok-Kong Shen <mok-kong.shen@t-online.de> - 2013-05-15 10:16 +0200
                Re: Compare two methods of random permutations James Dow Allen <jdallen2000@yahoo.com> - 2013-05-15 03:54 -0700
                Re: Compare two methods of random permutations Patricia Shanahan <pats@acm.org> - 2013-05-15 07:11 -0700
                Re: Compare two methods of random permutations James Dow Allen <jdallen2000@yahoo.com> - 2013-05-15 11:04 -0700
                Re: Compare two methods of random permutations James Dow Allen <jdallen2000@yahoo.com> - 2013-05-15 11:06 -0700
                Re: Compare two methods of random permutations Patricia Shanahan <pats@acm.org> - 2013-05-15 12:55 -0700
                Re: Compare two methods of random permutations "Chris Uppal" <chris.uppal@metagnostic.REMOVE-THIS.org> - 2013-05-16 06:10 +0100
                Re: Compare two methods of random permutations pacman@kosh.dhis.org (Alan Curry) - 2013-05-16 06:57 +0000
                Re: Compare two methods of random permutations "Chris Uppal" <chris.uppal@metagnostic.REMOVE-THIS.org> - 2013-05-16 09:26 +0100
                Re: Compare two methods of random permutations James Dow Allen <jdallen2000@yahoo.com> - 2013-05-16 01:35 -0700
                Re: Compare two methods of random permutations Mok-Kong Shen <mok-kong.shen@t-online.de> - 2013-05-17 14:11 +0200
                Re: Compare two methods of random permutations James Dow Allen <jdallen2000@yahoo.com> - 2013-05-17 08:13 -0700
                Re: Compare two methods of random permutations Mok-Kong Shen <mok-kong.shen@t-online.de> - 2013-05-19 11:06 +0200
                Re: Compare two methods of random permutations James Dow Allen <jdallen2000@yahoo.com> - 2013-05-19 03:14 -0700
                Re: Compare two methods of random permutations Mok-Kong Shen <mok-kong.shen@t-online.de> - 2013-05-19 13:26 +0200
                Re: Compare two methods of random permutations James Dow Allen <jdallen2000@yahoo.com> - 2013-05-19 04:59 -0700
                Re: Compare two methods of random permutations Mok-Kong Shen <mok-kong.shen@t-online.de> - 2013-05-19 14:13 +0200
                Re: Compare two methods of random permutations James Dow Allen <jdallen2000@yahoo.com> - 2013-05-19 05:52 -0700
                Re: Compare two methods of random permutations Mok-Kong Shen <mok-kong.shen@t-online.de> - 2013-05-19 15:06 +0200
                Re: Compare two methods of random permutations James Dow Allen <jdallen2000@yahoo.com> - 2013-05-19 06:50 -0700
                Re: Compare two methods of random permutations Mok-Kong Shen <mok-kong.shen@t-online.de> - 2013-05-19 16:14 +0200
                Re: Compare two methods of random permutations James Dow Allen <jdallen2000@yahoo.com> - 2013-05-19 08:11 -0700
                Re: Compare two methods of random permutations Mok-Kong Shen <mok-kong.shen@t-online.de> - 2013-05-19 17:15 +0200
                Re: Compare two methods of random permutations Mok-Kong Shen <mok-kong.shen@t-online.de> - 2013-05-19 17:24 +0200

csiph-web