Yes it does, however it is important to know that the output of p_to_x1.m is deterministic. If changing the state of the random number generator is undesirable for your approach, please consider the following pseudo code for a workaround.
% create a randstream for your application
stream = RandStream(‘mt19937ar’,’Seed’,0); % Lots of options on how to create a stream
RandStream.setGlobalStream(stream); % set this as the global stream
% lots of code here, e.g.,
u1 = rand(1,5)
u1 = rand(1,5)
stream = RandStream.getGlobalStream; % at anytime retrieve the previously created stream
savedState = stream.State; % grab the stream state
% call challenge functions
h1 = p_to_x1(…..)
RandStream.setGlobalStream(stream);
stream.State = savedState;
% continue coding using your previous, now interrupted stream
This should provide an uninterrupted stream. There are probably other (better) ways to do this. See the test code below to check if this provides the desired functionality.
Sample code follows:
% cut and paste into Matlab
stream = RandStream(‘mt19937ar’,’Seed’,0);
RandStream.setGlobalStream(stream);
u1 = rand(1,5)
u2 = rand(1,5)
u3 = rand(1,5)
% intentionally reset stream to test if working
stream = RandStream(‘mt19937ar’,’Seed’,0);
RandStream.setGlobalStream(stream);
u1s = rand(1,5) % this should match the u1 vector above.
u2s = rand(1,5) % this should match the u2 vector above.
stream = RandStream.getGlobalStream;
savedState = stream.State;
% call challenge function that changes the stream
h1 = p_to_x1(0.1:0.1:0.5)
RandStream.setGlobalStream(stream);
stream.State = savedState;
u3s = rand(1,5) % this should match the u3 vector above.