Proportion modeling
Model a continuous quantity constrained to a proportion or probability.
SciPy · Function
scipy.stats.beta provides a beta continuous random variable parameterized by positive shape parameters a and b. Its distribution methods support evaluation, probability calculations, statistics, and sampling, with optional location and scale transformations.
scipy.stats.beta represents a beta continuous random variable. Provide positive shape parameters a and b; inherited distribution methods such as pdf, cdf, rvs, and interval then evaluate, summarize, or sample it, with optional loc and scale for shifting and scaling.
scipy.stats.beta.pdf(x, a, b, loc=0, scale=1)| Name | Type | Description |
|---|---|---|
x | array_like | Point or array of points at which a distribution method is evaluated. |
a | float | First positive shape parameter. |
b | float | Second positive shape parameter. |
loc | float, optional | Location parameter used to shift the distribution. |
scale | float, optional | Positive scale parameter used to resize the distribution. |
A beta continuous random-variable object with inherited distribution methods; individual methods return the corresponding density, probability, statistic, or sample result.
scipy.stats.beta is SciPy’s continuous beta-distribution object.a and b.loc translates the distribution and scale changes its width.loc and scale when the distribution must be translated or resized.(x - loc) / scale and divided by scale.from scipy.stats import beta
alpha, beta_param = 2.0, 5.0
probability = beta.cdf(0.4, alpha, beta_param)
samples = beta.rvs(alpha, beta_param, size=4, random_state=0)
print(probability)
print(samples)Computes a cumulative probability and draws reproducible samples from a beta distribution.
Model a continuous quantity constrained to a proportion or probability.
Compute cumulative or tail probabilities for a beta-distributed variable.
Generate simulated observations for testing or Monte Carlo workflows.
a and b control?a and b are the two shape parameters of the beta distribution. They must be positive, and the standard variable is supported on the interval from 0 through 1.
Follow-up: How is a location-scale form interpreted? The standardized value is y = (x - loc) / scale, and the density is the standard beta density at y divided by scale.
scipy.stats.beta?The object exposes the generic continuous-distribution methods inherited from rv_continuous, including methods for density, cumulative probability, quantiles, moments, and random variates. Distribution-specific behavior supplies the beta density and its shape parameters.
Follow-up: Which method would estimate the probability of being at most x? Use beta.cdf(x, a, b), while beta.sf(x, a, b) is preferable for an upper-tail probability.
The standard beta density is defined on the unit interval and depends on positive a and b. Optional loc and scale parameters transform that standard distribution without changing the underlying shape parameters.
Follow-up: How can a beta model be used on an interval other than the unit interval? Supply the target lower endpoint as loc and the interval width as scale.
scipy.stats.rv_continuousscipy.stats.beta.pdfscipy.stats.beta.cdfscipy.stats.beta.rvsscipy.stats.beta.fit