Last active
May 1, 2019 02:34
-
-
Save hktosun/d25671de6d0817f910482d73f9dfd5d1 to your computer and use it in GitHub Desktop.
Halton draws
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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