这个函数是matlab自带的
>> help RandStream
RANDSTREAM Random number stream.
(Pseudo)random numbers in MATLAB come from one or more random number
streams. The simplest way to generate arrays of random numbers is to use
RAND, RANDN, or RANDI. These functions all rely on the same stream of
uniform random numbers, known as the default stream. You can create other
streams that act separately from the default stream, and you can use their
RAND, RANDN, or RANDI methods to generate arrays of random numbers. You can
also create a random number stream and make it the default stream.
To create a single random number stream, use either the RandStream
constructor or the RandStream.CREATE factory method. To create multiple
independent random number streams, use RandStream.CREATE.
STREAM = RandStream.getDefaultStream returns the default random number
stream, i.e., the one currently used by the RAND, RANDI, and RANDN
functions.
PREVSTREAM = RandStream.setDefaultStream(STREAM) returns the current default
stream, and designates the random number stream STREAM as the new default to
be used by the RAND, RANDI, and RANDN functions.
A random number stream S has properties that control its behavior. Access or
assign to a property using P = S.Property or S.Property = P.
RandStream properties:
Type - (Read-only) identifies the type of generator algorithm
used by the stream.
Seed - (Read-only) the seed value used to create the stream.
NumStreams - (Read-only) the number of streams created at the same
time as the stream.
StreamIndex - (Read-only) the stream's index among the group of streams
in which it was created.
State - the internal state of the generator. You should not depend
on the format of this property. The value you assign
to S.State must be a value read from S.State previously.
Substream - the index of the substream to which the stream is
currently set. The default is 1. Multiple substreams are
not supported by all generator types.
RandnAlg - the current algorithm used by RANDN(S, ...) to generate
normal pseudorandom values, one of 'Ziggurat' (the
default), 'Polar', or 'Inversion'.
Antithetic - a logical value indicating whether S generates antithetic
uniform pseudorandom values, that is, the usual values
subtracted from 1. The default is false.
FullPrecision - a logical value indicating whether S generates values
using its full precision. Some generators are able to
create pseudorandom values faster, but with fewer random
bits, if FullPrecision is false. The default is true.
The sequence of pseudorandom numbers produced by a random number stream S is
determined by the internal state of its random number generator. Saving and
restoring the generator's internal state via the 'State' property allows you
to reproduce output.
Examples:
Create three independent streams:
[s1,s2,s3] = RandStream.create('mrg32k3a','NumStreams',3);
r1 = rand(s1,100000,1); r2 = rand(s2,100000,1); r3 = rand(s3,100000,1);
corrcoef([r1,r2,r3])
Create only one stream from a set of three independent streams:
s2 = RandStream.create('mrg32k3a','NumStreams',3,'StreamIndices',2);
Reset the generator for the default stream that underlies RAND, RANDI,
and RANDN back to the beginning to reproduce previous results:
reset(RandStream.getDefaultStream);
Save and restore the default stream's state to reproduce the output of
RAND:
defaultStream = RandStream.getDefaultStream;
savedState = defaultStream.State;
u1 = rand(1,5)
defaultStream.State = savedState;
u2 = rand(1,5) % contains exactly the same values as u1
Return RAND, RANDI, and RANDN to their default initial settings:
s = RandStream.create('mt19937ar','seed',5489);
RandStream.setDefaultStream(s);
Replace the default stream with a stream whose seed is based on CLOCK, so
RAND will return different values in different MATLAB sessions. NOTE: It
is usually not desirable to do this more than once per MATLAB session.
s = RandStream.create('mt19937ar','seed',sum(100*clock));
RandStream.setDefaultStream(s);
Select the algorithm that RANDN uses:
defaultStream = RandStream.getDefaultStream;
defaultStream.RandnAlg = 'inversion';
RandStream methods:
RandStream/RandStream - Create a random number stream.
create - Create multiple independent random number streams.
list - List available random number generator algorithms.
getDefaultStream - Get the default random number stream.
setDefaultStream - Set the default random number stream.
reset - Reset a stream to its initial internal state.
rand - Pseudorandom numbers from a uniform distribution.
randn - Pseudorandom numbers from a standard normal distribution.
randi - Pseudorandom integers from a uniform discrete distribution.
randperm - Random permutation.
See also randfun/rand, randfun/randn, randfun/randi.
Reference page in Help browser
doc RandStream
这个函数是matlab自带的
>> help RandStream
RANDSTREAM Random number stream.
(Pseudo)random numbers in MATLAB come from one or more random number
streams. The simplest way to generate arrays of random numbers is to use
RAND, RANDN, or RANDI. These functions all rely on the same stream of
uniform random numbers, known as the default stream. You can create other
streams that act separately from the default stream, and you can use their
RAND, RANDN, or RANDI methods to generate arrays of random numbers. You can
also create a random number stream and make it the default stream.
To create a single random number stream, use either the RandStream
constructor or the RandStream.CREATE factory method. To create multiple
independent random number streams, use RandStream.CREATE.
STREAM = RandStream.getDefaultStream returns the default random number
stream, i.e., the one currently used by the RAND, RANDI, and RANDN
functions.
PREVSTREAM = RandStream.setDefaultStream(STREAM) returns the current default
stream, and designates the random number stream STREAM as the new default to
be used by the RAND, RANDI, and RANDN functions.
A random number stream S has properties that control its behavior. Access or
assign to a property using P = S.Property or S.Property = P.
RandStream properties:
Type - (Read-only) identifies the type of generator algorithm
used by the stream.
Seed - (Read-only) the seed value used to create the stream.
NumStreams - (Read-only) the number of streams created at the same
time as the stream.
StreamIndex - (Read-only) the stream's index among the group of streams
in which it was created.
State - the internal state of the generator. You should not depend
on the format of this property. The value you assign
to S.State must be a value read from S.State previously.
Substream - the index of the substream to which the stream is
currently set. The default is 1. Multiple substreams are
not supported by all generator types.
RandnAlg - the current algorithm used by RANDN(S, ...) to generate
normal pseudorandom values, one of 'Ziggurat' (the
default), 'Polar', or 'Inversion'.
Antithetic - a logical value indicating whether S generates antithetic
uniform pseudorandom values, that is, the usual values
subtracted from 1. The default is false.
FullPrecision - a logical value indicating whether S generates values
using its full precision. Some generators are able to
create pseudorandom values faster, but with fewer random
bits, if FullPrecision is false. The default is true.
The sequence of pseudorandom numbers produced by a random number stream S is
determined by the internal state of its random number generator. Saving and
restoring the generator's internal state via the 'State' property allows you
to reproduce output.
Examples:
Create three independent streams:
[s1,s2,s3] = RandStream.create('mrg32k3a','NumStreams',3);
r1 = rand(s1,100000,1); r2 = rand(s2,100000,1); r3 = rand(s3,100000,1);
corrcoef([r1,r2,r3])
Create only one stream from a set of three independent streams:
s2 = RandStream.create('mrg32k3a','NumStreams',3,'StreamIndices',2);
Reset the generator for the default stream that underlies RAND, RANDI,
and RANDN back to the beginning to reproduce previous results:
reset(RandStream.getDefaultStream);
Save and restore the default stream's state to reproduce the output of
RAND:
defaultStream = RandStream.getDefaultStream;
savedState = defaultStream.State;
u1 = rand(1,5)
defaultStream.State = savedState;
u2 = rand(1,5) % contains exactly the same values as u1
Return RAND, RANDI, and RANDN to their default initial settings:
s = RandStream.create('mt19937ar','seed',5489);
RandStream.setDefaultStream(s);
Replace the default stream with a stream whose seed is based on CLOCK, so
RAND will return different values in different MATLAB sessions. NOTE: It
is usually not desirable to do this more than once per MATLAB session.
s = RandStream.create('mt19937ar','seed',sum(100*clock));
RandStream.setDefaultStream(s);
Select the algorithm that RANDN uses:
defaultStream = RandStream.getDefaultStream;
defaultStream.RandnAlg = 'inversion';
RandStream methods:
RandStream/RandStream - Create a random number stream.
create - Create multiple independent random number streams.
list - List available random number generator algorithms.
getDefaultStream - Get the default random number stream.
setDefaultStream - Set the default random number stream.
reset - Reset a stream to its initial internal state.
rand - Pseudorandom numbers from a uniform distribution.
randn - Pseudorandom numbers from a standard normal distribution.
randi - Pseudorandom integers from a uniform discrete distribution.
randperm - Random permutation.
setDefaultStream 在matlab7.7(2008b)及其以上的版本中才有该函数,但是在2012a(2012a中会出现警告、2013a直接提示错误)及其以后的版本中中该函数改名字了,改成了 RandStream.setGlobalStream。
网页链接这是该函数的更新记录
这个函数是自带的哈
是啥子原因没有查到
可以重装试试嘛