fdtrc#
- scipy.special.fdtrc(dfn,dfd,x,out=None)#
F survival function.
Returns the complemented F-distribution function (the integral of thedensity fromx to infinity).
- Parameters:
- dfnarray_like
First parameter (positive float).
- dfdarray_like
Second parameter (positive float).
- xarray_like
Argument (nonnegative float).
- outndarray, optional
Optional output array for the function values
- Returns:
- yscalar or ndarray
The complemented F-distribution function with parametersdfn anddfd atx.
See also
fdtrF distribution cumulative distribution function
fdtriF distribution inverse cumulative distribution function
scipy.stats.fF distribution
Notes
The regularized incomplete beta function is used, according to theformula,
\[F(d_n, d_d; x) = I_{d_d/(d_d + xd_n)}(d_d/2, d_n/2).\]Wrapper for a routine from the Boost Math C++ library[1]. TheF distribution is also available as
scipy.stats.f. Callingfdtrcdirectly can improve performance compared to thesfmethod ofscipy.stats.f(see last example below).Array API Standard Support
fdtrchas experimental support for Python Array API Standard compatiblebackends in addition to NumPy. Please consider testing these featuresby setting an environment variableSCIPY_ARRAY_API=1and providingCuPy, PyTorch, JAX, or Dask arrays as array arguments. The followingcombinations of backend and device (or other capability) are supported.Library
CPU
GPU
NumPy
✅
n/a
CuPy
n/a
✅
PyTorch
✅
⛔
JAX
⚠️ no JIT
⛔
Dask
✅
n/a
SeeSupport for the array API standard for more information.
References
[1]The Boost Developers. “Boost C++ Libraries”.https://www.boost.org/.
Examples
Calculate the function for
dfn=1anddfd=2atx=1.>>>importnumpyasnp>>>fromscipy.specialimportfdtrc>>>fdtrc(1,2,1)0.42264973081037427
Calculate the function at several points by providing a NumPy array forx.
>>>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.
>>>importmatplotlib.pyplotasplt>>>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()>>>forparameter_setinparameters_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. Usingfdtrcdirectly can be much faster than calling thesfmethod ofscipy.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).>>>fromscipy.statsimportf>>>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 equalTrue