Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change the source distribution #297

Open
wants to merge 1 commit into
base: v2
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions leaspy/models/abstract_multivariate_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
LinkedVariable,
VariablesValuesRO,
)
from leaspy.variables.distributions import Normal
from leaspy.variables.distributions import Laplace, Normal
from leaspy.utils.functional import (
Exp,
MatMul,
Expand Down Expand Up @@ -145,7 +145,7 @@ def get_variables_specs(self) -> NamedVariables:
sampling_kws={"scale": .5}, # cf. GibbsSampler (for retro-compat)
),
sources=IndividualLatentVariable(
Normal("sources_mean", "sources_std")
Laplace("sources_mean", "sources_std")
),
# DERIVED VARS
mixing_matrix=LinkedVariable(
Expand Down
2 changes: 2 additions & 0 deletions leaspy/models/multivariate.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ def __init__(self, name: str, variables_to_track: Optional[Iterable[str]] = None

default_variables_to_track = [
"g",
"log_g_mean",
"v0",
"log_v0_mean",
"noise_std",
"tau_mean",
"tau_std",
Expand Down
7 changes: 7 additions & 0 deletions leaspy/variables/distributions.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,12 @@ class BernoulliFamily(StatelessDistributionFamilyFromTorchDistribution):
parameters: ClassVar = ("loc",)
dist_factory: ClassVar = torch.distributions.Bernoulli

class LaplaceFamily(StatelessDistributionFamilyFromTorchDistribution):
"""Log Normal family (stateless)."""
parameters: ClassVar = ("loc","scale")
dist_factory: ClassVar = torch.distributions.laplace.Laplace



class OrdinalFamily(StatelessDistributionFamilyFromTorchDistribution):
"""Ordinal family (stateless)."""
Expand Down Expand Up @@ -859,6 +865,7 @@ def factory(*parameters_names: str) -> SymbolicDistribution:


Normal = SymbolicDistribution.bound_to(NormalFamily)
Laplace = SymbolicDistribution.bound_to(LaplaceFamily)
Bernoulli = SymbolicDistribution.bound_to(BernoulliFamily)
Ordinal = SymbolicDistribution.bound_to(OrdinalFamily)
WeibullRightCensored = SymbolicDistribution.bound_to(WeibullRightCensoredFamily)
Expand Down