Main Content

scramble

Scramble quasirandom point set

Description

ps = scramble(p,type) returns a scrambled copy ps of the point set p, created using the scramble type specified by type. The point set p is either a haltonset or sobolset object, and each type of point set supports a different scramble type.

The scrambled point set ps is the same kind of object as p.

example

ps = scramble(p,'clear') removes the scramble setting from p and returns the result in ps.

example

ps = scramble(p) reapplies the existing scramble setting to p, which typically results in a different point set because of the randomness of the scrambling algorithms.

example

Examples

collapse all

Generate a three-dimensional Halton point set, skip the first 1000 values, and then retain every 101st point.

p = haltonset(3,'Skip',1e3,'Leap',1e2)
p = 
Halton point set in 3 dimensions (89180190640991 points)

Properties:
              Skip : 1000
              Leap : 100
    ScrambleMethod : none

Apply reverse-radix scrambling by using scramble.

p = scramble(p,'RR2')
p = 
Halton point set in 3 dimensions (89180190640991 points)

Properties:
              Skip : 1000
              Leap : 100
    ScrambleMethod : RR2

Generate the first four points by using net.

X0 = net(p,4)
X0 = 4×3

    0.0928    0.6950    0.0029
    0.6958    0.2958    0.8269
    0.3013    0.6497    0.4141
    0.9087    0.7883    0.2166

Generate every third point, up to the eleventh point, by using parenthesis indexing.

X = p(1:3:11,:)
X = 4×3

    0.0928    0.6950    0.0029
    0.9087    0.7883    0.2166
    0.3843    0.9840    0.9878
    0.6831    0.7357    0.7923

Create and scramble a five-dimensional Sobol point set. Specify the 'MatousekAffineOwen' scramble type.

p = sobolset(5);
ps = scramble(p,'MatousekAffineOwen');

Compare the first four points in the two point sets.

X = net(p,4)
X = 4×5

         0         0         0         0         0
    0.5000    0.5000    0.5000    0.5000    0.5000
    0.2500    0.7500    0.2500    0.7500    0.2500
    0.7500    0.2500    0.7500    0.2500    0.7500

X2 = net(ps,4)
X2 = 4×5

    0.6681    0.2784    0.2476    0.5688    0.0513
    0.4485    0.6735    0.5417    0.3285    0.9719
    0.9940    0.9606    0.3515    0.1586    0.4742
    0.1550    0.1202    0.9226    0.9262    0.5491

Remove the scramble setting from ps by using the 'clear' option. The point set clearps matches the original point set p.

clearps = scramble(ps,'clear');
clearX = net(clearps,4)
clearX = 4×5

         0         0         0         0         0
    0.5000    0.5000    0.5000    0.5000    0.5000
    0.2500    0.7500    0.2500    0.7500    0.2500
    0.7500    0.2500    0.7500    0.2500    0.7500

Pass ps to the scramble function without additional input arguments. The software removes the scramble setting from ps and then reapplies it. Because of the randomness of the scrambling algorithm, the new scrambled point set newps differs from the original scrambled point set ps.

newps = scramble(ps);
newX = net(newps,4)
newX = 4×5

    0.6882    0.6261    0.9298    0.3314    0.4169
    0.2442    0.1978    0.4307    0.6286    0.8666
    0.7827    0.2868    0.5172    0.8430    0.1261
    0.2772    0.8576    0.0164    0.1404    0.5905

Input Arguments

collapse all

Point set, specified as either a haltonset or sobolset object.

Example: sobolset(5)

Scramble type, specified as 'RR2' or 'MatousekAffineOwen'. Different point sets support different scramble types, as indicated in this table.

ObjectScramble Type
haltonset

'RR2' — A permutation of the radical inverse coefficients derived by applying a reverse-radix operation to all of the possible coefficient values. The scramble is described in [2].

sobolset

'MatousekAffineOwen' — A random linear scramble combined with a random digital shift. The scramble is described in [1].

References

[1] Hong, H. S., and F. J. Hickernell. “Algorithm 823: Implementing Scrambled Digital Sequences.” ACM Transactions on Mathematical Software. Vol. 29, No. 2, 2003, pp. 95–109.

[2] Kocis, L., and W. J. Whiten. “Computational Investigations of Low-Discrepancy Sequences.” ACM Transactions on Mathematical Software. Vol. 23, No. 2, 1997, pp. 266–294.

[3] Matousek, J. “On the L2-Discrepancy for Anchored Boxes.” Journal of Complexity. Vol. 14, No. 4, 1998, pp. 527–556.

Version History

Introduced in R2008a