Skip to content

Instantly share code, notes, and snippets.

@hktosun
Last active May 1, 2019
Embed
What would you like to do?
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