Source code for greybox.distributions.t

"""T-distribution functions.

Density, cumulative distribution, quantile functions and random number
generation for the Student's t-distribution.
"""

from scipy import stats


[docs] def dt(q, df, loc=0, scale=1, log=False): """T-distribution density. Parameters ---------- q : array_like Quantiles. df : float Degrees of freedom. loc : float Location parameter. scale : float Scale parameter. log : bool If True, return log-density. Returns ------- array Density values. """ if log: return stats.t.logpdf(q, df=df, loc=loc, scale=scale) return stats.t.pdf(q, df=df, loc=loc, scale=scale)
[docs] def pt(q, df, loc=0, scale=1): """T-distribution CDF. Parameters ---------- q : array_like Quantiles. df : float Degrees of freedom. loc : float Location parameter. scale : float Scale parameter. Returns ------- array CDF values. """ return stats.t.cdf(q, df=df, loc=loc, scale=scale)
[docs] def qt(p, df, loc=0, scale=1): """T-distribution quantile function. Parameters ---------- p : array_like Probabilities. df : float Degrees of freedom. loc : float Location parameter. scale : float Scale parameter. Returns ------- array Quantile values. """ return stats.t.ppf(p, df=df, loc=loc, scale=scale)
[docs] def rt(n, df, loc=0, scale=1): """T-distribution random number generation. Parameters ---------- n : int Number of observations. df : float Degrees of freedom. loc : float Location parameter. scale : float Scale parameter. Returns ------- array Random values. """ return stats.t.rvs(df=df, loc=loc, scale=scale, size=n)