Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
174 commits
Select commit Hold shift + click to select a range
303bf7b
DOC: add SAS ex and docs for Tukey-Cramer
swallan Oct 2, 2020
ab660ce
DOC: add source for tukeykramer
swallan Oct 2, 2020
7ce66f3
ENH: add functioning tukey-kramer with studentized range dist lookup …
swallan Oct 8, 2020
28dfe5e
ENH: add wrapped fortran to get studentized q value for use in tukey …
swallan Oct 20, 2020
d6016dc
ENH: used ft wrapper in tukeykramer to get q
swallan Oct 20, 2020
1dd919f
ENH: increase accuracy of fortran routine by reducing lower limit for…
swallan Oct 20, 2020
12c5c6f
ENH: refine io for tukeykramer
swallan Oct 21, 2020
87d4068
ENH: tukeykramer support for differing group sizes
swallan Oct 24, 2020
a0cf79c
TST: Add SAS comparisons for TukeyKramer method
swallan Oct 24, 2020
7bef36a
ENH: update studentized range fortran
swallan Oct 27, 2020
6fdbaaf
TST: reparametrize tukeykramer tests
swallan Oct 27, 2020
e1da5c3
ENH: add p-value calc in tukeykramer
swallan Nov 18, 2020
54cac74
DOC: create for tukeykramer
swallan Nov 28, 2020
1819c5c
TST: add NIST test to tukeykramer
swallan Nov 28, 2020
1ab878c
DOC: update example tukeykramer
swallan Nov 29, 2020
5e87bc0
ENH: Add studentized range distribution
DominicChm Dec 8, 2020
0288bf4
ENH: Integrate studentized-T
DominicChm Dec 13, 2020
9384ad8
TST: fix bugs causing tests to fail.
DominicChm Dec 14, 2020
f53180f
TST: add studentized_range tests
DominicChm Dec 15, 2020
32a4574
DOC: initial doc implementation
DominicChm Dec 15, 2020
9307701
MAINT: rename studentized_t to studentized_range
DominicChm Dec 15, 2020
b20c40e
MAINT: rename studentized_t to studentized_range
DominicChm Dec 15, 2020
17a4d43
MAINT: move consts inside integral to increase precision
DominicChm Dec 15, 2020
309bb01
Merge remote-tracking branch 'origin/studentized-t-distribution' into…
DominicChm Dec 15, 2020
9a8aa31
BUG: Missing underscore
DominicChm Dec 16, 2020
d95968f
TST: decrease tolerance for table test
DominicChm Dec 18, 2020
08c2bea
Inital commit
DominicChm Dec 22, 2020
5e027ce
DOC: Builds
DominicChm Dec 22, 2020
6ef7865
ENH: Make studentized range CDF use log
DominicChm Dec 27, 2020
ef16312
ENH: Add custom PDF
DominicChm Dec 29, 2020
a2584d5
MAINT: Fix spelling
DominicChm Dec 29, 2020
6ca4495
PEP: tukeykramer pep fixes
swallan Jan 5, 2021
7e37669
ENH: Convert PDF to log, initial moment imp.
DominicChm Jan 5, 2021
a3a280c
TST: Add PDF tests
DominicChm Jan 5, 2021
ec03cef
ENH: Use ufuncs, add debug options
DominicChm Jan 6, 2021
0ce4f9a
BUG: Fix studentized moment gen fn
DominicChm Jan 12, 2021
d02e60a
ENH: remove PPF, standardize intro+quads
DominicChm Jan 19, 2021
0ea7561
TST: Add moment test
DominicChm Jan 19, 2021
7178ccf
TST: Add moment test
DominicChm Jan 19, 2021
7cb536d
Merge branch 'studentized-testing' into studentized-t-distribution
DominicChm Jan 19, 2021
6a05140
BUG: Add return statement
DominicChm Feb 9, 2021
8d563c4
TST: parametrize table comparisons
swallan Feb 17, 2021
6c1ac23
TST: missing import
swallan Feb 18, 2021
950de55
DOC: add references, clarify comments
swallan Feb 18, 2021
17b0ef6
STY: spelling asymptotic
swallan Feb 23, 2021
997d0e0
DOC: Update tutorial formulas
DominicChm Feb 23, 2021
639a07e
DOC: Add info to docstring
DominicChm Feb 23, 2021
6625d7b
DOC: update note for asymptotic switching
swallan Feb 23, 2021
3590a86
Merge branch 'studentized-t-distribution' of github.com:DominicChm/sc…
swallan Feb 23, 2021
5d5f100
DOCS: add a-hat special character
swallan Feb 24, 2021
052339e
DOC: add example with inverse transform sampling instead of rvs
swallan Feb 25, 2021
2885066
DOC: missing line
swallan Feb 25, 2021
648685b
MAINT: Remove debug attributes
DominicChm Feb 27, 2021
4926a24
DOC: elaborate on random variate example, remove uneeded notes
swallan Mar 2, 2021
9ed05e7
TST: Add test comparing CDF to mpmath
DominicChm Mar 16, 2021
8be9370
MAINT: Reformat fn calls and var. names in stud. range class
DominicChm Mar 16, 2021
5f9076c
DOC: clarifications and rewording
DominicChm Mar 22, 2021
32f405a
DOC: add asymptotic approximation
DominicChm Mar 22, 2021
9d013ba
MAINT: replace v with df, correct spacing
DominicChm Mar 22, 2021
7ca0895
DOC: use names, use leftmost 99.9
swallan Mar 22, 2021
52f1824
TST: vectorize over parametrize cdf, ppf tests
swallan Mar 22, 2021
b930876
DOC: describe phi/Phi in tutorial
DominicChm Mar 23, 2021
19e25a4
DOC: slightly reformat formulas
DominicChm Mar 23, 2021
459d876
MAINT: standardize test variable names
DominicChm Mar 23, 2021
e786578
Merge remote-tracking branch 'upstream/master' into studentized-t-dis…
DominicChm Mar 23, 2021
4c60249
ENH: add to invdistcont
swallan Mar 23, 2021
af71050
ENH: fix for test_cont_basic.check_named_args
swallan Mar 23, 2021
b40b90a
TST: omit studentized_range from test_cont_basic.check_fit_args
swallan Mar 23, 2021
64b441e
PEP: fix pep8 in tests + sources
swallan Mar 23, 2021
d3f4849
TST: forgotten file arg
swallan Mar 23, 2021
496eec1
DOC: update number of dists
swallan Mar 24, 2021
95370ce
TST: skip failing / unreliable studentized range test_fit
swallan Mar 24, 2021
bb1bc22
TST: add alpha=.001, make use of itertools product
swallan Mar 24, 2021
e0a2805
TST: test_continuous_basic.py skip `test_rvs_broadcast` and slow tests
swallan Mar 24, 2021
65a4291
ENH: add _fitstart
swallan Mar 24, 2021
c645901
ENH: correct integration range on nu=100,000+
swallan Mar 24, 2021
fd5f545
TST: test all the way to np.inf
swallan Mar 24, 2021
f08afa7
TST: add invalid log to check_pdf_logpdf_at_endpoints for studentized…
swallan Mar 24, 2021
c78a73f
DOC: add formula pdf
swallan Mar 26, 2021
573ffd2
DOC: try removing equations
swallan Mar 26, 2021
90adf0b
DOC: add back in PDF
swallan Mar 26, 2021
0f69fc1
DOC: add formulas back in
swallan Mar 26, 2021
b87f239
TST: trying to test linux32 weird np.log errors
swallan Mar 26, 2021
fcaef25
Revert "TST: trying to test linux32 weird np.log errors"
swallan Mar 26, 2021
0478d05
BUG: define variable for linux32
swallan Mar 26, 2021
3c627ed
TST: change product order
swallan Mar 26, 2021
25c5130
TST: test _fitstart for valid args
swallan Mar 26, 2021
531dc0f
DOC: use full name in docs
swallan Mar 27, 2021
b8443e2
Merge remote-tracking branch 'scipy/master' into studentized-t-distri…
swallan Mar 27, 2021
9a8f275
Merge remote-tracking branch 'scipy/master' into studentized-t-distri…
swallan Mar 30, 2021
ece0f67
MAINT: Fix indentation, add constant precomputations
DominicChm Apr 12, 2021
8b1be08
DOC: add some cython fn. docstrings
DominicChm Apr 12, 2021
6595cbd
MAINT: rework argcheck
DominicChm Apr 12, 2021
02731da
DOC: Move after_notes
DominicChm Apr 12, 2021
35390a9
MAINT: Refactor last term position.
DominicChm Apr 12, 2021
711bb60
MAINT: fix name of asymptotic cython fn
DominicChm Apr 12, 2021
b5f7b01
MAINT: clarify _Phi and _phi docstrings
DominicChm Apr 12, 2021
18ed224
ENH: Vectorize _munp
DominicChm Apr 15, 2021
ff6a54c
TST: add moment vectorization test.
DominicChm Apr 15, 2021
1f412fa
TST: parameterize moment test
DominicChm Apr 15, 2021
de412d7
MAINT: fix typo in test class comment
DominicChm Apr 15, 2021
e6d0cac
DOC: clean up equations in tutorial
DominicChm Apr 15, 2021
8582191
DOC: update pdf definition in docstring
DominicChm Apr 15, 2021
48fea13
ENH: replace custom CDF with special.ndtr
DominicChm Apr 15, 2021
a5ea374
ENH: prevent division error warning
DominicChm Apr 15, 2021
11acb11
DOC: minor changes to cython comments
DominicChm Apr 19, 2021
96a860d
Merge branch 'master' into studentized-t-distribution
mdhaber Apr 19, 2021
9c2233d
MAINT: remove term from logarithm, remove warning suppression.
DominicChm Apr 19, 2021
4077166
STY: code/comment spacing
DominicChm Apr 19, 2021
8f49e84
MAINT: style/old code removal changes for JSON data gen script
DominicChm Apr 19, 2021
cd887b1
DOC: update number of dists
DominicChm Apr 19, 2021
15ce23e
TST: Add PDF mp comparisons
DominicChm Apr 20, 2021
86073d6
TST: Add moment mp test
DominicChm Apr 26, 2021
73b6b71
Revert "TST: Add moment mp test"
DominicChm Apr 26, 2021
9df00bf
TST: test moment vs mp
DominicChm Apr 26, 2021
033fe12
MAINT: Update generated data (temp)
DominicChm Apr 26, 2021
dd0cab3
TST: update comment for data
swallan Apr 27, 2021
baefb59
STY: PEP8 fix in studentizedrange
swallan Apr 27, 2021
ddbaaa7
MAINT: Enable and run all mp reference data
DominicChm May 3, 2021
0919d56
BUG: revert use of cs.ndtr which was innacurate on 32bit
DominicChm May 3, 2021
c72b65d
DOC: missing (-) in equations
DominicChm May 3, 2021
63dc35b
DOC: Update comments about reason for log
DominicChm May 3, 2021
951a6db
DOC: Fix (-) in docstring
DominicChm May 3, 2021
4181036
DOC: Add _Phi comment about custom implementation rationale
DominicChm May 3, 2021
f3bcae4
ENH: Calculate const externally
DominicChm May 3, 2021
cc6d3f3
MAINT: Refactor studentized range to calc constants outside of integrand
DominicChm May 3, 2021
a5d625d
BUG: Fix user_data index in moment
DominicChm May 4, 2021
32d6498
DOC: use single source for q values
swallan May 9, 2021
a591336
STY: style fixes for prettier code
swallan May 9, 2021
b1b8934
TST: mark slwo studentized range tests
swallan May 10, 2021
ea5df0f
DOC: Fix missing term in tutorial
DominicChm May 10, 2021
81ea9f0
MAINT: Remove usage of support range in some integrals.
DominicChm May 10, 2021
81e7de7
MAINT: Remove atleast_1d calls.
DominicChm May 10, 2021
1cf89a4
DOC: small clarifications in cython/docstring
DominicChm May 10, 2021
145ecf8
MAINT: Standardize variable names, PEP8 fixes
DominicChm May 10, 2021
62d33b8
MAINT: Rename studentized_range cython functions
DominicChm May 10, 2021
52430f0
Merge remote-tracking branch 'scipy/master' into tukeycramer-test
swallan May 10, 2021
6fb4455
ENH: Add caching mechanism, more test cases to mp generator.
DominicChm May 10, 2021
b84baeb
ENH: refactoring tukeykramer to work with studentized range distribution
swallan May 10, 2021
d60ee21
MAINT: Refactor mp PDF
DominicChm May 10, 2021
0df846b
CI: [skip travis] [skip actions] [skip azurepipelines]
swallan May 10, 2021
809bab9
Merge remote-tracking branch 'dom/studentized-t-distribution' into tu…
swallan May 10, 2021
818722a
MAINT: Refactor mp moment.
DominicChm May 10, 2021
999860d
TST: Remove redundant test that compared moment to PDF.
DominicChm May 10, 2021
6a79cca
ENH: Generator script overhaul
DominicChm May 11, 2021
66059e9
x
swallan May 12, 2021
f191ad0
TST: change variable order
swallan May 12, 2021
499dee7
STY: pep8 fixes in pyx, uneeded citation
swallan May 12, 2021
ce232e3
ENH: refactor out duplicate code
swallan May 12, 2021
d205942
TST: add reference to complement wikipedia
swallan May 12, 2021
2ca42d0
DOC: add default inf for when v is very large
swallan May 12, 2021
20f4e2f
DOC: missing ^\nu in PDF on distr. doc.
swallan May 12, 2021
d541b05
ENH: minor equation refactor + spelling
swallan May 13, 2021
a7e0e72
MAINT: rename studentized range mpmath test file
swallan May 13, 2021
36523bd
TST: skip studentized_range in test_cont_basic
swallan May 13, 2021
460ce0c
DOC: clarify large \nu swtich, correct variable name in doc.
swallan May 13, 2021
8c196ba
Update scipy/stats/_continuous_distns.py
mdhaber May 14, 2021
9972ec1
TST: mark studentized range as xslow in test-cont-basic
swallan May 14, 2021
3364d44
TST: mark studentized range xslow in cases_test_moments
swallan May 14, 2021
1315c5f
DOC: update shape constraints in doc for studentized range
swallan May 14, 2021
90d6cfd
TST: skip to next loop iteration to pass second yield
swallan May 14, 2021
60a50d1
DOC: use `x` rather than `x` to make similar to other distributions
swallan May 14, 2021
a769637
STY: grammar fix
swallan May 14, 2021
01623d1
DOC: simplify wording.
swallan May 15, 2021
6b1fade
Merge branch 'studentized-t-distribution' into tukeykramer-combined-w…
swallan May 15, 2021
ed66587
m
swallan May 15, 2021
4fe435d
Merge remote-tracking branch 'scipy/master' into tukeykramer-combined…
swallan May 15, 2021
a537c90
Update stats.py
swallan May 15, 2021
82a612b
Update test_stats.py
swallan May 15, 2021
458504f
Update stats.py
swallan May 21, 2021
2dd790f
nameless
swallan May 24, 2021
8756b92
mmfmfmf
swallan May 24, 2021
d117900
so close
swallan May 25, 2021
0de4a5a
ready
swallan May 25, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion doc/source/tutorial/stats.rst
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ introspection:
>>> dist_discrete = [d for d in dir(stats) if
... isinstance(getattr(stats, d), stats.rv_discrete)]
>>> print('number of continuous distributions: %d' % len(dist_continu))
number of continuous distributions: 103
number of continuous distributions: 104
>>> print('number of discrete distributions: %d' % len(dist_discrete))
number of discrete distributions: 19

