Normal#

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

Bases: BasePrior

Normal (Gaussian) prior distribution.

The Normal prior is one of the most commonly used priors in Bayesian inference. It represents beliefs that parameter values follow a bell-shaped distribution centered at a specific value with a given spread. When assigned to a parameter with bounds, it automatically becomes a truncated normal distribution.

This prior is suitable for: - Parameters where you have informative prior knowledge about the likely value - Regression coefficients and effect sizes - Location parameters when uncertainty is approximately symmetric

Example

>>> # Prior centered at 0 with standard deviation 1
>>> prior = Normal(mu=0.0, sigma=1.0)
>>>
>>> # Prior for a parameter expected around 10 with uncertainty ±2
>>> prior = Normal(mu=10.0, sigma=2.0)

Initialize a Normal prior.

Parameters:
  • mu (float) – Mean (center) of the normal distribution

  • sigma (float) – Standard deviation (spread) of the normal distribution. Must be positive.

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

__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