Vous êtes un professionnel et vous avez besoin d'une formation ?
RAG (Retrieval-Augmented Generation)et Fine Tuning d'un LLM
Voir le programme détaillé
Module « scipy.special »
Signature de la fonction fdtrc
def fdtrc(*args, **kwargs)
Description
help(scipy.special.fdtrc)
fdtrc(x1, x2, x3, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature])
fdtrc(dfn, dfd, x, out=None)
F survival function.
Returns the complemented F-distribution function (the integral of the
density from `x` to infinity).
Parameters
----------
dfn : array_like
First parameter (positive float).
dfd : array_like
Second parameter (positive float).
x : array_like
Argument (nonnegative float).
out : ndarray, optional
Optional output array for the function values
Returns
-------
y : scalar or ndarray
The complemented F-distribution function with parameters `dfn` and
`dfd` at `x`.
See Also
--------
fdtr : F distribution cumulative distribution function
fdtri : F distribution inverse cumulative distribution function
scipy.stats.f : F distribution
Notes
-----
The regularized incomplete beta function is used, according to the
formula,
.. math::
F(d_n, d_d; x) = I_{d_d/(d_d + xd_n)}(d_d/2, d_n/2).
Wrapper for the Cephes [1]_ routine `fdtrc`. The F distribution is also
available as `scipy.stats.f`. Calling `fdtrc` directly can improve
performance compared to the ``sf`` method of `scipy.stats.f` (see last
example below).
References
----------
.. [1] Cephes Mathematical Functions Library,
http://www.netlib.org/cephes/
Examples
--------
Calculate the function for ``dfn=1`` and ``dfd=2`` at ``x=1``.
>>> import numpy as np
>>> from scipy.special import fdtrc
>>> fdtrc(1, 2, 1)
0.42264973081037427
Calculate the function at several points by providing a NumPy array for
`x`.
>>> x = np.array([0.5, 2., 3.])
>>> fdtrc(1, 2, x)
array([0.5527864 , 0.29289322, 0.22540333])
Plot the function for several parameter sets.
>>> import matplotlib.pyplot as plt
>>> dfn_parameters = [1, 5, 10, 50]
>>> dfd_parameters = [1, 1, 2, 3]
>>> linestyles = ['solid', 'dashed', 'dotted', 'dashdot']
>>> parameters_list = list(zip(dfn_parameters, dfd_parameters,
... linestyles))
>>> x = np.linspace(0, 30, 1000)
>>> fig, ax = plt.subplots()
>>> for parameter_set in parameters_list:
... dfn, dfd, style = parameter_set
... fdtrc_vals = fdtrc(dfn, dfd, x)
... ax.plot(x, fdtrc_vals, label=rf"$d_n={dfn},\, d_d={dfd}$",
... ls=style)
>>> ax.legend()
>>> ax.set_xlabel("$x$")
>>> ax.set_title("F distribution survival function")
>>> plt.show()
The F distribution is also available as `scipy.stats.f`. Using `fdtrc`
directly can be much faster than calling the ``sf`` method of
`scipy.stats.f`, especially for small arrays or individual values.
To get the same results one must use the following parametrization:
``stats.f(dfn, dfd).sf(x)=fdtrc(dfn, dfd, x)``.
>>> from scipy.stats import f
>>> dfn, dfd = 1, 2
>>> x = 1
>>> fdtrc_res = fdtrc(dfn, dfd, x) # this will often be faster than below
>>> f_dist_res = f(dfn, dfd).sf(x)
>>> f_dist_res == fdtrc_res # test that results are equal
True
Vous êtes un professionnel et vous avez besoin d'une formation ?
Machine Learning
avec Scikit-Learn
Voir le programme détaillé
Améliorations / Corrections
Vous avez des améliorations (ou des corrections) à proposer pour ce document : je vous remerçie par avance de m'en faire part, cela m'aide à améliorer le site.
Emplacement :
Description des améliorations :