Draws samples from an optionally truncated log-logistic distribution.
(shape, loc=0., scale=1., min_value=0., max_value=float('inf'), device='cpu', dtype=torch.float32)
| 328 | |
| 329 | |
| 330 | def rand_log_logistic(shape, loc=0., scale=1., min_value=0., max_value=float('inf'), device='cpu', dtype=torch.float32): |
| 331 | """Draws samples from an optionally truncated log-logistic distribution.""" |
| 332 | min_value = torch.as_tensor(min_value, device=device, dtype=torch.float64) |
| 333 | max_value = torch.as_tensor(max_value, device=device, dtype=torch.float64) |
| 334 | min_cdf = min_value.log().sub(loc).div(scale).sigmoid() |
| 335 | max_cdf = max_value.log().sub(loc).div(scale).sigmoid() |
| 336 | u = stratified_with_settings(shape, device=device, dtype=torch.float64) * (max_cdf - min_cdf) + min_cdf |
| 337 | return u.logit().mul(scale).add(loc).exp().to(dtype) |
| 338 | |
| 339 | |
| 340 | def rand_log_uniform(shape, min_value, max_value, device='cpu', dtype=torch.float32): |
nothing calls this directly
no test coverage detected