*
* %Halton(n,base)
* generates an n-vector of the Halton sequence for the given base (which
* should be a prime number). Halton sequences are deterministic
* "low-discrepancy" sequences which fill the unit cube relatively
* uniformly (with a different base for each dimension) allowing
* numerical integrals to be estimated more accurately for a given number
* of function evaluations than would be possible with truly random
* numbers.
*
* Revision Schedule:
*  06/2011 Written by Tom Doan, Estima
*
* Reference:
*  Halton, J. (1964), Algorithm 247: Radical-inverse quasi-random point
*    sequence, ACM, p. 701
*
function %Halton n base
type vector %Halton
type integer n base
*
local real 		f
local integer 	i j
*
dim %Halton(n)
*
do j=1,n
   compute %Halton(j)=0.0
   compute f=1.0/base
   compute i=j
   while (i > 0) {
      compute %Halton(j)=%Halton(j)+f*%mod(i,base)
      compute i=i/base
      compute f=f/base
   }
end do j
end

