leaspy.models.utilities module

compute_std_from_variance(variance: Tensor, varname: str, tol: float = 1e-05) Tensor

Check that variance is strictly positive and return its square root, otherwise fail with a convergence error.

If variance is multivariate check that all components are strictly positive.

TODO? a full Bayesian setting with good priors on all variables should prevent such convergence issues.

Parameters:
variancetorch.Tensor

The variance we would like to convert to a std-dev.

varnamestr

The name of the variable - to display a nice error message.

tolfloat

The lower bound on variance, under which the converge error is raised.

Returns:
torch.Tensor
Raises:
LeaspyConvergenceError
tensor_to_list(x: list | Tensor) list

Convert input tensor to list.