Beta#

class zfit.prior.Beta(alpha, beta, lower, upper, name=None)[source]#

Bases: BasePrior

Beta prior distribution for arbitrary [a, b] intervals.

This extends the standard Beta distribution to any bounded interval [a, b] by applying an affine transformation. The shape parameters work the same way as in the standard Beta distribution, but the support is transformed to [a, b].

This prior is suitable for: - Any parameter bounded within a specific interval - Proportional parameters scaled to custom ranges - Mixing weights that don’t sum to 1 - Any bounded parameter where Beta-like shapes are desired

The transformation is: Y = a + (b - a) * X where X ~ Beta(alpha, beta)

Example

>>> # Uniform prior on [2, 10]
>>> prior = Beta(alpha=1.0, beta=1.0, lower=2.0, upper=10.0)
>>>
>>> # Prior on [-1, 1] favoring values near 0.6
>>> prior = Beta(alpha=8.0, beta=2.0, lower=-1.0, upper=1.0)

Initialize a Beta prior.

Parameters:
  • alpha (float) – First shape parameter controlling behavior near the upper bound. Must be positive.

  • beta (float) – Second shape parameter controlling behavior near the lower bound. Must be positive.

  • lower (float) – Lower bound of the distribution.

  • upper (float) – Upper bound of the distribution. Must be > lower.

  • 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