Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Скачиваний:
18
Добавлен:
09.02.2015
Размер:
73.22 Кб
Скачать

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

<RandStream/create> - Create parallel random number streams.

RANDSTREAM.CREATE Create multiple independent random number streams.

[S1,S2,...] = RandStream.CREATE('GENTYPE','NumStreams',N) creates N random

number streams that use the uniform pseudorandom number generator algorithm

specified by GENTYPE, and that are independent in a pseudorandom sense.

These streams are not necessarily independent from streams created at other

times. Multiple streams are not supported by all generator types. Type

RandStream.LIST for a list of possible values for GENTYPE, and DOC

RandStream for details on these generator algorithms.

S = RandStream.CREATE('GENTYPE') creates a single random stream.

[ ... ] = RandStream.CREATE(..., 'PARAM1',val1, 'PARAM2',val2, ...) allows

you to specify optional parameter name/value pairs to control creation of

the stream(s). Parameters are:

NumStreams - the total number of streams of this type that will be

created, across sessions or labs. Default is 1.

StreamIndices - the stream indices that should be created in this call.

Default is 1:N, where N is the value given with the

'NumStreams' parameter.

Seed - a non-negative scalar integer seed with which to

Initialize all streams. Default is 0.

RandnAlg - the algorithm that will be used by RANDN(S, ...) to

generate normal pseudorandom values, one of

'Ziggurat' (the default), 'Polar', or 'Inversion'.

CellOutput - a logical flag indicating whether or not to return the

stream objects as elements of a cell array. Default is

false.

'NumStreams', 'StreamIndices', and 'Seed' can be used to ensure that

multiple streams created at different times are independent. Streams of the

same type and created using the same value for 'NumStreams' and 'Seed', but

with different values of 'StreamIndices', are independent even if they were

created in separate calls to RandStream.CREATE. Instances of different

generator types may not be independent.

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, and

designate it as the default stream:

s2 = RandStream.create('mrg32k3a','NumStreams',3,'StreamIndices',2);

RandStream.setDefaultStream(s2);

See also RandStream, RandStream/RandStream, RandStream/list,

RandStream/getDefaultStream, RandStream/setDefaultStream,

RandStream/rand, RandStream/randi, RandStream/randn.

<RandStream/getDefaultStream> - Get the current default random number stream.

RANDSTREAM.GETDEFAULTSTREAM Get the default random number stream.

STREAM = RandStream.getDefaultStream returns the default random number

stream, i.e., the one currently used by the RAND, RANDI, and RANDN

functions.

RAND, RANDI, and RANDN all rely on the same stream of uniform pseudorandom

numbers, known as the default stream. RANDI uses one uniform value from the

default stream to generate each integer value; RANDN uses one or more

uniform values from the default stream to generate each normal value. Note

that there are also RAND, RANDI, and RANDN methods for which you specify a

specific random stream from which to draw values.

See also RandStream, RandStream/setDefaultStream, randfun/rand,

randfun/randn, randfun/randi.

<RandStream/setDefaultStream> - Set the current default random number stream.

RANDSTREAM.SETDEFAULTSTREAM Set the default random number stream.

PREVSTREAM = RandStream.setDefaultStream(STREAM) returns the current default

random number stream, and designates the random number stream STREAM as the

new default to be used by the RAND, RANDI, and RANDN functions.

RAND, RANDI, and RANDN all rely on the same stream of uniform pseudorandom

numbers, known as the default stream. RANDI uses one uniform value from the

default stream to generate each integer value; RANDN uses one or more

uniform values from the default stream to generate each normal value. Note

that there are also RAND, RANDI, and RANDN methods for which you specify a

specific random stream from which to draw values.

See also RandStream, RandStream/getDefaultStream, randfun/rand,

randfun/randn, randfun/randi.

Соседние файлы в папке Библиотеки Matlab