bundles / numpy 2.4.3 / numpy / random / _generator / Generator / standard_t
cython_function_or_method
numpy.random._generator:Generator.standard_t
Signature
def standard_t ( df , size = None ) Summary
Draw samples from a standard Student's t distribution with df degrees of freedom.
Extended Summary
A special case of the hyperbolic distribution. As df gets large, the result resembles that of the standard normal distribution (standard_normal).
Parameters
df: float or array_like of floatsDegrees of freedom, must be > 0.
size: int or tuple of ints, optionalOutput shape. If the given shape is, e.g.,
(m, n, k), thenm * n * ksamples are drawn. If size isNone(default), a single value is returned ifdfis a scalar. Otherwise,np.array(df).sizesamples are drawn.
Returns
out: ndarray or scalarDrawn samples from the parameterized standard Student's t distribution.
Notes
The probability density function for the t distribution is
The t test is based on an assumption that the data come from a Normal distribution. The t test provides a way to test whether the sample mean (that is the mean calculated from the data) is a good estimate of the true mean.
The derivation of the t-distribution was first published in 1908 by William Gosset while working for the Guinness Brewery in Dublin. Due to proprietary issues, he had to publish under a pseudonym, and so he used the name Student.
Examples
From Dalgaard page 83 [1]_, suppose the daily energy intake for 11 women in kilojoules (kJ) is:intake = np.array([5260., 5470, 5640, 6180, 6390, 6515, 6805, 7515, \ 7515, 8230, 8770])✓
np.mean(intake) intake.std(ddof=1)✗
t = (np.mean(intake)-7725)/(intake.std(ddof=1)/np.sqrt(len(intake)))
✓t
✗import matplotlib.pyplot as plt rng = np.random.default_rng() s = rng.standard_t(10, size=1000000) h = plt.hist(s, bins=100, density=True)✓
np.sum(np.abs(t) < np.abs(s)) / float(len(s))
✗Aliases
-
numpy.random.Generator.standard_t