Chronology Current Month Current Thread Current Date
[Year List] [Month List (current year)] [Date Index] [Thread Index] [Thread Prev] [Thread Next] [Date Prev] [Date Next]

Re: [Phys-L] From a Math Prof (physics BS major) at my institution ( math challenge)



I don't know if I trust my own hat-rustling skills enough to call it a
perfect RNG. (As John D. pointed out, it's not too hard to bias a coin
flip. My hat-randomness likely scales with the number of objects
jostling each other in the hat, and perhaps also with caffeine level.)

In terms of pseudo-RNGs, there are several statistical tests, like
Knuth's serial and gap tests, and some in the "DieHard battery", that
look for the sort of bias that would skew a "throw out and re-roll"
strategy. I'd expect any pRNG worth its salt to pass these. After
all, Metropolis and similar rejection-sampling methods do the
equivalent of "throwing away" samples all the time.

This raises a question. In a simulation code, I might need to generate
random numbers for energies, particle displacements, and branch
conditions, all intermingled. Do I go to the same pRNG well for all of
my random number needs, or is it prudent to use different pRNGs (perhaps
the same algorithm but with different seeds) for each type of quantity?

- Craig


On Wed, 26 Feb 2014 14:19:35 -0600
Paul Nord <paul.nord@valpo.edu> wrote:

Craig,

It doesn’t matter for your example because pulling real numbers out
of a hat is a perfect random number generator. And for this reason,
solving the problem analytically, as you have done, is better than
the Montecarlo method of generating random numbers.

However, when generating random numbers with an algorithm, clipping
sections out of the distribution can change the outcome.

I would bet that randperm() is careful not to make this mistake.

Paul



On Feb 26, 2014, at 1:38 PM, Craig Wiegert <wiegert@physast.uga.edu>
wrote:

It doesn't matter, aside from efficiency.

If I put 6 numbers in a hat and draw two without replacement, then
there are 30 equally likely outcomes (preserving the order of the
numbers that are picked).

Now let's say I put 6 numbers in a hat and draw two *with*
replacement, but with the condition that if the second draw is the
same number as the first, I put it back and redo my second draw
until I get a different result. Let's calculate the probability
that the two numbers end up being "1" and "2", in that order.
Well, the first draw picks "1" with probability 1/6. The second
draw picks "2" 1/6 of the time... or "1" 1/6 of the time, in which
case I redo. That redo similarly picks "2" 1/6 of the time, or "1"
1/6 of the time which would mean *another* redo, and so on.

The probability that the second draw ends up being "2" after as many
redos as it takes is
1/6 (zero redos) + 1/36 (one redo) + 1/216 (two redos) + ... = 1/5.
So the overall chance of picking "1" and then "2" is 1/30. Aside
from being distinct, "1" and "2" aren't special, thus all of the
ordered pairs of distinct numbers occur with equal probability 1/30.

I'm by no means proficient in matlab/octave, but it seems like all
of this choosing code could be replaced with calls to randperm(35,
5).

- Craig

_______________________________________________
Forum for Physics Educators
Phys-l@phys-l.org
http://www.phys-l.org/mailman/listinfo/phys-l