adder
Posts:
153
Registered:
10/3/07


Re: Random numbers
Posted:
Dec 24, 2007 1:45 AM


On Dec 23, 10:32 pm, no comment <adler.m...@gmail.com> wrote: > On Dec 23, 9:32 pm, quasi <qu...@null.set> wrote: > > > > > On Mon, 24 Dec 2007 00:10:57 0500, quasi <qu...@null.set> wrote: > > >On Sun, 23 Dec 2007 19:46:21 0800 (PST), bill <b92...@yahoo.com> > > >wrote: > > > >>On Dec 22, 5:25 pm, quasi <qu...@null.set> wrote: > > >>> On Sat, 22 Dec 2007 16:30:20 0800 (PST), bill <b92...@yahoo.com> > > >>> wrote: > > > >>> >On Dec 22, 10:16 am, quasi <qu...@null.set> wrote: > > >>> >> On Fri, 21 Dec 2007 10:57:00 0800 (PST), simple.pop...@gmail.com > > >>> >> wrote: > > > >>> >> >On Dec 21, 11:37 pm, bill <b92...@yahoo.com> wrote: > > >>> >> >> On Dec 21, 3:16 am, John <iamach...@gmail.com> wrote: > > > >>> >> >> > Given a function that returns a random number between 15, write one > > >>> >> >> > that returns a random number between 17 for the case when it should > > >>> >> >> > be integer and for the case it can be real. > > > >>> >> >> Let S be the function that generates a RN between 1 and 5. Then > > > >>> >> >> T = S_1 + S_2 + ... + S_7 > > > >>> >> >> For the reals , RN_7 = T/7 > > > >>> >> >May be this should fix it: > > > >>> >> >For the reals , RN_7 = 1 + (T7)*3/14 > > > >>> >> Yes, that fixes the range. > > > >>> >> But it's still biased (that is, not a unform distribution). > > > >>> >> quasi > > > >>> >The OP does not specify a uniform > > >>> >distribution, merely the range. > > > >>> This has already been discussed. > > > >>> The obvious assumption _implicit_ in the problem, even if not unstated > > >>> is that the resulting distribution should be uniform. Of course, it > > >>> should have been specified, but common sense dictates that in the > > >>> absence of the required info, to choose the natural default. > > > >>> If there was no preference for a distribution, there would be no need > > >>> to use the RNG provided for the range 1 to 5. We could just always > > >>> produce the number 3, for example. In other words, the very fact that > > >>> an RNG for the range 1 to 5 was given as part of the problem makes it > > >>> clear that the for the actual problem (not the OP's deficient > > >>> statement of it), it almost certainly _was_ specified that the > > >>> required distribution should be uniform. > > > >>> >RN_7 = T/7 satisfies the range 1 thru 7. > > > >>> So what? It's badly biased. Worse, since there is no discussion of > > >>> bias or the lack of it, it's misleading to those unaware of the issue. > > > >>> >T/7 is a numner in the range 1 thru 7, > > >>> >but is it random? > > > >>> Ok, but note that T/7 never exceeds 5. > > > >>> It's definitely not uniformly random. > > > >>> >If RN_7 = T mod 7 +1, the probability > > >>> >of a correct guess is 1/7 > > > >>> Nonsense. Do a simulation. > > > >Ok, for the above, I must apologize. For the _integer_ case, the > > >calculation (T mod 7) + 1 does appear to give a uniform distribution > > > Hehe  I take back part of my apology. It _is_ biased, but only > > slightly. > > > The probabilities for y = (T mod 7) + 1 are as follows: > > > P(y=1) = .1430656 > > P(y=2) = .1430016 > > P(y=3) = .1428224 > > P(y=4) = .1426432 > > P(y=5) = .1426432 > > P(y=6) = .1428224 > > P(y=7) = .1430016 > > > The above probabilities are exact, hence you can see a slight bias. Of > > course, while I had originally intuited a bias, I expected it to be > > badly biased. I was wrong about that. Only the continuous case is > > badly biased. > > > quasi > > As to the bias, I had pointed it out quite a while ago. Any random > variable which is a function of a fixed number n of independent > random variables, each say uniformly distributed on the integers from > 1 to 5, CANNOT be uniformly distributed on the integers from 1 to 7, > for the very simple reason that 7 does not divide 5^n.
The following question may be challenging. Imagine an algorithm that A produces a distribution which is uniform on the integers from 1 to 7, by "calling" a random number generator that produces numbers uniformly distributed on the integers from 1 to 5. The number of calls will also be a random variable. Let its mean be m(A). What is the smallest possible value of m(A)? (There is nothing very special here about 5 ann 7.)