Expand Down
1 change: 1 addition & 0 deletions doc/source/tutorial/stats/continuous.rst
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ Continuous Distributions in `scipy.stats`
continuous_rice
continuous_recipinvgauss
continuous_semicircular
continuous_studentized_range
continuous_t
continuous_trapezoid
continuous_triang
Expand Down
38 changes: 38 additions & 0 deletions doc/source/tutorial/stats/continuous_studentized_range.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
.. _continuous-studentized_range:

Studentized Range Distribution
==============================
This distribution has two shape parameters, :math:`k>1` and :math:`\nu>0`, and the support is :math:`x \geq 0`.

.. math::
:nowrap:

\begin{eqnarray*}
f(x; k, \nu) = \frac{k(k-1)\nu^{\nu/2}}{\Gamma(\nu/2)2^{\nu/2-1}}
\int_{0}^{\infty} \int_{-\infty}^{\infty} s^{\nu} e^{-\nu s^2/2} \phi(z) \phi(sx + z)
[\Phi(sx + z) - \Phi(z)]^{k-2} \,dz \,ds
\end{eqnarray*}

.. math::
:nowrap:

\begin{eqnarray*}
F(q; k, \nu) = \frac{k\nu^{\nu/2}}{\Gamma(\nu/2)2^{\nu/2-1}}
\int_{0}^{\infty} \int_{-\infty}^{\infty} s^{\nu-1} e^{-\nu s^2/2} \phi(z)
[\Phi(sq + z) - \Phi(z)]^{k-1} \,dz \,ds
\end{eqnarray*}

