|
Thanks a lot for your explanation. That was a crucial thing to understand. I am a biologist trying to design some physiology experiments, so my math is far from developed.
How about if i 'seed' the rand function at each iteration ?:
for i = 1:90000
rand ('state', i);
randmonoisematrix = rand (45, 45);
end
Intuitively, this the same as sampling a random space of values, and perchance the subsample would be random as well). The goal for me is not necessarily to alter the stimulus on each presentation, but rather to ensure that the "surface" of the matrix is as "diverse" as possible, in the x,y dimension, as well as in the temporal one, for the duration of the stimulus. I imagine this would not work if there is some periodicity of the sequence that can add up to the integer value.
Thanks again for your insight. Is there a refference that describes the math behind the rand and randn functions ?
Tudor
>
> > I find that if i run the iteration above repeatedly, to any given point
> > ( say 43001) i get back the same randomnoise matrix as expected, however if i ask for
> > rand ('state', 43001)
> > randmonoisematrix = rand (45, 45) i get a completely different output.
> > I other words, it appears that the state 0 is not followed by the state 1, 2, 3 etc.
>
> Correct. The state is used to initialize the internal binary data used in
> the pseudo-random number generator. The state is not a counter of how many
> values have been produced.
>
> > The reason i want to do this is because i do not want to have to run each time
> > through the whole sequence to get to my epoch of interest, but rather would like
> > to "skip" ahead to the state i want (inbetween 43000 and 43060 for example).
>
> You will have to create your own random number generator then. For example, you
> could MD5 the state number, extract some bits from the MD5 and typecast() the
> result to a floating point number.
>
> Or you could research one of the linear congruential pseudo random number generators.
> Although they are usually processed sequentially, if you go back to the theory
> of them, you could go directly to any particular state without a lot more work
> than raising a large number to a power (the state number) modulo a large number.
> You would have to use indefinite precision arithmetic to do it the naive way as
> the values get *huge*, but fortunately you can take advantage of the fact that
> the number and the modulus will be relatively prime (for any PRNG of maximum
> length) and there are theorems that in that case allow the work to be done to
> be reduced enormously (to a practical level, if you have the right software.)
|