Uniform#

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

Bases: BasePrior

Uniform prior distribution.

The Uniform prior assigns equal probability to all values within a specified range. It represents complete uncertainty about which values are more likely within the bounds. This is often used as a “non-informative” or “flat” prior when you want the data to dominate the inference.

Special behavior: - If bounds are not specified, the prior adapts to the parameter’s limits - If only one bound is specified, a default range of 1e6 is used for the other

This prior is suitable for: - Parameters where you have no prior preference within a range - Initial explorations when prior knowledge is minimal - Bounded parameters where all values are equally plausible

Example

>>> # Uniform prior between 0 and 1
>>> prior = Uniform(lower=0.0, upper=1.0)
>>>
>>> # Uniform prior that adapts to parameter bounds
>>> prior = Uniform()  # Will use parameter's limits when assigned

Initialize a Uniform prior.

Parameters:
  • lower (float | None) – Lower bound of the uniform distribution. If None, will use the parameter’s lower limit when the prior is assigned.

  • upper (float | None) – Upper bound of the uniform distribution. If None, will use the parameter’s upper limit when the prior is assigned.

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

Note

If both bounds are None, the prior will adapt completely to the parameter’s limits. If the parameter has no limits, temporary bounds of [-1e6, 1e6] are used.

__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