;+ ; NAME: ; haltonseq ; ; ; PURPOSE: ; Return the halton sequence for monte carlo simulations. This is a ; Sub-Random sequence that can improve convergence time for certain ; classes of problems. See Numerical Recipes secton 7.7 and Galanti, ; Silvio, Alan Jung, "Low-Discrepancy Sequences: Monte Carlo ; Simulation of Option Prices", J. Derivatatives, Fall 1997; 5, ; 1; ABI/INFORM Global pg 63 ; ; ; CATEGORY: ; Monte Carlo ; ; ; INPUTS: ; N: the number of values of the halton seq to generate ; ; ; OUTPUTS: ; The first N values of the Halton Sequence ; ; ; EXAMPLE: ; IDL> print, haltonseq(10) ; 0.500000 0.250000 0.750000 0.125000 0.625000 0.375000 0.875000 0.0625000 0.562500 ; ; ; ; MODIFICATION HISTORY: ; ; Fri Mar 14 09:52:28 2008, Brian Larsen ; ; written and tested ; ;- FUNCTION haltonseq, N pwrs = 2L^(lindgen(N)+1) ans = fltarr(N-1) FOR i = 1L, N-1 DO BEGIN exp = reverse(expand_in_base(i, 2)) ans[i-1] = total(pwrs * exp, /double)/2L^(n_elements(exp)+1) ENDFOR RETURN, ans END
Disclaimer