scipy.special.gdtrib#

scipy.special.gdtrib(a, p, x, out=None) = <wrapped_ufunc 'gdtrib'>#

Inverse of gdtr vs b.

Returns the inverse with respect to the parameter b of p = gdtr(a, b, x), the cumulative distribution function of the gamma distribution.

Parameters:
aarray_like

a parameter values of gdtr(a, b, x)`. ``1/a is the “scale” parameter of the gamma distribution.

parray_like

Probability values.

xarray_like

Nonnegative real values, from the domain of the gamma distribution.

outndarray, optional

If a fourth argument is given, it must be a numpy.ndarray whose size matches the broadcast result of a, b and x. out is then the array returned by the function.

Returns:
bscalar or ndarray

Values of the b parameter such that p = gdtr(a, b, x). b is the “shape” parameter of the gamma distribution.

See also

gdtr

CDF of the gamma distribution.

gdtria

Inverse with respect to a of gdtr(a, b, x).

gdtrix

Inverse with respect to x of gdtr(a, b, x).

Notes

The cumulative distribution function p is computed using the Cephes [1] routines igam and igamc. Computation of b involves a search for a value that produces the desired value of p using Chandrupatla’s bracketing root finding algorithm [2].

Note that there are some edge cases where gdtrib is extended by taking limits where they are uniquely defined. In particular x == 0 with p > 0 and p == 0 with x > 0. For these edge cases, a numerical result will be returned for gdtrib(a, p, x) even though gdtr(a, gdtrib(a, p, x), x) is undefined.

Array API Standard Support

gdtrib has support for Python Array API Standard compatible backends in addition to NumPy. The following combinations of backend and device (or other capability) are supported.

Library

CPU

GPU

NumPy

✅

n/a

CuPy

n/a

⛔

PyTorch

✅

⛔

JAX

✅

⛔

Dask

✅

n/a

For the NumPy backend, this function supports all NumPy ufunc keyword arguments. Other backends may support out, but typically none of the other ufunc kwargs. out is typically supported for CuPy and PyTorch, but not currently in cases where SciPy relies on a generic Array API implementation or, for PyTorch on CPU, falls back to the NumPy backend. out is never supported for JAX because JAX arrays are immutable. gdtrib does not currently support out for the PyTorch backend.

See Support for the array API standard for more information.

References

[1]

Cephes Mathematical Functions Library, https://netlib.org/cephes/

[2]

Chandrupatla, Tirupathi R. “A new hybrid quadratic/bisection algorithm for finding the zero of a nonlinear function without using derivatives”. Advances in Engineering Software, 28(3), 145-149. DOI:10.1016/s0965-9978(96)00051-8.

Examples

First evaluate gdtr.

>>> from scipy.special import gdtr, gdtrib
>>> p = gdtr(1.2, 3.4, 5.6)
>>> print(p)
0.94378087442

Verify the inverse.

>>> gdtrib(1.2, p, 5.6)
3.3999999999999995