Main Content

reset

R2026b

Reset quasirandom number stream

Syntax

Description

reset(q) resets the quasirandom number stream object q to its initial state. You can also reset the stream using q.State=1.

example

Examples

collapse all

Create a quasirandom number stream from a Halton sequence. Omit the first 1000 points in the sequence from the stream and the next 100 points after each generated number. Generate points from the stream, and then set the stream back to its original state.

q = qrandstream("halton",3,Skip=1e3,Leap=1e2)
q = 
Halton quasi-random stream in 3 dimensions

Point set properties:
              Skip : 1000
              Leap : 100
    ScrambleMethod : none

q is a qrandstream object that contains the point set and parameters for a three-dimensional quasirandom number stream. q generates numbers from the Halton sequence.

Generate four points from q.

X = qrand(q,4)
X = 4×3

    0.0928    0.3475    0.0051
    0.6958    0.2035    0.2371
    0.3013    0.8496    0.4307
    0.9087    0.5629    0.6166

The rows of X contain the first four points in the stream, and the columns of X correspond to the dimensions of the points.

Display the State property of q.

q.State
ans = 
5

The State property shows that the index of the next point in the number stream is 5.

Reset State to 1 and generate another point from q.

reset(q)
q.State
ans = 
1
x1 = qrand(q)
x1 = 1×3

    0.0928    0.3475    0.0051

x1 is identical to the first row in X because they both contain the first point in the stream.

Input Arguments

collapse all

Quasirandom number stream, specified as a qrandstream object.

Version History

Introduced in R2008a

See Also

| |