Main Content

qrand

R2026b

Generate quasirandom points from stream

Description

X = qrand(q) returns the next point X in the quasirandom number stream q.

example

X = qrand(q,n) returns the next n quasirandom number stream points X.

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.

Number of quasirandom points, specified as a positive integer.

Output Arguments

collapse all

Quasirandom points, returned as an n-by-d numeric matrix, where d is the dimension of the quasirandom number stream q. The function sets the State property of q to the index of the next value in the underlying point set.

Version History

Introduced in R2008a

See Also

| |