Note: :math:`\phi(z)` and :math:`\Phi(z)` represent the normal PDF and normal CDF, respectively.

When :math:`\nu` exceeds 100,000, the asymptopic approximation of :math:`F(x; k, \nu=\infty)` is used:

.. math::
:nowrap:

\begin{eqnarray*}
F(x; k, \nu=\infty) = k \int_{-\infty}^{\infty} \phi(z)
[\Phi(x + z) - \Phi(z)]^{k-1} \,dz
\end{eqnarray*}


Implementation: `scipy.stats.studentized_range`
2 changes: 2 additions & 0 deletions scipy/stats/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@
semicircular -- Semicircular
skewcauchy -- Skew Cauchy
skewnorm -- Skew normal
studentized_range -- Studentized Range
t -- Student's T
trapezoid -- Trapezoidal
triang -- Triangular
Expand Down Expand Up @@ -269,6 +270,7 @@
siegelslopes
theilslopes
multiscale_graphcorr
tukeykramer

Statistical tests
=================
Expand Down
186 changes: 186 additions & 0 deletions scipy/stats/_continuous_distns.py
Original file line number Diff line number Diff line change
Expand Up @@ -9315,6 +9315,192 @@ def _updated_ctor_param(self):
return dct


class studentized_range_gen(rv_continuous):
r"""A studentized range continuous random variable.

%(before_notes)s

See Also
--------
t: Student's t distribution

Notes
-----
The probability density function for `studentized_range` is:

.. math::

f(x; k, \nu) = \frac{k(k-1)\nu^{\nu/2}}{\Gamma(\nu/2)
2^{\nu/2-1}} \int_{0}^{\infty} \int_{-\infty}^{\infty}
s^{\nu} e^{-\nu s^2/2} \phi(z) \phi(sx + z)
[\Phi(sx + z) - \Phi(z)]^{k-2} \,dz \,ds

for :math:`x ≥ 0`, :math:`k > 1`, and :math:`\nu > 0`.

`studentized_range` takes ``k`` and ``v`` as shape parameters.

When :math:`\nu` exceeds 100,000, an asymptotic approximation (infinite
degrees of freedom) is used to compute the cumulative distribution
function [4]_.

%(after_notes)s

References
----------

.. [1] "Studentized range distribution",
https://en.wikipedia.org/wiki/Studentized_range_distribution
.. [2] Batista, Ben Dêivide, et al. "Externally Studentized Normal Midrange
Distribution." Ciência e Agrotecnologia, vol. 41, no. 4, 2017, pp.
378-389., doi:10.1590/1413-70542017414047716.
.. [3] Harter, H. Leon. "Tables of Range and Studentized Range." The Annals
of Mathematical Statistics, vol. 31, no. 4, 1960, pp. 1122-1147.
JSTOR, www.jstor.org/stable/2237810. Accessed 18 Feb. 2021.
.. [4] Lund, R. E., and J. R. Lund. "Algorithm AS 190: Probabilities and
Upper Quantiles for the Studentized Range." Journal of the Royal
Statistical Society. Series C (Applied Statistics), vol. 32, no. 2,
1983, pp. 204-210. JSTOR, www.jstor.org/stable/2347300. Accessed 18
Feb. 2021.

Examples
--------
>>> from scipy.stats import studentized_range
>>> import matplotlib.pyplot as plt
>>> fig, ax = plt.subplots(1, 1)

Calculate the first four moments:

>>> k, df = 3, 10
>>> mean, var, skew, kurt = studentized_range.stats(k, df, moments='mvsk')

Display the probability density function (``pdf``):

>>> x = np.linspace(studentized_range.ppf(0.01, k, df),
... studentized_range.ppf(0.99, k, df), 100)
>>> ax.plot(x, studentized_range.pdf(x, k, df),
... 'r-', lw=5, alpha=0.6, label='studentized_range pdf')

Alternatively, the distribution object can be called (as a function)
to fix the shape, location and scale parameters. This returns a "frozen"
RV object holding the given parameters fixed.

Freeze the distribution and display the frozen ``pdf``:

>>> rv = studentized_range(k, df)
>>> ax.plot(x, rv.pdf(x), 'k-', lw=2, label='frozen pdf')

Check accuracy of ``cdf`` and ``ppf``:

>>> vals = studentized_range.ppf([0.001, 0.5, 0.999], k, df)
>>> np.allclose([0.001, 0.5, 0.999], studentized_range.cdf(vals, k, df))
True

Rather than using (``studentized_range.rvs``) to generate random variates,
which is very slow for this distribution, we can approximate the inverse
CDF using an interpolator, and then perform inverse transform sampling
with this approximate inverse CDF.

This distribution has an infinite but thin right tail, so we focus our
attention on the leftmost 99.9 percent.

>>> a, b = studentized_range.ppf([0, .999], k, df)
>>> a, b
0, 7.41058083802274

>>> from scipy.interpolate import interp1d
>>> random_state = np.random.default_rng(123)
>>> xs = np.linspace(a, b, 50)
>>> cdf = studentized_range.cdf(xs, k, df)
# Create an interpolant of the inverse CDF
>>> ppf = interp1d(cdf, xs, fill_value='extrapolate')
# Perform inverse transform sampling using the interpolant
>>> r = ppf(random_state.uniform(size=1000))

And compare the histogram:

>>> ax.hist(r, density=True, histtype='stepfilled', alpha=0.2)
>>> ax.legend(loc='best', frameon=False)
>>> plt.show()

"""

