Gamma#
- class zfit.prior.Gamma(alpha, beta, mu=0, name=None)[source]#
Bases:
BasePriorGamma prior distribution.
The Gamma distribution is a flexible family of continuous probability distributions for positive values. Its shape can range from exponential-like (alpha=1) to bell-shaped (larger alpha values). The distribution is commonly used in Bayesian inference due to its conjugacy properties with certain likelihoods.
This prior is suitable for: - Rate parameters and inverse scales - Precision parameters (inverse of variance) - Waiting times and lifetimes - Any positive parameter with flexibility in shape
The parameterization used here: - Mean = alpha/beta (when mu=0) - Variance = alpha/beta²
Example
>>> # Gamma prior with shape=2, rate=1 >>> prior = Gamma(alpha=2.0, beta=1.0) >>> >>> # Shifted Gamma starting at 0.5 >>> prior = Gamma(alpha=2.0, beta=1.0, mu=0.5)
Initialize a Gamma prior.
- Parameters:
alpha (
float) – Shape parameter controlling the form of the distribution. Must be positive. Larger values make the distribution more bell-shaped.beta (
float) – Rate parameter (inverse scale). Must be positive. Larger values shift the distribution toward zero.mu (
float) – Location parameter that shifts the entire distribution. Defaults to 0 for a standard Gamma. The distribution has support on [mu, ∞).
- __eq__(other)#
Compare two priors for equality.
- Parameters:
other – Another ZfitPrior instance to compare with
- Returns:
True if the priors are equal
- Return type:
- __hash__()#
Return hash of the prior based on pdf and name.
- Returns:
Hash value for the prior
- Return type:
- 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