Skip to content

Instantly share code, notes, and snippets.

@hktosun
Last active May 1, 2019 02:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hktosun/d25671de6d0817f910482d73f9dfd5d1 to your computer and use it in GitHub Desktop.
Save hktosun/d25671de6d0817f910482d73f9dfd5d1 to your computer and use it in GitHub Desktop.
Halton draws
def halton(prime, N):
step = 1;
k = 0;
x = [0];
while(True):
t = len(x);
for i in range(1,prime):
for j in range(t):
x.append(i/(prime**step) + x[j])
k = k + 1;
if(k >= N):
y = norm.ppf(x)[1:];
return(y)
step = step + 1;
def multi_halton(N, dim):
z = np.empty((N,1))
primes = [2,3,5,7,11,13,17,19,23,29,31,37,41];
for i in range(dim):
z = np.column_stack((z, halton(primes[i], N)))
return(z[:, 1:])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment