Re: Random numbers



On Sun, 23 Dec 2007 19:46:21 -0800 (PST), bill <b92057@xxxxxxxxx>
wrote:

On Dec 22, 5:25 pm, quasi <qu...@xxxxxxxx> wrote:
On Sat, 22 Dec 2007 16:30:20 -0800 (PST), bill <b92...@xxxxxxxxx>
wrote:

On Dec 22, 10:16 am, quasi <qu...@xxxxxxxx> wrote:
On Fri, 21 Dec 2007 10:57:00 -0800 (PST), simple.pop...@xxxxxxxxx
wrote:

On Dec 21, 11:37 pm, bill <b92...@xxxxxxxxx> wrote:
On Dec 21, 3:16 am, John <iamach...@xxxxxxxxx> wrote:

Given a function that returns a random number between 1-5, write one
that returns a random number between 1-7 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 + (T-7)*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
on the set {1,2,3,4,5,6,7}. While T is clearly biased in the range 7
to 35, apparently (T mod 7) is _unbiased_ in the range 0 to 6. As to
why it's unbiased, I'm not sure. I'll have to think about it.

Just in case my notation is incorrect;
if T = 21, then T mod 7+1 = 1;
If T = 35, T mod 7 +1 = 1.

Right.

The following is the typical result of my simulation.

1 1209
2 1115
3 1180
4 1189
5 1191
6 1131
7 1171
TOT 8186

Looks uniform enough.

I thought it would be badly biased.

Oh well -- at least I was right about the continuous case.

I'm glad you took up the challenge to do a simulation. That's the cool
thing about probability. Very often, a simple experiment is all it
takes to validate a true claim or invalidate a false one (to within a
reasonable doubt).

quasi
.



Relevant Pages

  • Re: Random numbers
    ... is that the resulting distribution should be uniform. ... to use the RNG provided for the range 1 to 5. ... The problem with your previously proposed RNGs was the dependence on ...
    (sci.math)
  • Re: How to test a distribution for uniformity?
    ... > observations occured is roughly uniform. ... > distribution of observation times differs significantly from ... I am using bins (those are my 45 minute ... I wonder is there such a thing as a chi-square test which is adjusted to ...
    (sci.stat.math)
  • Re: How to test a pseudo random prime number generator?
    ... number generators. ... This method is efficient but does not produce a uniform distribution ... approximate distribution of gaps. ...
    (sci.math)
  • Re: random number problem
    ... It's a simple linear transformation. ... your distribution will be ... which is what theory says it should be for a uniform ... If you want a *serious* random number generator, ...
    (comp.programming)
  • Re: Random numbers
    ... But it's still biased (that is, not a unform distribution). ... The OP does not specify a uniform ... is that the resulting distribution should be uniform. ... to use the RNG provided for the range 1 to 5. ...
    (sci.math)

Loading