Returns the next term of the sequence
[this,next] = lowdisc_next ( this ) [this,next] = lowdisc_next ( this , imax )
the current object
a 1-by-1 matrix of doubles, integer value, the number of terms to retrieve (default imax = 1)
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
.
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.
lowdisc_haltonsuggest
: provides settings for the Halton sequence,lowdisc_fauresuggest
: provides settings for the Faure sequence,lowdisc_sobolsuggest
: provides settings for the Sobol sequence,lowdisc_niedersuggest
: provides settings for the Niederreiter sequence.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.
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); | ![]() | ![]() |