LogNormal#

class zfit.prior.LogNormal(mu, sigma, name=None)[source]#

Bases: BasePrior

Log-normal prior distribution.

The Log-Normal distribution arises when the logarithm of a variable is normally distributed. It’s right-skewed and only defined for positive values. This makes it useful for parameters that are positive and potentially have a long right tail.

This prior is suitable for: - Parameters with multiplicative effects - Sizes, lengths, and other positive measurements - Parameters where relative changes are more important than absolute - Economic variables like income or prices - Any positive parameter with potential for extreme values

Properties: - If X ~ LogNormal(mu, sigma), then log(X) ~ Normal(mu, sigma) - Mode = exp(mu - sigma^2) - Median = exp(mu) - Mean = exp(mu + sigma^2/2)

Example

>>> # Log-normal with median at 1
>>> prior = LogNormal(mu=0.0, sigma=1.0)
>>>
>>> # Log-normal with median at 10 and moderate spread
>>> prior = LogNormal(mu=2.303, sigma=0.5)  # 2.303 ≈ log(10)

Initialize a Log-Normal prior.

Parameters:
  • mu (float) – Mean of the logarithm of the variable. This controls the median of the distribution (median = exp(mu)).

  • sigma (float) – Standard deviation of the logarithm. Must be positive. Larger values create heavier right tails.

  • name (str | None) – Optional name for the prior

Note

The parameters mu and sigma are NOT the mean and standard deviation of the Log-Normal distribution itself, but of the underlying normal distribution of log(X).

__eq__(other)#

Compare two priors for equality.

Parameters:

other – Another ZfitPrior instance to compare with

Returns:

True if the priors are equal

Return type:

bool

__hash__()#

Return hash of the prior based on pdf and name.

Returns:

Hash value for the prior

Return type:

int

log_pdf(value=None)#

Return the log probability of the prior at the given value(s).

Parameters:

value – The parameter value(s) to evaluate the log probability at

Returns:

The log probability

sample(n)#

Sample n values from the prior distribution.

Parameters:

n – Number of samples to draw

Returns:

An array of samples