<< lowdisc_new Sequences lowdisc_startup >>

Low Discrepancy >> Low Discrepancy > Sequences > lowdisc_next

lowdisc_next

Returns the next term of the sequence

Calling Sequence

[this,next] = lowdisc_next ( this )
[this,next] = lowdisc_next ( this , imax )

Parameters

this:

the current object

imax:

a 1-by-1 matrix of doubles, integer value, the number of terms to retrieve (default imax = 1)

next :

a imax-by-s matrix of doubles, the next vector in the sequence. The experiment #i is stored at next(i,:) for i=1,2,...,imax. The component #j of experiment #i is stored in next(i,j) with j=1,2,...,s.

Description

The current object is updated after the call to next : both this and next are mandatory output arguments. This function is sensitive to the "-leap" option.

Fast sequences are based on the intermediate storage of the iteration index on a 32 bits C int. This implies that these sequences are able to generate at most 2^32-1 = 4 294 967 295 experiments.

The number of simulations might be computed so that it improves the discrepancy of the sequence. This is especially true for the Sobol, Faure and Niederreiter sequences. This can lead to some trouble for non-experts. For that purpose, we designed the following functions.

This function is sensitive to the "-coordinate" option. If "-coordinate" is false (the default), then next is a imax-by-s matrix of doubles. If "-coordinate" is false (the default), then next is a imax-by-1 matrix of doubles. In this case it contains the dimension-th coordinate of the sequence. See lowdisc_configure for more details on this feature.

Examples

lds = lowdisc_new("halton");
// Term #1
[lds,computed] = lowdisc_next (lds);
disp(computed)
// Term #2
[lds,computed] = lowdisc_next (lds);
disp(computed)
// Term #3, etc...
[lds,computed] = lowdisc_next (lds);
disp(computed)
lds
lds = lowdisc_destroy(lds);

// See the imax parameter in action
lds = lowdisc_new("halton");
// Term #1 to 100
[lds,computed] = lowdisc_next (lds,100);
// Term #101 to 201
[lds,computed] = lowdisc_next (lds,100);
lds
lds = lowdisc_destroy(lds);

// See the -leap option in action
lds = lowdisc_new("halton");
lds = lowdisc_configure(lds,"-leap",10);
// Term #1
[lds,computed] = lowdisc_next (lds);
// Term #11
[lds,computed] = lowdisc_next (lds);
// Term #21
[lds,computed] = lowdisc_next (lds);
lds
lds = lowdisc_destroy(lds);

// See the -skip option in action.
lds = lowdisc_new("faure");
lds = lowdisc_configure(lds,"-dimension",4);
// Skip qs^4 - 1 terms, as in TOMS implementation
qs = lowdisc_get ( lds , "-faureprime" );
lds = lowdisc_configure(lds,"-skip", qs^4 - 2);
lds
[lds,computed]=lowdisc_next(lds);
// Terms #1 to #100
[lds,computed]=lowdisc_next(lds,100);
for i = 1:100
mprintf ("%8d %14.6f %14.6f %14.6f %14.6f\n", ...
i , computed(i,1) , computed(i,2) , computed(i,3) , computed(i,4) )
end
lds = lowdisc_destroy(lds);

// Configure a list of primes and use it
lds = lowdisc_new("halton");
// Get a table of primes
prarray = number_primes1000 ( );
// Configure the primes list of the sequence
lds = lowdisc_configure(lds,"-primeslist",prarray);
lds = lowdisc_configure(lds,"-dimension",150);
lds = lowdisc_startup (lds);
[lds,next] = lowdisc_next ( lds , 10 );
assert_checkequal ( size(next) , [10 150] );
lds = lowdisc_destroy(lds);

// See the -coordinate option in action.
// Show how to get the 12-th coordinate of the
// Halton sequence.
lds = lowdisc_new("halton");
lds = lowdisc_configure(lds,"-dimension",12);
lds = lowdisc_configure(lds,"-coordinate",%t);
// Elements #1,...,#5, coordinate index = 12.
[lds,computed] = lowdisc_next (lds,5);
disp(computed)
// Elements #6,...,#10, coordinate index = 12.
[lds,computed] = lowdisc_next (lds,5);
disp(computed)
lds = lowdisc_destroy(lds);

Authors


Report an issue
<< lowdisc_new Sequences lowdisc_startup >>