def _argcheck(self, k, df):
return (k > 1) & (df > 0)

def _fitstart(self, data):
# Default is k=1, but that is not a valid value of the parameter.
return super(studentized_range_gen, self)._fitstart(data, args=(2, 1))

def _munp(self, K, k, df):
cython_symbol = '_studentized_range_moment'
_a, _b = self._get_support()
# all three of these are used to create a numpy array so they must
# be the same shape.

def _single_moment(K, k, df):
log_const = _stats._studentized_range_pdf_logconst(k, df)
arg = [K, k, df, log_const]
usr_data = np.array(arg, float).ctypes.data_as(ctypes.c_void_p)

llc = LowLevelCallable.from_cython(_stats, cython_symbol, usr_data)

ranges = [(-np.inf, np.inf), (0, np.inf), (_a, _b)]
opts = dict(epsabs=1e-11, epsrel=1e-12)

return integrate.nquad(llc, ranges=ranges, opts=opts)[0]

ufunc = np.frompyfunc(_single_moment, 3, 1)
return np.float64(ufunc(K, k, df))

def _pdf(self, x, k, df):
cython_symbol = '_studentized_range_pdf'

def _single_pdf(q, k, df):
log_const = _stats._studentized_range_pdf_logconst(k, df)
arg = [q, k, df, log_const]
usr_data = np.array(arg, float).ctypes.data_as(ctypes.c_void_p)

