Skip to content

Add LogNormal#84

Open
gvcallen wants to merge 1 commit into
lockwo:mainfrom
gvcallen:lognormal
Open

Add LogNormal#84
gvcallen wants to merge 1 commit into
lockwo:mainfrom
gvcallen:lognormal

Conversation

@gvcallen

@gvcallen gvcallen commented May 7, 2026

Copy link
Copy Markdown
Contributor

No description provided.

LogNormal distribution parameterized by the loc/scale of the underlying
Normal, with sample, log_prob, cdf/icdf, entropy, moments, and KL
divergence (computed via the invariance of KL under the strictly
monotonic log transform).
`loc` and `scale` of the underlying Normal.
"""

loc: Array

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can type as Float[Array]? also can do the converter trick mentioned in another PR to remove init

dtype = jnp.result_type(self.loc, self.scale)
return jax.random.normal(key, shape=self.event_shape, dtype=dtype)

def sample(self, key: Key[Array, ""]) -> Array:

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

event_shape is loc.shape, but sample() later broadcasts with scale. e.g. LogNormal(0, jnp.ones(3)).event_shape == (), while sample() returns shape (3,) with the same random draw repeated across all entries. Either use the broadcasted parameter shape for sampling, or reject unequal parameter shapes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants