Statistical inference
Compute tail probabilities or critical values for inference involving a t-distributed statistic.
SciPy · Function
scipy.stats.t represents a continuous Student’s t random variable. Set its positive degrees of freedom with df, and use inherited methods for densities, probabilities, quantiles, and sampling.
scipy.stats.t is a continuous Student’s t distribution object. Supply the degrees of freedom through df, then use inherited distribution methods such as pdf, cdf, ppf, and rvs; loc and scale can shift and rescale the distribution.
scipy.stats.t| Name | Type | Description |
|---|---|---|
x | array_like | Evaluation point or array of points for distribution methods such as pdf and cdf. |
df | array_like | Degrees of freedom; the shape parameter, required to be positive. |
loc | array_like, optional | Location parameter used to shift the distribution; default is 0. |
scale | array_like, optional | Scale parameter used to rescale the distribution; default is 1. |
Distribution-method calls return the corresponding result, such as a density, cumulative probability, quantile, or random variates, depending on the selected inherited method.
scipy.stats.nct when the required model is the noncentral t distribution.loc and scale for location and scale changes rather than modifying the standard distribution manually.from scipy.stats import t
probability = t.cdf(1.96, df=10)
quantile = t.ppf(0.975, df=10)
samples = t.rvs(df=10, size=4, random_state=0)
print(probability)
print(quantile)
print(samples)Computes a cumulative probability, a quantile, and four random variates from a Student’s t distribution with 10 degrees of freedom.
Compute tail probabilities or critical values for inference involving a t-distributed statistic.
Evaluate likelihood or density values for continuous observations under a t model.
Generate simulated observations with specified degrees of freedom.
scipy.stats.t represent?It represents a Student’s t continuous random variable. The object is an rv_continuous instance, so it provides generic distribution operations supplemented with t-specific behavior.
Follow-up: How would you model a noncentral t distribution? Use the related scipy.stats.nct distribution instead.
df is the shape parameter and must be greater than zero. loc shifts the distribution, while scale rescales it.
Follow-up: What constraint applies to the scale parameter? It must be positive for a valid continuous distribution parameterization.
loc and scale affect the density?For a shifted and scaled variable, standardize with y = (x - loc) / scale; the density is the standard density at y, divided by scale. This lets the inherited methods operate on nonstandard location and scale settings.
Follow-up: Which method returns a probability threshold? Use ppf, the percent-point function, with a probability between zero and one.
scipy.stats.nctscipy.stats.rv_continuous