Skip to content

Commit

Permalink
Fixed edge case in vegas
Browse files Browse the repository at this point in the history
  • Loading branch information
gomezzz committed Aug 20, 2021
1 parent 27d8fe1 commit 6be0131
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion torchquad/integration/vegas.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,8 @@ def _warmup_grid(self, warmup_N_it=5, N_samples=1000):
jf = 0 # jacobians * function
jf2 = 0

yrnd = torch.rand(size=[N_samples, self._dim])
# Multiplying by 0.99999999 as the edge case of y=1 leads to an error
yrnd = torch.rand(size=[N_samples, self._dim]) * 0.999999
x = self.map.get_X(yrnd)
f_eval = self._eval(x).squeeze()
jac = self.map.get_Jac(yrnd)
Expand Down
6 changes: 3 additions & 3 deletions torchquad/integration/vegas_stratification.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,9 @@ def get_Y(self, nevals):
indices = self._get_indices(indices)

# Get random numbers (we get a few more just to vectorize properly)
# This might increase the memorz requirements slightly but is probably
# worth it
random_uni = torch.rand(size=[len(nevals), nevals.max(), self.dim])
# This might increase the memory requirements slightly but is probably
# worth it.
random_uni = torch.rand(size=[len(nevals), nevals.max(), self.dim]) * 0.999999

# Sum the random numbers onto the index locations and scale with dy
# Note that the resulting tensor is still slightly too large
Expand Down

0 comments on commit 6be0131

Please sign in to comment.