Re: Length of cycle for random numbers
- From: Gib Bogle <bogle@xxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Sat, 21 Jul 2007 13:25:06 +1200
Joseph K. wrote:
On Fri, 20 Jul 2007 16:30:21 -0600, "Jim Hewitt"
<jim.hewitt@xxxxxxxxxxxxxxx> wrote:
"Joseph K." <nihil@xxxxxxxx> wrote in message news:1jc2a31vm6kt9ieubifnv0c0nr30b0o1o5@xxxxxxxxxxHi Matlab experts:"Random" numbers in computers are pseudo-random, which includes repeating he sequence though it is usually are large enough count before it repeats. Given the same seed, the generator will produce htesame sequence. The solution is to reset the seed every now and then using something quasi-random.
I've carried out intensive calculations using randn in many parts of
my code and I have noticed that in some replicate runs exactly the
same resuls have been produced. I think I've reached some sort of
limit cycle in the random number generator. How can I avoid this
behavior? Do I need to set randn to some unique state in the very
first few lines every time I run again my program?
TIA
Joseph K.
randn('state',sum(100*clock)) Resets it to a different state each time.
Jim
Thanks Jim.
I thought that Matlab by default reset the seed using the clock every
time the random number generator (rng) was called.
Is this another option?:
randn('state',j)
where 'j' is entered by the user when the program starts and it asks
to write 'a large integer typed haphazardly'.
I'm not sure because 'j' may necessarily be a previous state of the
rng rather than any integer.
It is a good idea to have the option of setting the seed yourself, because it means you can replicate a run if necessary. You could code it so that when the user enters a seed of zero (for example) the seed is generated from the time. Note that, as someone else mentioned, the seed should be specified just once, at the start of the run - this defines a unique pseudo-random sequence.
.
- Follow-Ups:
- Re: Length of cycle for random numbers
- From: Dave Bell
- Re: Length of cycle for random numbers
- From: Joseph K .
- Re: Length of cycle for random numbers
- References:
- Length of cycle for random numbers
- From: Joseph K .
- Re: Length of cycle for random numbers
- From: Jim Hewitt
- Re: Length of cycle for random numbers
- From: Joseph K .
- Length of cycle for random numbers
- Prev by Date: Re: Is a QR Decomposition Better than B \ A?
- Next by Date: Re: Using fzero with ppval
- Previous by thread: Re: Length of cycle for random numbers
- Next by thread: Re: Length of cycle for random numbers
- Index(es):
Relevant Pages
|