Student’s t-Distribution

Table of contents


Density Function

The density function of the Student’s t distribution:

\[f(x; \nu) = \dfrac{\Gamma \left( \frac{\nu + 1}{2} \right)}{ \sqrt{\nu \pi} \Gamma \left( \frac{\nu}{2} \right)} \left( 1 + \frac{x^2}{\nu} \right)^{- \frac{\nu+1}{2}}\]

where \(\Gamma(\cdot)\) denotes the gamma function.

Methods for scalar input, as well as for list input, are listed below.

Scalar Input

pystats.dt(x: float, dof: float = 1.0, log: bool = False) float

Density function of the t-distribution distribution.

Example

>>> pystats.dt(0.37, 11)
0.362095719673348
Parameters
  • x (float) – A real-valued input.

  • dof (float) – The degrees of freedom parameter, a real-valued input.

  • log (bool) – Return the log-density or the true form.

Returns

The density function evaluated at x.

List Input

pystats.dt(x: List[float], dof: float = 1.0, log: bool = False) List[float]

Density function of the t-distribution distribution.

Example

>>> pystats.dt([1.8, 0.7, 4.2], 11)
[0.08286084841281988, 0.3002542334010353, 0.0012519045841828374]
Parameters
  • x (List[float]) – A standard list input.

  • dof (float) – The degrees of freedom parameter, a real-valued input.

  • log (bool) – Return the log-density or the true form.

Returns

A list of density values corresponding to the elements of x.


Cumulative Distribution Function

The cumulative distribution function (CDF) of the Student’s t distribution:

\[F(x; \nu) = \int_{-\infty}^x f(z; \nu) dz = \frac{1}{2} + x \Gamma \left( \frac{\nu + 1}{2} \right) + \dfrac{ {}_2 F_1 \left( \frac{1}{2}, \frac{\nu+1}{2}; \frac{3}{\nu}; - \frac{x^2}{\nu} \right) }{ \sqrt{\nu \pi} \Gamma \left( \frac{\nu}{2} \right)}\]

where \(\Gamma(\cdot)\) denotes the gamma function and \({}_2 F_1\) denotes the hypergeometric function.

Methods for scalar input, as well as for list input, are listed below.

Scalar Input

pystats.pt(p: float, dof: float = 1.0, log: bool = False) float

Distribution function of the t-distribution distribution.

Example

>>> pystats.pt(0.37, 11)
0.6407962382848924
Parameters
  • p (float) – A real-valued input.

  • dof (float) – The degrees of freedom parameter, a real-valued input.

  • log (bool) – Return the log-density or the true form.

Returns

The cumulative distribution function evaluated at p.

List Input

pystats.pt(p: List[float], dof: float = 1.0, log: bool = False) List[float]

Distribution function of the t-distribution distribution.

Example

>>> pystats.pt([1.8, 0.7, 4.2], 11)
[0.9503420534306152, 0.7507677671528026, 0.9992572076935229]
Parameters
  • p (List[float]) – A standard list input.

  • dof (float) – The degrees of freedom parameter, a real-valued input.

  • log (bool) – Return the log-density or the true form.

Returns

A list of CDF values corresponding to the elements of p.


Quantile Function

The quantile function of the Student’s t distribution:

\[q(p; \nu) = \inf \left\{ x : p \leq F(x; \nu) \right\}\]

Methods for scalar input, as well as for list input, are listed below.

Scalar Input

pystats.qt(q: float, dof: float = 1.0) float

Quantile function of the t-distribution distribution.

Example

>>> pystats.qt(0.5, 11)
0.0
Parameters
  • q (float) – A real-valued input.

  • dof (float) – The degrees of freedom parameter, a real-valued input.

Returns

The quantile function evaluated at q.

List Input

pystats.qt(q: List[float], dof: float = 1.0) List[float]

Quantile function of the t-distribution distribution.

Example

>>> pystats.qt([0.3, 0.5, 0.8], 11)
[-0.5399378774105429, 0.0, 0.8755299114635708]
Parameters
  • q (List[float]) – A standard list input.

  • dof (float) – The degrees of freedom parameter, a real-valued input.

Returns

A list of quantiles values corresponding to the elements of q.


Random Sampling

Scalar Output

pystats.rt(dof: float = 1.0) float

Random sampling function for the t-distribution distribution.

Example

>>> pystats.rt(dof=11)
0.30585871954611826
Parameters

dof (float) – The degrees of freedom parameter, a real-valued input.

Returns

A pseudo-random draw from the t-distribution distribution.

List Output

pystats.rt(n: int, dof: float = 1.0) List[float]

Random sampling function for the t-distribution distribution.

Example

>>> pystats.rt(3, 11)
[2.781125786671334, -0.7090818248684807, -0.3220992876319297]
Parameters
  • n (int) – The number of output values.

  • dof (float) – The degrees of freedom parameter, a real-valued input.

Returns

A list of pseudo-random draws from the t-distribution distribution.