MCPcopy Create free account
hub / github.com/Meshcapade/difflocks / rand_log_logistic

Function rand_log_logistic

k_diffusion/utils.py:330–337  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

328
329
330def 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
340def rand_log_uniform(shape, min_value, max_value, device='cpu', dtype=torch.float32):

Callers

nothing calls this directly

Calls 1

stratified_with_settingsFunction · 0.85

Tested by

no test coverage detected