From c09d94908d8ad52f557ed59195c1ceb2d0434d65 Mon Sep 17 00:00:00 2001 From: Balakumar Sundaralingam Date: Tue, 19 Dec 2023 10:00:18 -0800 Subject: [PATCH] bug fix for stomp sampling --- src/curobo/util/sample_lib.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/curobo/util/sample_lib.py b/src/curobo/util/sample_lib.py index dbbcfe42..b5d3604f 100644 --- a/src/curobo/util/sample_lib.py +++ b/src/curobo/util/sample_lib.py @@ -510,7 +510,21 @@ def get_gaussian_samples(self, num_samples, variance=1.0): def gaussian_transform( uniform_samples: torch.Tensor, proj_mat: torch.Tensor, i_mat: torch.Tensor, variance: float ): - gaussian_halton_samples = proj_mat * torch.erfinv(2 * uniform_samples - 1) + """Compute a guassian transform of uniform samples. + + Args: + uniform_samples (torch.Tensor): uniform samples in the range [0,1]. + proj_mat (torch.Tensor): _description_ + i_mat (torch.Tensor): _description_ + variance (float): _description_ + + Returns: + _type_: _description_ + """ + # since erfinv returns inf when value is -1 or +1, we scale the input to not have + # these values. + changed_samples = 1.99 * uniform_samples - 0.99 + gaussian_halton_samples = proj_mat * torch.erfinv(changed_samples) i_mat = i_mat * variance gaussian_halton_samples = torch.matmul(gaussian_halton_samples, i_mat) return gaussian_halton_samples