[Date Index]
[Thread Index]
[Author Index]
RE: random numbers?
*To*: mathgroup at smc.vnet.net
*Subject*: [mg46140] RE: [mg46110] random numbers?
*From*: "Owen, HL (Hywel)" <H.L.Owen at dl.ac.uk>
*Date*: Sat, 7 Feb 2004 04:03:00 -0500 (EST)
*Sender*: owner-wri-mathgroup at wolfram.com
Random numbers are notoriously tricky, and there is no general 'best' random
number generator. The key things you should know about random number
generators:
1. There are basically two types of random number generation:
a. Pseudo-random - choose a number from a sequence. By selecting the same
'seed' (i.e. initial value in the sequence) you can repeat your simulation -
handy for ironing out bugs. Of course, pseudo-random numbers are not
actually random at all. Most computer random number generators use this
method.
b. Selecting a number from the machine you're using, e.g. the number of
milliseconds elapsed since you last asked for the time, and then combining
it some formula to give you an answer. You have to very careful here to
ensure there are no correlations/repeats in your numbers that you're not
aware of - this happens a lot more than you might think. And of course you
can't repeat your results.
2. A good working definition of what makes a good random number sequence,
for a particular problem, is one that does not have a correlation with the
maths/physics of the system you're simulating.
This comes about in particular when you have to model a system using
'macroparticles' rather than individual particles, e.g. watching how a
system of charges evolves under e-m forces, where you couldn't model all
10^9 particles in a simulation but would instead look at, say, 10^4
macroparticles. Depending on the system at hand, you might have to:
a. Use a pseudo-random sequence. But this can cause artificial 'clumping'
(i.e. correlations) which wouldn't be there in the real system. Avoid if
your system is sensitive to such clumping.
b. Use a regular sequence, e.g. Hammersley or similar, where you
artificially smooth out your initial distribution. However, a Hammersley
sequence has its own correlations which may be problematic in certain
situations.
c. Use one of these sequences, but modify your simulation to take account of
the correlation effects that could arise, and interpret your results
accordingly.
3. Most random number generators that you encounter are pitifully bad. e.g.
most in-built compiler random number generators, the terrible routine in
Numerical Recipes (actually, the whole book is pretty rubbish IMHO) etc.
Don't use any random number generator routine for anything serious - at all
- without understanding how it works and whether it's ok for your
simulation. The Mathematica ones are pretty good, not surprisingly.
4. There are various good tests of randomness available, and some people
produce tables of random numbers that you can use that pass these tests
(some people even sell CDs of the stuff). See for example the NIST page on
the subject:
http://csrc.nist.gov/rng/
> -----Original Message-----
> From: sean_incali at yahoo.com [mailto:sean_incali at yahoo.com]
To: mathgroup at smc.vnet.net
> Sent: 06 February 2004 09:16
> To: mathgroup at smc.vnet.net
> Subject: [mg46140] [mg46110] random numbers?
>
>
> hello group.
>
> this is gonna sound silly.
>
> How do ppl make random number generators? is a random number
> generator like a routine that picks a given set of different number
> then goes back to the beginning and starts over?
>
> How does mathematica determine if a numbder is random? or is that
> even a right question to ask?
>
> I just wanted to know what the random generator is. and how it's used
> in Mathematica.
>
> maybe i'm asking alot.
>
> thanks in advance
>
Prev by Date:
**Re: Specifying arguments inside nested functions**
Next by Date:
**Re: random numbers?**
Previous by thread:
**Re: random numbers?**
Next by thread:
**Re: random numbers?**
| |