Reputation: 363
When I run the rand
function many times it generates a sequence of random values that follows the uniform distribution, each value is calculated from the previous one, so this whole sequence is for single random variable that have the complete range 0:1
to draw a value from.
Now in my simulation program, I have two independent random variables X,Y
. In each iteration, I should generate a new value for each of them and in sometimes for only one of them. So I generate a value for X
then Y
then X
then Y
... etc. This sequence of generation means that they share the same seed and the 0:1
range, so the sequence of generated numbers before in case of one variable is now distributed over two variables.
I need each variable to have its own independent sequence not sharing the same one. This is for the quality of simulation. Any help with that?
Upvotes: 2
Views: 834
Reputation: 5913
Random Number generators by design, return Independent, Uniformly Distributed random variables. So, there is no concern here. If you are concerned that there will be correlation between x & y, then you need to be concerned that there are correlations between different values of x as well. People work very hard, to make sure that there is zero correlation (no matter what the seed) between different values in a random number generator.
Upvotes: 1
Reputation: 1009
It sounds like you want to create two different instances of RandStream
, like this:
[xstream, ystream] = RandStream.create('mrg32k3a', 'NumStreams', 2)
for ii = 1:1000
x = rand(xstream)
y = rand(ystream)
% compute simulation step here
end
Upvotes: 3