Skip to content

Commit ae3c850

Browse files
author
Julian Blank
committed
Some modifications
1 parent 1b35b8f commit ae3c850

File tree

17 files changed

+83
-20
lines changed

17 files changed

+83
-20
lines changed

pysample/usage.py

Lines changed: 0 additions & 10 deletions
This file was deleted.
File renamed without changes.

pysample/indicators.py renamed to pysampling/indicators.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@ def centered_l2_discrepancy(X):
2323
_acmh = np.abs(acmh.T[..., None] + acmh.T[:, None, :])
2424

2525
val = np.sum(np.prod((1 + 0.5 * (_acmh - _X)), axis=0))
26-
val = ((13 / 12) ** n_dim - 2 / n_points * np.sum(
27-
np.prod(1 + 0.5 * (acmh - acmh ** 2), axis=1)) + val / n_points ** 2) ** 0.5
26+
27+
val = ((13 / 12) ** n_dim -
28+
2 / n_points * np.sum(np.prod(1 + 0.5 * (acmh - acmh ** 2), axis=1)) + val / n_points ** 2) ** 0.5
2829

2930
return val
3031

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

pysample/methods/sobol.py renamed to pysampling/methods/sobol.py

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,34 @@
88

99
class SobolSampling(Sampling):
1010

11-
def __init__(self, n_skip=-1, n_leap=0, setup="matlab") -> None:
11+
def __init__(self, n_skip=None, n_leap=0, setup="matlab") -> None:
1212
super().__init__()
13-
fname = "sobol_%s.dat" % setup
14-
self.setup = parse_file(path_to_resources(fname))
1513

14+
if setup == "matlab":
15+
if n_skip is None:
16+
n_skip = 0
17+
max_bits = 53
18+
fname = "sobol_matlab.dat"
19+
20+
elif setup == "burkardt":
21+
if n_skip is None:
22+
n_skip = -1
23+
max_bits = 32
24+
fname = "sobol_burkardt.dat"
25+
26+
elif setup == "joekuo":
27+
if n_skip is None:
28+
n_skip = 0
29+
max_bits = 32
30+
fname = "sobol_joekuo.dat"
31+
32+
else:
33+
raise Exception("Unkonwn setup.")
34+
35+
self.setup = parse_file(path_to_resources(fname))
1636
self.n_skip = n_skip
1737
self.n_leap = n_leap
38+
self.max_bits = max_bits
1839

1940
def _sample(self, n_samples, n_dim):
2041

@@ -26,7 +47,7 @@ def _sample(self, n_samples, n_dim):
2647
I += self.n_skip
2748
n_sequence = np.max(I) + 1
2849

29-
# containts all the values of the sequences as integer
50+
# contains all the values of the sequences as integer
3051
_X = np.zeros((n_sequence, n_dim), dtype=np.int)
3152

3253
# number of bits which will be necessary for this sequence
@@ -38,7 +59,7 @@ def _sample(self, n_samples, n_dim):
3859
for j in range(n_dim):
3960

4061
if j == 0:
41-
V = np.concatenate((np.array([0]), 2 ** np.arange(31, -1, -1)))
62+
V = np.concatenate((np.array([0]), 2 ** np.arange(self.max_bits-1, -1, -1)))
4263

4364
else:
4465

@@ -47,12 +68,12 @@ def _sample(self, n_samples, n_dim):
4768

4869
if L <= s:
4970
for k in range(1, L + 1):
50-
V[k] = m[k - 1] << (32 - k)
71+
V[k] = m[k - 1] << (self.max_bits - k)
5172

5273
else:
5374

5475
for k in range(1, s + 1):
55-
V[k] = m[k - 1] << (32 - k)
76+
V[k] = m[k - 1] << (self.max_bits - k)
5677

5778
for i in range(s + 1, L + 1):
5879
V[i] = V[i - s] ^ int(V[i - s] >> s)
@@ -62,7 +83,7 @@ def _sample(self, n_samples, n_dim):
6283
for i in range(1, n_sequence):
6384
_X[i, j] = _X[i - 1, j] ^ V[C[i - 1]]
6485

65-
X = (_X / 2 ** 32)[I]
86+
X = (_X / 2 ** self.max_bits)[I]
6687
return X
6788

6889

File renamed without changes.

0 commit comments

Comments
 (0)