Hauptinhalt

rand

R2026b

Generate quasirandom points from stream

Description

X = rand(q) returns the next point X in the quasirandom number stream q. q must be one-dimensional.

X = rand(q,n) returns the next n quasirandom number stream points. n must equal the dimension of q.

example

X = rand(q,n,p) returns the next n quasirandom number stream points, where p is the dimension of q. Use this syntax when you want to return n points from a stream with dimension p ≠ n.

example

Examples

collapse all

Create a quasirandom number stream from a Halton sequence. Use the default properties and dimension p=3.

p = 3;
q = qrandstream("halton",p)
q = 
Halton quasi-random stream in 3 dimensions

Point set properties:
              Skip : 0
              Leap : 0
    ScrambleMethod : none

Return n=p points from the p-dimensional stream using the rand function.

n = p;
X1 = rand(q,n)
X1 = 3×3

         0         0         0
    0.5000    0.3333    0.2000
    0.2500    0.6667    0.4000

Return n=5 additional points from the stream. Because n does not equal p, you must specify the third input argument.

n = 5;
X2 = rand(q,n,p)
X2 = 5×3

    0.7500    0.1111    0.6000
    0.1250    0.4444    0.8000
    0.6250    0.7778    0.0400
    0.3750    0.2222    0.2400
    0.8750    0.5556    0.4400

Input Arguments

collapse all

Quasirandom number stream, specified as a qrandstream object.

Number of quasirandom points, specified as a positive integer. n must equal the dimension of q if you do not specify p.

Dimension of the quasirandom number stream q, specified as a positive integer. You must specify p when n does not equal the dimension of q.

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

| | |