llc = LowLevelCallable.from_cython(_stats, cython_symbol, usr_data)

ranges = [(-np.inf, np.inf), (0, np.inf)]
opts = dict(epsabs=1e-11, epsrel=1e-12)

return integrate.nquad(llc, ranges=ranges, opts=opts)[0]

ufunc = np.frompyfunc(_single_pdf, 3, 1)
return np.float64(ufunc(x, k, df))

def _cdf(self, x, k, df):

def _single_cdf(q, k, df):
# "When the degrees of freedom V are infinite the probability
# integral takes [on a] simpler form," and a single asymptotic
# integral is evaluated rather than the standard double integral.
# (Lund, Lund, page 205)
if df < 100000:
cython_symbol = '_studentized_range_cdf'
log_const = _stats._studentized_range_cdf_logconst(k, df)
arg = [q, k, df, log_const]
usr_data = np.array(arg, float).ctypes.data_as(ctypes.c_void_p)
ranges = [(-np.inf, np.inf), (0, np.inf)]
else:
cython_symbol = '_studentized_range_cdf_asymptotic'
arg = [q, k]
usr_data = np.array(arg, float).ctypes.data_as(ctypes.c_void_p)
ranges = [(-np.inf, np.inf)]

llc = LowLevelCallable.from_cython(_stats, cython_symbol, usr_data)
opts = dict(epsabs=1e-11, epsrel=1e-12)
return integrate.nquad(llc, ranges=ranges, opts=opts)[0]

ufunc = np.frompyfunc(_single_cdf, 3, 1)
return np.float64(ufunc(x, k, df))


studentized_range = studentized_range_gen(name='studentized_range', a=0,
b=np.inf)


# Collect names of classes and objects in this module.
pairs = list(globals().copy().items())
_distn_names, _distn_gen_names = get_distribution_names(pairs, rv_continuous)
Expand Down
2 changes: 2 additions & 0 deletions scipy/stats/_distr_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@
['semicircular', ()],
['skewcauchy', (0.5,)],
['skewnorm', (4.0,)],
['studentized_range', (3.0, 10.0)],
['t', (2.7433514990818093,)],
['trapezoid', (0.2, 0.8)],
['triang', (0.15785029824528218,)],
Expand Down Expand Up @@ -254,6 +255,7 @@
['recipinvgauss', (-1, )],
['semicircular', ()],
['skewnorm', (np.inf, )],
['studentized_range', (-1, 1)],
['t', (-1, )],
['trapezoid', (0, 2)],
['triang', (2, )],
Expand Down
Loading