A logit normal prior is a useful distribution. Currently, it is specified via low-level classes DistributionalVariable and TransformedVariable, e.g.:
iedr_rv = TransformedVariable(
name="iedr",
base_rv=DistributionalVariable(
name="logit_iedr",
distribution=dist.Normal(
transformation.SigmoidTransform().inv(0.004),
0.3,
),
),
transforms=transformation.SigmoidTransform(),
)
Instead, it should be possible to specify:
iedr_rv = LogitNormalVariable(name="iedr", base_name="logit_iedr", median=0.004, scale=0.3)
Add class LogitNormalVariable to pyrenew.randomvaraible to make this a first-class PyRenew component:
from pyrenew.randomvariable import DistributionalVariable, TransformedVariable
import pyrenew.transformation as transformation
import numpyro.distributions as dist
def LogitNormalVariable(
name: str,
median: float,
scale: float,
base_name: str | None = None,
) -> TransformedVariable:
return TransformedVariable(
name=name,
base_rv=DistributionalVariable(
name=base_name or f"logit_{name}",
distribution=dist.Normal(
transformation.SigmoidTransform().inv(median),
scale,
),
),
transforms=transformation.SigmoidTransform(),
)
Tests should verify:
- returned object is a TransformedVariable,
- base RV uses dist.Normal(logit(median), scale),
- samples lie in (0, 1),
- names are recorded as expected.
A logit normal prior is a useful distribution. Currently, it is specified via low-level classes
DistributionalVariableandTransformedVariable, e.g.:Instead, it should be possible to specify:
Add class
LogitNormalVariabletopyrenew.randomvaraibleto make this a first-class PyRenew component:Tests should verify: