code stringlengths 66 870k | docstring stringlengths 19 26.7k | func_name stringlengths 1 138 | language stringclasses 1
value | repo stringlengths 7 68 | path stringlengths 5 324 | url stringlengths 46 389 | license stringclasses 7
values |
|---|---|---|---|---|---|---|---|
def _overlap_and_add(x: Array, step_size: int) -> Array:
"""Utility function compatible with tf.signal.overlap_and_add.
Args:
x: An array with `(..., frames, frame_length)`-shape.
step_size: An integer denoting overlap offsets. Must be less than
`frame_length`.
Returns:
An array with `(..., ou... | Utility function compatible with tf.signal.overlap_and_add.
Args:
x: An array with `(..., frames, frame_length)`-shape.
step_size: An integer denoting overlap offsets. Must be less than
`frame_length`.
Returns:
An array with `(..., output_size)`-shape containing overlapped signal.
| _overlap_and_add | python | jax-ml/jax | jax/_src/scipy/signal.py | https://github.com/jax-ml/jax/blob/master/jax/_src/scipy/signal.py | Apache-2.0 |
def istft(Zxx: Array, fs: ArrayLike = 1.0, window: str = 'hann',
nperseg: int | None = None, noverlap: int | None = None,
nfft: int | None = None, input_onesided: bool = True,
boundary: bool = True, time_axis: int = -1,
freq_axis: int = -2) -> tuple[Array, Array]:
"""
Perform... |
Perform the inverse short-time Fourier transform (ISTFT).
JAX implementation of :func:`scipy.signal.istft`; computes the inverse of
:func:`jax.scipy.signal.stft`.
Args:
Zxx: STFT of the signal to be reconstructed.
fs: Sampling frequency of the time series (default: 1.0)
window: Data tapering wind... | istft | python | jax-ml/jax | jax/_src/scipy/signal.py | https://github.com/jax-ml/jax/blob/master/jax/_src/scipy/signal.py | Apache-2.0 |
def gammasgn(x: ArrayLike) -> Array:
r"""Sign of the gamma function.
JAX implementation of :obj:`scipy.special.gammasgn`.
.. math::
\mathrm{gammasgn}(x) = \begin{cases}
+1 & \Gamma(x) > 0 \\
-1 & \Gamma(x) < 0
\end{cases}
Where :math:`\Gamma` is the :func:`~jax.scipy.special.gamma` funct... | Sign of the gamma function.
JAX implementation of :obj:`scipy.special.gammasgn`.
.. math::
\mathrm{gammasgn}(x) = \begin{cases}
+1 & \Gamma(x) > 0 \\
-1 & \Gamma(x) < 0
\end{cases}
Where :math:`\Gamma` is the :func:`~jax.scipy.special.gamma` function.
Because :math:`\Gamma(x)` is never z... | gammasgn | python | jax-ml/jax | jax/_src/scipy/special.py | https://github.com/jax-ml/jax/blob/master/jax/_src/scipy/special.py | Apache-2.0 |
def gamma(x: ArrayLike) -> Array:
r"""The gamma function.
JAX implementation of :obj:`scipy.special.gamma`.
The gamma function is defined for :math:`\Re(z)>0` as
.. math::
\mathrm{gamma}(z) = \Gamma(z) = \int_0^\infty t^{z-1}e^{-t}\mathrm{d}t
and is extended by analytic continuation to arbitrary com... | The gamma function.
JAX implementation of :obj:`scipy.special.gamma`.
The gamma function is defined for :math:`\Re(z)>0` as
.. math::
\mathrm{gamma}(z) = \Gamma(z) = \int_0^\infty t^{z-1}e^{-t}\mathrm{d}t
and is extended by analytic continuation to arbitrary complex values `z`.
For positive integers... | gamma | python | jax-ml/jax | jax/_src/scipy/special.py | https://github.com/jax-ml/jax/blob/master/jax/_src/scipy/special.py | Apache-2.0 |
def betaln(a: ArrayLike, b: ArrayLike) -> Array:
r"""Natural log of the absolute value of the beta function
JAX implementation of :obj:`scipy.special.betaln`.
.. math::
\mathrm{betaln}(a, b) = \log B(a, b)
where :math:`B` is the :func:`~jax.scipy.special.beta` function.
Args:
a: arraylike, real-... | Natural log of the absolute value of the beta function
JAX implementation of :obj:`scipy.special.betaln`.
.. math::
\mathrm{betaln}(a, b) = \log B(a, b)
where :math:`B` is the :func:`~jax.scipy.special.beta` function.
Args:
a: arraylike, real-valued. Parameter *a* of the beta distribution.
b:... | betaln | python | jax-ml/jax | jax/_src/scipy/special.py | https://github.com/jax-ml/jax/blob/master/jax/_src/scipy/special.py | Apache-2.0 |
def factorial(n: ArrayLike, exact: bool = False) -> Array:
r"""Factorial function
JAX implementation of :obj:`scipy.special.factorial`
.. math::
\mathrm{factorial}(n) = n! = \prod_{k=1}^n k
Args:
n: arraylike, values for which factorial will be computed elementwise
exact: bool, only ``exact=Fal... | Factorial function
JAX implementation of :obj:`scipy.special.factorial`
.. math::
\mathrm{factorial}(n) = n! = \prod_{k=1}^n k
Args:
n: arraylike, values for which factorial will be computed elementwise
exact: bool, only ``exact=False`` is supported.
Returns:
array containing values of the... | factorial | python | jax-ml/jax | jax/_src/scipy/special.py | https://github.com/jax-ml/jax/blob/master/jax/_src/scipy/special.py | Apache-2.0 |
def beta(a: ArrayLike, b: ArrayLike) -> Array:
r"""The beta function
JAX implementation of :obj:`scipy.special.beta`.
.. math::
\mathrm{beta}(a, b) = B(a, b) = \frac{\Gamma(a)\Gamma(b)}{\Gamma(a + b)}
where :math:`\Gamma` is the :func:`~jax.scipy.special.gamma` function.
Args:
a: arraylike, real... | The beta function
JAX implementation of :obj:`scipy.special.beta`.
.. math::
\mathrm{beta}(a, b) = B(a, b) = \frac{\Gamma(a)\Gamma(b)}{\Gamma(a + b)}
where :math:`\Gamma` is the :func:`~jax.scipy.special.gamma` function.
Args:
a: arraylike, real-valued. Parameter *a* of the beta distribution.
... | beta | python | jax-ml/jax | jax/_src/scipy/special.py | https://github.com/jax-ml/jax/blob/master/jax/_src/scipy/special.py | Apache-2.0 |
def logit(x: ArrayLike) -> Array:
r"""The logit function
JAX implementation of :obj:`scipy.special.logit`.
.. math::
\mathrm{logit}(p) = \log\frac{p}{1 - p}
Args:
x: arraylike, real-valued.
Returns:
array containing values of the logit function.
"""
x, = promote_args_inexact("logit", x)
... | The logit function
JAX implementation of :obj:`scipy.special.logit`.
.. math::
\mathrm{logit}(p) = \log\frac{p}{1 - p}
Args:
x: arraylike, real-valued.
Returns:
array containing values of the logit function.
| logit | python | jax-ml/jax | jax/_src/scipy/special.py | https://github.com/jax-ml/jax/blob/master/jax/_src/scipy/special.py | Apache-2.0 |
def xlogy(x: ArrayLike, y: ArrayLike) -> Array:
"""Compute x*log(y), returning 0 for x=0.
JAX implementation of :obj:`scipy.special.xlogy`.
This is defined to return zero when :math:`(x, y) = (0, 0)`, with a custom
derivative rule so that automatic differentiation is well-defined at this point.
Args:
x... | Compute x*log(y), returning 0 for x=0.
JAX implementation of :obj:`scipy.special.xlogy`.
This is defined to return zero when :math:`(x, y) = (0, 0)`, with a custom
derivative rule so that automatic differentiation is well-defined at this point.
Args:
x: arraylike, real-valued.
y: arraylike, real-valu... | xlogy | python | jax-ml/jax | jax/_src/scipy/special.py | https://github.com/jax-ml/jax/blob/master/jax/_src/scipy/special.py | Apache-2.0 |
def xlog1py(x: ArrayLike, y: ArrayLike) -> Array:
"""Compute x*log(1 + y), returning 0 for x=0.
JAX implementation of :obj:`scipy.special.xlog1py`.
This is defined to return 0 when :math:`(x, y) = (0, -1)`, with a custom
derivative rule so that automatic differentiation is well-defined at this point.
Args:... | Compute x*log(1 + y), returning 0 for x=0.
JAX implementation of :obj:`scipy.special.xlog1py`.
This is defined to return 0 when :math:`(x, y) = (0, -1)`, with a custom
derivative rule so that automatic differentiation is well-defined at this point.
Args:
x: arraylike, real-valued.
y: arraylike, real-... | xlog1py | python | jax-ml/jax | jax/_src/scipy/special.py | https://github.com/jax-ml/jax/blob/master/jax/_src/scipy/special.py | Apache-2.0 |
def entr(x: ArrayLike) -> Array:
r"""The entropy function
JAX implementation of :obj:`scipy.special.entr`.
.. math::
\mathrm{entr}(x) = \begin{cases}
-x\log(x) & x > 0 \\
0 & x = 0\\
-\infty & \mathrm{otherwise}
\end{cases}
Args:
x: arraylike, real-valued.
Returns:
... | The entropy function
JAX implementation of :obj:`scipy.special.entr`.
.. math::
\mathrm{entr}(x) = \begin{cases}
-x\log(x) & x > 0 \\
0 & x = 0\\
-\infty & \mathrm{otherwise}
\end{cases}
Args:
x: arraylike, real-valued.
Returns:
array containing entropy values.
See... | entr | python | jax-ml/jax | jax/_src/scipy/special.py | https://github.com/jax-ml/jax/blob/master/jax/_src/scipy/special.py | Apache-2.0 |
def multigammaln(a: ArrayLike, d: ArrayLike) -> Array:
r"""The natural log of the multivariate gamma function.
JAX implementation of :func:`scipy.special.multigammaln`.
.. math::
\mathrm{multigammaln}(a, d) = \log\Gamma_d(a)
where
.. math::
\Gamma_d(a) = \pi^{d(d-1)/4}\prod_{i=1}^d\Gamma(a-(i-... | The natural log of the multivariate gamma function.
JAX implementation of :func:`scipy.special.multigammaln`.
.. math::
\mathrm{multigammaln}(a, d) = \log\Gamma_d(a)
where
.. math::
\Gamma_d(a) = \pi^{d(d-1)/4}\prod_{i=1}^d\Gamma(a-(i-1)/2)
and :math:`\Gamma(x)` is the :func:`~jax.scipy.speci... | multigammaln | python | jax-ml/jax | jax/_src/scipy/special.py | https://github.com/jax-ml/jax/blob/master/jax/_src/scipy/special.py | Apache-2.0 |
def kl_div(
p: ArrayLike,
q: ArrayLike,
) -> Array:
r"""The Kullback-Leibler divergence.
JAX implementation of :obj:`scipy.special.kl_div`.
.. math::
\mathrm{kl\_div}(p, q) = \begin{cases}
p\log(p/q)-p+q & p>0,q>0\\
q & p=0,q\ge 0\\
\infty & \mathrm{otherwise}
\end{cases}
... | The Kullback-Leibler divergence.
JAX implementation of :obj:`scipy.special.kl_div`.
.. math::
\mathrm{kl\_div}(p, q) = \begin{cases}
p\log(p/q)-p+q & p>0,q>0\\
q & p=0,q\ge 0\\
\infty & \mathrm{otherwise}
\end{cases}
Args:
p: arraylike, real-valued.
q: arraylike, real-val... | kl_div | python | jax-ml/jax | jax/_src/scipy/special.py | https://github.com/jax-ml/jax/blob/master/jax/_src/scipy/special.py | Apache-2.0 |
def rel_entr(
p: ArrayLike,
q: ArrayLike,
) -> Array:
r"""The relative entropy function.
JAX implementation of :obj:`scipy.special.rel_entr`.
.. math::
\mathrm{rel\_entr}(p, q) = \begin{cases}
p\log(p/q) & p>0,q>0\\
0 & p=0,q\ge 0\\
\infty & \mathrm{otherwise}
\end{cases}
... | The relative entropy function.
JAX implementation of :obj:`scipy.special.rel_entr`.
.. math::
\mathrm{rel\_entr}(p, q) = \begin{cases}
p\log(p/q) & p>0,q>0\\
0 & p=0,q\ge 0\\
\infty & \mathrm{otherwise}
\end{cases}
Args:
p: arraylike, real-valued.
q: arraylike, real-value... | rel_entr | python | jax-ml/jax | jax/_src/scipy/special.py | https://github.com/jax-ml/jax/blob/master/jax/_src/scipy/special.py | Apache-2.0 |
def zeta(x: ArrayLike, q: ArrayLike | None = None) -> Array:
r"""The Hurwitz zeta function.
JAX implementation of :func:`scipy.special.zeta`. JAX does not implement
the Riemann zeta function (i.e. ``q = None``).
.. math::
\zeta(x, q) = \sum_{n=0}^\infty \frac{1}{(n + q)^x}
Args:
x: arraylike, rea... | The Hurwitz zeta function.
JAX implementation of :func:`scipy.special.zeta`. JAX does not implement
the Riemann zeta function (i.e. ``q = None``).
.. math::
\zeta(x, q) = \sum_{n=0}^\infty \frac{1}{(n + q)^x}
Args:
x: arraylike, real-valued
q: arraylike, real-valued
Returns:
array of zet... | zeta | python | jax-ml/jax | jax/_src/scipy/special.py | https://github.com/jax-ml/jax/blob/master/jax/_src/scipy/special.py | Apache-2.0 |
def polygamma(n: ArrayLike, x: ArrayLike) -> Array:
r"""The polygamma function.
JAX implementation of :func:`scipy.special.polygamma`.
.. math::
\mathrm{polygamma}(n, x) = \psi^{(n)}(x) = \frac{\mathrm{d}^n}{\mathrm{d}x^n}\log \Gamma(x)
where :math:`\Gamma` is the :func:`~jax.scipy.special.gamma` funct... | The polygamma function.
JAX implementation of :func:`scipy.special.polygamma`.
.. math::
\mathrm{polygamma}(n, x) = \psi^{(n)}(x) = \frac{\mathrm{d}^n}{\mathrm{d}x^n}\log \Gamma(x)
where :math:`\Gamma` is the :func:`~jax.scipy.special.gamma` function.
Args:
n: arraylike, integer-valued. The order ... | polygamma | python | jax-ml/jax | jax/_src/scipy/special.py | https://github.com/jax-ml/jax/blob/master/jax/_src/scipy/special.py | Apache-2.0 |
def ndtr(x: ArrayLike) -> Array:
r"""Normal distribution function.
JAX implementation of :obj:`scipy.special.ndtr`.
Returns the area under the Gaussian probability density function, integrated
from minus infinity to x:
.. math::
\begin{align}
\mathrm{ndtr}(x) =&
\ \frac{1}{\sqrt{2 \pi}}\int_{... | Normal distribution function.
JAX implementation of :obj:`scipy.special.ndtr`.
Returns the area under the Gaussian probability density function, integrated
from minus infinity to x:
.. math::
\begin{align}
\mathrm{ndtr}(x) =&
\ \frac{1}{\sqrt{2 \pi}}\int_{-\infty}^{x} e^{-\frac{1}{2}t^2} dt \\
... | ndtr | python | jax-ml/jax | jax/_src/scipy/special.py | https://github.com/jax-ml/jax/blob/master/jax/_src/scipy/special.py | Apache-2.0 |
def ndtri(p: ArrayLike) -> Array:
r"""The inverse of the CDF of the Normal distribution function.
JAX implementation of :obj:`scipy.special.ndtri`.
Returns `x` such that the area under the PDF from :math:`-\infty` to `x` is equal
to `p`.
A piece-wise rational approximation is done for the function.
This ... | The inverse of the CDF of the Normal distribution function.
JAX implementation of :obj:`scipy.special.ndtri`.
Returns `x` such that the area under the PDF from :math:`-\infty` to `x` is equal
to `p`.
A piece-wise rational approximation is done for the function.
This is based on the implementation in netlib... | ndtri | python | jax-ml/jax | jax/_src/scipy/special.py | https://github.com/jax-ml/jax/blob/master/jax/_src/scipy/special.py | Apache-2.0 |
def _create_polynomial(var, coeffs):
"""Compute n_th order polynomial via Horner's method."""
coeffs = np.array(coeffs, dtype)
if not coeffs.size:
return jnp.zeros_like(var)
return coeffs[0] + _create_polynomial(var, coeffs[1:]) * var | Compute n_th order polynomial via Horner's method. | _create_polynomial | python | jax-ml/jax | jax/_src/scipy/special.py | https://github.com/jax-ml/jax/blob/master/jax/_src/scipy/special.py | Apache-2.0 |
def log_ndtr(x: ArrayLike, series_order: int = 3) -> Array:
r"""Log Normal distribution function.
JAX implementation of :obj:`scipy.special.log_ndtr`.
For details of the Normal distribution function see `ndtr`.
This function calculates :math:`\log(\mathrm{ndtr}(x))` by either calling
:math:`\log(\mathrm{nd... | Log Normal distribution function.
JAX implementation of :obj:`scipy.special.log_ndtr`.
For details of the Normal distribution function see `ndtr`.
This function calculates :math:`\log(\mathrm{ndtr}(x))` by either calling
:math:`\log(\mathrm{ndtr}(x))` or using an asymptotic series. Specifically:
- For `x ... | log_ndtr | python | jax-ml/jax | jax/_src/scipy/special.py | https://github.com/jax-ml/jax/blob/master/jax/_src/scipy/special.py | Apache-2.0 |
def _log_ndtr_lower(x, series_order):
"""Asymptotic expansion version of `Log[cdf(x)]`, appropriate for `x<<-1`."""
dtype = lax.dtype(x).type
x_2 = lax.square(x)
# Log of the term multiplying (1 + sum)
log_scale = -dtype(0.5) * x_2 - lax.log(-x) - dtype(0.5 * np.log(2. * np.pi))
return log_scale + lax.log(_... | Asymptotic expansion version of `Log[cdf(x)]`, appropriate for `x<<-1`. | _log_ndtr_lower | python | jax-ml/jax | jax/_src/scipy/special.py | https://github.com/jax-ml/jax/blob/master/jax/_src/scipy/special.py | Apache-2.0 |
def _log_ndtr_asymptotic_series(x, series_order):
"""Calculates the asymptotic series used in log_ndtr."""
dtype = lax.dtype(x).type
if series_order <= 0:
return np.array(1, dtype)
x_2 = lax.square(x)
even_sum = jnp.zeros_like(x)
odd_sum = jnp.zeros_like(x)
x_2n = x_2 # Start with x^{2*1} = x^{2*n} w... | Calculates the asymptotic series used in log_ndtr. | _log_ndtr_asymptotic_series | python | jax-ml/jax | jax/_src/scipy/special.py | https://github.com/jax-ml/jax/blob/master/jax/_src/scipy/special.py | Apache-2.0 |
def i0(x: ArrayLike) -> Array:
r"""Modified bessel function of zeroth order.
JAX implementation of :obj:`scipy.special.i0`.
.. math::
\mathrm{i0}(x) = I_0(x) = \sum_{k=0}^\infty \frac{(x^2/4)^k}{(k!)^2}
Args:
x: array, real-valued
Returns:
array of bessel function values.
See also:
- ... | Modified bessel function of zeroth order.
JAX implementation of :obj:`scipy.special.i0`.
.. math::
\mathrm{i0}(x) = I_0(x) = \sum_{k=0}^\infty \frac{(x^2/4)^k}{(k!)^2}
Args:
x: array, real-valued
Returns:
array of bessel function values.
See also:
- :func:`jax.scipy.special.i0e`
- :... | i0 | python | jax-ml/jax | jax/_src/scipy/special.py | https://github.com/jax-ml/jax/blob/master/jax/_src/scipy/special.py | Apache-2.0 |
def i1(x: ArrayLike) -> Array:
r"""Modified bessel function of first order.
JAX implementation of :obj:`scipy.special.i1`.
.. math::
\mathrm{i1}(x) = I_1(x) = \frac{1}{2}x\sum_{k=0}^\infty\frac{(x^2/4)^k}{k!(k+1)!}
Args:
x: array, real-valued
Returns:
array of bessel function values
See a... | Modified bessel function of first order.
JAX implementation of :obj:`scipy.special.i1`.
.. math::
\mathrm{i1}(x) = I_1(x) = \frac{1}{2}x\sum_{k=0}^\infty\frac{(x^2/4)^k}{k!(k+1)!}
Args:
x: array, real-valued
Returns:
array of bessel function values
See also:
- :func:`jax.scipy.special.i... | i1 | python | jax-ml/jax | jax/_src/scipy/special.py | https://github.com/jax-ml/jax/blob/master/jax/_src/scipy/special.py | Apache-2.0 |
def bessel_jn(z: ArrayLike, *, v: int, n_iter: int=50) -> Array:
"""Bessel function of the first kind of integer order and real argument.
Reference:
Shanjie Zhang and Jian-Ming Jin. Computation of special functions.
Wiley-Interscience, 1996.
Args:
z: The sampling point(s) at which the Bessel function of... | Bessel function of the first kind of integer order and real argument.
Reference:
Shanjie Zhang and Jian-Ming Jin. Computation of special functions.
Wiley-Interscience, 1996.
Args:
z: The sampling point(s) at which the Bessel function of the first kind are
computed.
v: The order (int) of the Bess... | bessel_jn | python | jax-ml/jax | jax/_src/scipy/special.py | https://github.com/jax-ml/jax/blob/master/jax/_src/scipy/special.py | Apache-2.0 |
def _gen_recurrence_mask(
l_max: int, is_normalized: bool, dtype: Any
) -> tuple[Array, Array]:
"""Generates a mask for recurrence relation on the remaining entries.
The remaining entries are with respect to the diagonal and offdiagonal
entries.
Args:
l_max: see `gen_normalized_legendre`.
is_norma... | Generates a mask for recurrence relation on the remaining entries.
The remaining entries are with respect to the diagonal and offdiagonal
entries.
Args:
l_max: see `gen_normalized_legendre`.
is_normalized: True if the recurrence mask is used by normalized associated
Legendre functions.
Returns:... | _gen_recurrence_mask | python | jax-ml/jax | jax/_src/scipy/special.py | https://github.com/jax-ml/jax/blob/master/jax/_src/scipy/special.py | Apache-2.0 |
def _gen_derivatives(p: Array,
x: Array,
is_normalized: bool) -> Array:
"""Generates derivatives of associated Legendre functions of the first kind.
Args:
p: The 3D array containing the values of associated Legendre functions; the
dimensions are in the sequence o... | Generates derivatives of associated Legendre functions of the first kind.
Args:
p: The 3D array containing the values of associated Legendre functions; the
dimensions are in the sequence of order (m), degree (l), and evaluation
points.
x: A vector of type `float32` or `float64` containing the sam... | _gen_derivatives | python | jax-ml/jax | jax/_src/scipy/special.py | https://github.com/jax-ml/jax/blob/master/jax/_src/scipy/special.py | Apache-2.0 |
def lpmn(m: int, n: int, z: Array) -> tuple[Array, Array]:
"""The associated Legendre functions (ALFs) of the first kind.
Args:
m: The maximum order of the associated Legendre functions.
n: The maximum degree of the associated Legendre function, often called
`l` in describing ALFs. Both the degrees a... | The associated Legendre functions (ALFs) of the first kind.
Args:
m: The maximum order of the associated Legendre functions.
n: The maximum degree of the associated Legendre function, often called
`l` in describing ALFs. Both the degrees and orders are
`[0, 1, 2, ..., l_max]`, where `l_max` denot... | lpmn | python | jax-ml/jax | jax/_src/scipy/special.py | https://github.com/jax-ml/jax/blob/master/jax/_src/scipy/special.py | Apache-2.0 |
def sph_harm_y(n: Array,
m: Array,
theta: Array,
phi: Array,
diff_n: int | None = None,
n_max: int | None = None) -> Array:
r"""Computes the spherical harmonics.
The JAX version has one extra argument `n_max`, the maximum value in `n`.
T... | Computes the spherical harmonics.
The JAX version has one extra argument `n_max`, the maximum value in `n`.
The spherical harmonic of degree `n` and order `m` can be written as
:math:`Y_n^m(\theta, \phi) = N_n^m * P_n^m(\cos \theta) * \exp(i m \phi)`,
where :math:`N_n^m = \sqrt{\frac{\left(2n+1\right) \left(n... | sph_harm_y | python | jax-ml/jax | jax/_src/scipy/special.py | https://github.com/jax-ml/jax/blob/master/jax/_src/scipy/special.py | Apache-2.0 |
def sph_harm(m: Array,
n: Array,
theta: Array,
phi: Array,
n_max: int | None = None) -> Array:
r"""Computes the spherical harmonics.
Note:
This function is deprecated, and :func:`~jax.scipy.special.sph_harm_y`
should be used instead, noting that the order... | Computes the spherical harmonics.
Note:
This function is deprecated, and :func:`~jax.scipy.special.sph_harm_y`
should be used instead, noting that the order of ``m`` and ``n`` are
reversed, and definitions of ``theta`` and ``phi`` are swapped.
The JAX version has one extra argument `n_max`, the maximu... | sph_harm | python | jax-ml/jax | jax/_src/scipy/special.py | https://github.com/jax-ml/jax/blob/master/jax/_src/scipy/special.py | Apache-2.0 |
def expi(x: ArrayLike) -> Array:
r"""Exponential integral function.
JAX implementation of :obj:`scipy.special.expi`
.. math::
\mathrm{expi}(x) = \int_{-\infty}^x \frac{e^t}{t} \mathrm{d}t
Args:
x: arraylike, real-valued
Returns:
array of expi values
See also:
- :func:`jax.scipy.specia... | Exponential integral function.
JAX implementation of :obj:`scipy.special.expi`
.. math::
\mathrm{expi}(x) = \int_{-\infty}^x \frac{e^t}{t} \mathrm{d}t
Args:
x: arraylike, real-valued
Returns:
array of expi values
See also:
- :func:`jax.scipy.special.expn`
- :func:`jax.scipy.special.... | expi | python | jax-ml/jax | jax/_src/scipy/special.py | https://github.com/jax-ml/jax/blob/master/jax/_src/scipy/special.py | Apache-2.0 |
def expn(n: ArrayLike, x: ArrayLike) -> Array:
r"""Generalized exponential integral function.
JAX implementation of :obj:`scipy.special.expn`.
.. math::
\mathrm{expn}(x) = E_n(x) = x^{n-1}\int_x^\infty\frac{e^{-t}}{t^n}\mathrm{d}t
Args:
n: arraylike, real-valued
x: arraylike, real-valued
Ret... | Generalized exponential integral function.
JAX implementation of :obj:`scipy.special.expn`.
.. math::
\mathrm{expn}(x) = E_n(x) = x^{n-1}\int_x^\infty\frac{e^{-t}}{t^n}\mathrm{d}t
Args:
n: arraylike, real-valued
x: arraylike, real-valued
Returns:
array of expn values
See also:
- :fu... | expn | python | jax-ml/jax | jax/_src/scipy/special.py | https://github.com/jax-ml/jax/blob/master/jax/_src/scipy/special.py | Apache-2.0 |
def exp1(x: ArrayLike) -> Array:
r"""Exponential integral function.
JAX implementation of :obj:`scipy.special.exp1`
.. math::
\mathrm{exp1}(x) = E_1(x) = x^{n-1}\int_x^\infty\frac{e^{-t}}{t}\mathrm{d}t
Args:
x: arraylike, real-valued
Returns:
array of exp1 values
See also:
- :func:`j... | Exponential integral function.
JAX implementation of :obj:`scipy.special.exp1`
.. math::
\mathrm{exp1}(x) = E_1(x) = x^{n-1}\int_x^\infty\frac{e^{-t}}{t}\mathrm{d}t
Args:
x: arraylike, real-valued
Returns:
array of exp1 values
See also:
- :func:`jax.scipy.special.expi`
- :func:`jax... | exp1 | python | jax-ml/jax | jax/_src/scipy/special.py | https://github.com/jax-ml/jax/blob/master/jax/_src/scipy/special.py | Apache-2.0 |
def spence(x: Array) -> Array:
r"""Spence's function, also known as the dilogarithm for real values.
JAX implementation of :obj:`scipy.special.spence`.
It is defined to be:
.. math::
\mathrm{spence}(x) = \begin{equation}
\int_1^x \frac{\log(t)}{1 - t}dt
\end{equation}
Unlike the SciPy implemen... | Spence's function, also known as the dilogarithm for real values.
JAX implementation of :obj:`scipy.special.spence`.
It is defined to be:
.. math::
\mathrm{spence}(x) = \begin{equation}
\int_1^x \frac{\log(t)}{1 - t}dt
\end{equation}
Unlike the SciPy implementation, this is only defined for posi... | spence | python | jax-ml/jax | jax/_src/scipy/special.py | https://github.com/jax-ml/jax/blob/master/jax/_src/scipy/special.py | Apache-2.0 |
def bernoulli(n: int) -> Array:
"""Generate the first N Bernoulli numbers.
JAX implementation of :func:`scipy.special.bernoulli`.
Args:
n: integer, the number of Bernoulli terms to generate.
Returns:
Array containing the first ``n`` Bernoulli numbers.
Notes:
``bernoulli`` generates numbers usi... | Generate the first N Bernoulli numbers.
JAX implementation of :func:`scipy.special.bernoulli`.
Args:
n: integer, the number of Bernoulli terms to generate.
Returns:
Array containing the first ``n`` Bernoulli numbers.
Notes:
``bernoulli`` generates numbers using the :math:`B_n^-` convention,
... | bernoulli | python | jax-ml/jax | jax/_src/scipy/special.py | https://github.com/jax-ml/jax/blob/master/jax/_src/scipy/special.py | Apache-2.0 |
def poch(z: ArrayLike, m: ArrayLike) -> Array:
r"""The Pochammer symbol.
JAX implementation of :obj:`scipy.special.poch`.
.. math::
\mathrm{poch}(z, m) = (z)_m = \frac{\Gamma(z + m)}{\Gamma(z)}
where :math:`\Gamma(z)` is the :func:`~jax.scipy.special.gamma` function.
Args:
z: arraylike, real-val... | The Pochammer symbol.
JAX implementation of :obj:`scipy.special.poch`.
.. math::
\mathrm{poch}(z, m) = (z)_m = \frac{\Gamma(z + m)}{\Gamma(z)}
where :math:`\Gamma(z)` is the :func:`~jax.scipy.special.gamma` function.
Args:
z: arraylike, real-valued
m: arraylike, real-valued
Returns:
arr... | poch | python | jax-ml/jax | jax/_src/scipy/special.py | https://github.com/jax-ml/jax/blob/master/jax/_src/scipy/special.py | Apache-2.0 |
def _hyp1f1_serie(a, b, x):
"""
Compute the 1F1 hypergeometric function using the taylor expansion
See Eq. 3.2 and associated method (a) from PEARSON, OLVER & PORTER 2014
https://doi.org/10.48550/arXiv.1407.7786
"""
precision = jnp.finfo(x.dtype).eps
def body(state):
serie, k, term = state
serie... |
Compute the 1F1 hypergeometric function using the taylor expansion
See Eq. 3.2 and associated method (a) from PEARSON, OLVER & PORTER 2014
https://doi.org/10.48550/arXiv.1407.7786
| _hyp1f1_serie | python | jax-ml/jax | jax/_src/scipy/special.py | https://github.com/jax-ml/jax/blob/master/jax/_src/scipy/special.py | Apache-2.0 |
def _hyp1f1_asymptotic(a, b, x):
"""
Compute the 1F1 hypergeometric function using asymptotic expansion
See Eq. 3.8 and simplification for real inputs from PEARSON, OLVER & PORTER 2014
https://doi.org/10.48550/arXiv.1407.7786
"""
precision = jnp.finfo(x.dtype).eps
def body(state):
serie, k, term = s... |
Compute the 1F1 hypergeometric function using asymptotic expansion
See Eq. 3.8 and simplification for real inputs from PEARSON, OLVER & PORTER 2014
https://doi.org/10.48550/arXiv.1407.7786
| _hyp1f1_asymptotic | python | jax-ml/jax | jax/_src/scipy/special.py | https://github.com/jax-ml/jax/blob/master/jax/_src/scipy/special.py | Apache-2.0 |
def _hyp1f1_a_derivative(a, b, x):
"""
Define it as a serie using :
https://functions.wolfram.com/HypergeometricFunctions/Hypergeometric1F1/20/01/01/
"""
precision = jnp.finfo(x.dtype).eps
def body(state):
serie, k, term = state
serie += term * (digamma(a + k) - digamma(a))
term *= (a + k) / (... |
Define it as a serie using :
https://functions.wolfram.com/HypergeometricFunctions/Hypergeometric1F1/20/01/01/
| _hyp1f1_a_derivative | python | jax-ml/jax | jax/_src/scipy/special.py | https://github.com/jax-ml/jax/blob/master/jax/_src/scipy/special.py | Apache-2.0 |
def _hyp1f1_b_derivative(a, b, x):
"""
Define it as a serie using :
https://functions.wolfram.com/HypergeometricFunctions/Hypergeometric1F1/20/01/02/
"""
precision = jnp.finfo(x.dtype).eps
def body(state):
serie, k, term = state
serie += term * (digamma(b) - digamma(b + k))
term *= (a + k) / (... |
Define it as a serie using :
https://functions.wolfram.com/HypergeometricFunctions/Hypergeometric1F1/20/01/02/
| _hyp1f1_b_derivative | python | jax-ml/jax | jax/_src/scipy/special.py | https://github.com/jax-ml/jax/blob/master/jax/_src/scipy/special.py | Apache-2.0 |
def hyp1f1(a: ArrayLike, b: ArrayLike, x: ArrayLike) -> Array:
r"""The 1F1 hypergeometric function.
JAX implementation of :obj:`scipy.special.hyp1f1`.
.. math::
\mathrm{hyp1f1}(a, b, x) = {}_1F_1(x;a, b) = \sum_{k=0}^\infty \frac{(a)_k}{(b)_kk!}x^k
where :math:`(\cdot)_k` is the Pochammer symbol (refer... | The 1F1 hypergeometric function.
JAX implementation of :obj:`scipy.special.hyp1f1`.
.. math::
\mathrm{hyp1f1}(a, b, x) = {}_1F_1(x;a, b) = \sum_{k=0}^\infty \frac{(a)_k}{(b)_kk!}x^k
where :math:`(\cdot)_k` is the Pochammer symbol (refer to :func:`~jax.scipy.special.poch`).
The JAX version only accepts... | hyp1f1 | python | jax-ml/jax | jax/_src/scipy/special.py | https://github.com/jax-ml/jax/blob/master/jax/_src/scipy/special.py | Apache-2.0 |
def _hyp2f1_terminal(a, b, c, x):
"""
The Taylor series representation of the 2F1 hypergeometric function
terminates when either a or b is a non-positive integer. See Eq. 4.1 and
Taylor Series Method (a) from PEARSON, OLVER & PORTER 2014
https://doi.org/10.48550/arXiv.1407.7786
"""
# Ensure that between a... |
The Taylor series representation of the 2F1 hypergeometric function
terminates when either a or b is a non-positive integer. See Eq. 4.1 and
Taylor Series Method (a) from PEARSON, OLVER & PORTER 2014
https://doi.org/10.48550/arXiv.1407.7786
| _hyp2f1_terminal | python | jax-ml/jax | jax/_src/scipy/special.py | https://github.com/jax-ml/jax/blob/master/jax/_src/scipy/special.py | Apache-2.0 |
def _hyp2f1_serie(a, b, c, x):
"""
Compute the 2F1 hypergeometric function using the Taylor expansion.
See Eq. 4.1 from PEARSON, OLVER & PORTER 2014
https://doi.org/10.48550/arXiv.1407.7786
"""
rtol = jnp.finfo(x.dtype).eps
def body(state):
serie, k, term = state
serie += term
term *= (a + k... |
Compute the 2F1 hypergeometric function using the Taylor expansion.
See Eq. 4.1 from PEARSON, OLVER & PORTER 2014
https://doi.org/10.48550/arXiv.1407.7786
| _hyp2f1_serie | python | jax-ml/jax | jax/_src/scipy/special.py | https://github.com/jax-ml/jax/blob/master/jax/_src/scipy/special.py | Apache-2.0 |
def _hyp2f1_terminal_or_serie(a, b, c, x):
"""
Check for recurrence relations along with whether or not the series
terminates. True recursion is not possible; however, the recurrence
relation may still be approximated.
See 4.6.1. Recurrence Relations from PEARSON, OLVER & PORTER 2014
https://doi.org/10.4855... |
Check for recurrence relations along with whether or not the series
terminates. True recursion is not possible; however, the recurrence
relation may still be approximated.
See 4.6.1. Recurrence Relations from PEARSON, OLVER & PORTER 2014
https://doi.org/10.48550/arXiv.1407.7786
| _hyp2f1_terminal_or_serie | python | jax-ml/jax | jax/_src/scipy/special.py | https://github.com/jax-ml/jax/blob/master/jax/_src/scipy/special.py | Apache-2.0 |
def _hyp2f1_digamma_transform(a, b, c, x):
"""
Digamma transformation of the 2F1 hypergeometric function.
See AMS55 #15.3.10, #15.3.11, #15.3.12
"""
rtol = jnp.finfo(x.dtype).eps
d = c - a - b
s = 1 - x
rd = jnp.round(d)
e = jnp.where(rd >= 0, d, -d)
d1 = jnp.where(rd >= 0, d, jnp.array(0, dtype=d... |
Digamma transformation of the 2F1 hypergeometric function.
See AMS55 #15.3.10, #15.3.11, #15.3.12
| _hyp2f1_digamma_transform | python | jax-ml/jax | jax/_src/scipy/special.py | https://github.com/jax-ml/jax/blob/master/jax/_src/scipy/special.py | Apache-2.0 |
def hyp2f1(a: ArrayLike, b: ArrayLike, c: ArrayLike, x: ArrayLike) -> Array:
r"""The 2F1 hypergeometric function.
JAX implementation of :obj:`scipy.special.hyp2f1`.
.. math::
\mathrm{hyp2f1}(a, b, c, x) = {}_2F_1(a; b; c; x) = \sum_{k=0}^\infty \frac{(a)_k(b)_k}{(c)_k}\frac{x^k}{k!}
where :math:`(\cdot... | The 2F1 hypergeometric function.
JAX implementation of :obj:`scipy.special.hyp2f1`.
.. math::
\mathrm{hyp2f1}(a, b, c, x) = {}_2F_1(a; b; c; x) = \sum_{k=0}^\infty \frac{(a)_k(b)_k}{(c)_k}\frac{x^k}{k!}
where :math:`(\cdot)_k` is the Pochammer symbol.
The JAX version only accepts positive and real inp... | hyp2f1 | python | jax-ml/jax | jax/_src/scipy/special.py | https://github.com/jax-ml/jax/blob/master/jax/_src/scipy/special.py | Apache-2.0 |
def softmax(x: ArrayLike,
/,
*,
axis: int | tuple[int, ...] | None = None,
) -> Array:
r"""Softmax function.
JAX implementation of :func:`scipy.special.softmax`.
Computes the function which rescales elements to the range :math:`[0, 1]`
such that the elements alo... | Softmax function.
JAX implementation of :func:`scipy.special.softmax`.
Computes the function which rescales elements to the range :math:`[0, 1]`
such that the elements along :code:`axis` sum to :math:`1`.
.. math ::
\mathrm{softmax}(x) = \frac{\exp(x_i)}{\sum_j \exp(x_j)}
Args:
x : input array
... | softmax | python | jax-ml/jax | jax/_src/scipy/special.py | https://github.com/jax-ml/jax/blob/master/jax/_src/scipy/special.py | Apache-2.0 |
def log_softmax(x: ArrayLike,
/,
*,
axis: int | tuple[int, ...] | None = None,
) -> Array:
r"""Log-Softmax function.
JAX implementation of :func:`scipy.special.log_softmax`
Computes the logarithm of the :code:`softmax` function, which rescales
el... | Log-Softmax function.
JAX implementation of :func:`scipy.special.log_softmax`
Computes the logarithm of the :code:`softmax` function, which rescales
elements to the range :math:`[-\infty, 0)`.
.. math ::
\mathrm{log\_softmax}(x)_i = \log \left( \frac{\exp(x_i)}{\sum_j \exp(x_j)}
\right)
Args:
... | log_softmax | python | jax-ml/jax | jax/_src/scipy/special.py | https://github.com/jax-ml/jax/blob/master/jax/_src/scipy/special.py | Apache-2.0 |
def vq(obs: ArrayLike, code_book: ArrayLike, check_finite: bool = True) -> tuple[Array, Array]:
"""Assign codes from a code book to a set of observations.
JAX implementation of :func:`scipy.cluster.vq.vq`.
Assigns each observation vector in ``obs`` to a code from ``code_book``
based on the nearest Euclidean d... | Assign codes from a code book to a set of observations.
JAX implementation of :func:`scipy.cluster.vq.vq`.
Assigns each observation vector in ``obs`` to a code from ``code_book``
based on the nearest Euclidean distance.
Args:
obs: array of observation vectors of shape ``(M, N)``. Each row represents
... | vq | python | jax-ml/jax | jax/_src/scipy/cluster/vq.py | https://github.com/jax-ml/jax/blob/master/jax/_src/scipy/cluster/vq.py | Apache-2.0 |
def minimize_bfgs(
fun: Callable,
x0: jax.Array,
maxiter: int | None = None,
norm=jnp.inf,
gtol: float = 1e-5,
line_search_maxiter: int = 10,
) -> _BFGSResults:
"""Minimize a function using BFGS.
Implements the BFGS algorithm from
Algorithm 6.1 from Wright and Nocedal, 'Numerical Optimi... | Minimize a function using BFGS.
Implements the BFGS algorithm from
Algorithm 6.1 from Wright and Nocedal, 'Numerical Optimization', 1999, pg.
136-143.
Args:
fun: function of the form f(x) where x is a flat ndarray and returns a real
scalar. The function should be composed of operations with vjp ... | minimize_bfgs | python | jax-ml/jax | jax/_src/scipy/optimize/bfgs.py | https://github.com/jax-ml/jax/blob/master/jax/_src/scipy/optimize/bfgs.py | Apache-2.0 |
def _zoom(restricted_func_and_grad, wolfe_one, wolfe_two, a_lo, phi_lo,
dphi_lo, a_hi, phi_hi, dphi_hi, g_0, pass_through):
"""
Implementation of zoom. Algorithm 3.6 from Wright and Nocedal, 'Numerical
Optimization', 1999, pg. 59-61. Tries cubic, quadratic, and bisection methods
of zooming.
"""
st... |
Implementation of zoom. Algorithm 3.6 from Wright and Nocedal, 'Numerical
Optimization', 1999, pg. 59-61. Tries cubic, quadratic, and bisection methods
of zooming.
| _zoom | python | jax-ml/jax | jax/_src/scipy/optimize/line_search.py | https://github.com/jax-ml/jax/blob/master/jax/_src/scipy/optimize/line_search.py | Apache-2.0 |
def line_search(f, xk, pk, old_fval=None, old_old_fval=None, gfk=None, c1=1e-4,
c2=0.9, maxiter=20):
"""Inexact line search that satisfies strong Wolfe conditions.
Algorithm 3.5 from Wright and Nocedal, 'Numerical Optimization', 1999, pg. 59-61
Args:
fun: function of the form f(x) where x is... | Inexact line search that satisfies strong Wolfe conditions.
Algorithm 3.5 from Wright and Nocedal, 'Numerical Optimization', 1999, pg. 59-61
Args:
fun: function of the form f(x) where x is a flat ndarray and returns a real
scalar. The function should be composed of operations with vjp defined.
x0: i... | line_search | python | jax-ml/jax | jax/_src/scipy/optimize/line_search.py | https://github.com/jax-ml/jax/blob/master/jax/_src/scipy/optimize/line_search.py | Apache-2.0 |
def minimize(
fun: Callable,
x0: jax.Array,
args: tuple = (),
*,
method: str,
tol: float | None = None,
options: Mapping[str, Any] | None = None,
) -> OptimizeResults:
"""Minimization of scalar function of one or more variables.
This API for this function matches SciPy with some minor d... | Minimization of scalar function of one or more variables.
This API for this function matches SciPy with some minor deviations:
- Gradients of ``fun`` are calculated automatically using JAX's autodiff
support when required.
- The ``method`` argument is required. You must specify a solver.
- Various optiona... | minimize | python | jax-ml/jax | jax/_src/scipy/optimize/minimize.py | https://github.com/jax-ml/jax/blob/master/jax/_src/scipy/optimize/minimize.py | Apache-2.0 |
def _minimize_lbfgs(
fun: Callable,
x0: Array,
maxiter: float | None = None,
norm=jnp.inf,
maxcor: int = 10,
ftol: float = 2.220446049250313e-09,
gtol: float = 1e-05,
maxfun: float | None = None,
maxgrad: float | None = None,
maxls: int = 20,
):
"""
Minimize a function using ... |
Minimize a function using L-BFGS
Implements the L-BFGS algorithm from
Algorithm 7.5 from Wright and Nocedal, 'Numerical Optimization', 1999, pg. 176-185
And generalizes to complex variables from
Sorber, L., Barel, M.V. and Lathauwer, L.D., 2012.
"Unconstrained optimization of real functions in com... | _minimize_lbfgs | python | jax-ml/jax | jax/_src/scipy/optimize/_lbfgs.py | https://github.com/jax-ml/jax/blob/master/jax/_src/scipy/optimize/_lbfgs.py | Apache-2.0 |
def _normalize_matvec(f):
"""Normalize an argument for computing matrix-vector products."""
if callable(f):
return f
elif isinstance(f, (np.ndarray, jax.Array)):
if f.ndim != 2 or f.shape[0] != f.shape[1]:
raise ValueError(
f'linear operator must be a square matrix, but has shape: {f.shape... | Normalize an argument for computing matrix-vector products. | _normalize_matvec | python | jax-ml/jax | jax/_src/scipy/sparse/linalg.py | https://github.com/jax-ml/jax/blob/master/jax/_src/scipy/sparse/linalg.py | Apache-2.0 |
def _safe_normalize(x, thresh=None):
"""
Returns the L2-normalized vector (which can be a pytree) x, and optionally
the computed norm. If the computed norm is less than the threshold `thresh`,
which by default is the machine precision of x's dtype, it will be
taken to be 0, and the normalized x to be the zero... |
Returns the L2-normalized vector (which can be a pytree) x, and optionally
the computed norm. If the computed norm is less than the threshold `thresh`,
which by default is the machine precision of x's dtype, it will be
taken to be 0, and the normalized x to be the zero vector.
| _safe_normalize | python | jax-ml/jax | jax/_src/scipy/sparse/linalg.py | https://github.com/jax-ml/jax/blob/master/jax/_src/scipy/sparse/linalg.py | Apache-2.0 |
def _iterative_classical_gram_schmidt(Q, x, xnorm, max_iterations=2):
"""
Orthogonalize x against the columns of Q. The process is repeated
up to `max_iterations` times, or fewer if the condition
||r|| < (1/sqrt(2)) ||x|| is met earlier (see below for the meaning
of r and x).
Parameters
----------
Q : ... |
Orthogonalize x against the columns of Q. The process is repeated
up to `max_iterations` times, or fewer if the condition
||r|| < (1/sqrt(2)) ||x|| is met earlier (see below for the meaning
of r and x).
Parameters
----------
Q : array or tree of arrays
A matrix of orthonormal columns.
x : array ... | _iterative_classical_gram_schmidt | python | jax-ml/jax | jax/_src/scipy/sparse/linalg.py | https://github.com/jax-ml/jax/blob/master/jax/_src/scipy/sparse/linalg.py | Apache-2.0 |
def _kth_arnoldi_iteration(k, A, M, V, H):
"""
Performs a single (the k'th) step of the Arnoldi process. Thus,
adds a new orthonormalized Krylov vector A(M(V[:, k])) to V[:, k+1],
and that vectors overlaps with the existing Krylov vectors to
H[k, :]. The tolerance 'tol' sets the threshold at which an invarian... |
Performs a single (the k'th) step of the Arnoldi process. Thus,
adds a new orthonormalized Krylov vector A(M(V[:, k])) to V[:, k+1],
and that vectors overlaps with the existing Krylov vectors to
H[k, :]. The tolerance 'tol' sets the threshold at which an invariant
subspace is declared to have been found, in ... | _kth_arnoldi_iteration | python | jax-ml/jax | jax/_src/scipy/sparse/linalg.py | https://github.com/jax-ml/jax/blob/master/jax/_src/scipy/sparse/linalg.py | Apache-2.0 |
def _apply_givens_rotations(H_row, givens, k):
"""
Applies the Givens rotations stored in the vectors cs and sn to the vector
H_row. Then constructs and applies a new Givens rotation that eliminates
H_row's k'th element.
"""
# This call successively applies each of the
# Givens rotations stored in givens[... |
Applies the Givens rotations stored in the vectors cs and sn to the vector
H_row. Then constructs and applies a new Givens rotation that eliminates
H_row's k'th element.
| _apply_givens_rotations | python | jax-ml/jax | jax/_src/scipy/sparse/linalg.py | https://github.com/jax-ml/jax/blob/master/jax/_src/scipy/sparse/linalg.py | Apache-2.0 |
def _gmres_incremental(A, b, x0, unit_residual, residual_norm, ptol, restart, M):
"""
Implements a single restart of GMRES. The restart-dimensional Krylov subspace
K(A, x0) = span(A(x0), A@x0, A@A@x0, ..., A^restart @ x0) is built, and the
projection of the true solution into this subspace is returned.
This ... |
Implements a single restart of GMRES. The restart-dimensional Krylov subspace
K(A, x0) = span(A(x0), A@x0, A@A@x0, ..., A^restart @ x0) is built, and the
projection of the true solution into this subspace is returned.
This implementation builds the QR factorization during the Arnoldi process.
| _gmres_incremental | python | jax-ml/jax | jax/_src/scipy/sparse/linalg.py | https://github.com/jax-ml/jax/blob/master/jax/_src/scipy/sparse/linalg.py | Apache-2.0 |
def _gmres_batched(A, b, x0, unit_residual, residual_norm, ptol, restart, M):
"""
Implements a single restart of GMRES. The ``restart``-dimensional Krylov
subspace
K(A, x0) = span(A(x0), A@x0, A@A@x0, ..., A^restart @ x0) is built, and the
projection of the true solution into this subspace is returned.
Thi... |
Implements a single restart of GMRES. The ``restart``-dimensional Krylov
subspace
K(A, x0) = span(A(x0), A@x0, A@A@x0, ..., A^restart @ x0) is built, and the
projection of the true solution into this subspace is returned.
This implementation solves a dense linear problem instead of building
a QR factoriza... | _gmres_batched | python | jax-ml/jax | jax/_src/scipy/sparse/linalg.py | https://github.com/jax-ml/jax/blob/master/jax/_src/scipy/sparse/linalg.py | Apache-2.0 |
def _gmres_solve(A, b, x0, atol, ptol, restart, maxiter, M, gmres_func):
"""
The main function call wrapped by custom_linear_solve. Repeatedly calls GMRES
to find the projected solution within the order-``restart``
Krylov space K(A, x0, restart), using the result of the previous projection
in place of x0 each... |
The main function call wrapped by custom_linear_solve. Repeatedly calls GMRES
to find the projected solution within the order-``restart``
Krylov space K(A, x0, restart), using the result of the previous projection
in place of x0 each time. Parameters are the same as in ``gmres`` except:
atol: Tolerance for ... | _gmres_solve | python | jax-ml/jax | jax/_src/scipy/sparse/linalg.py | https://github.com/jax-ml/jax/blob/master/jax/_src/scipy/sparse/linalg.py | Apache-2.0 |
def gmres(A, b, x0=None, *, tol=1e-5, atol=0.0, restart=20, maxiter=None,
M=None, solve_method='batched'):
"""
GMRES solves the linear system A x = b for x, given A and b.
A is specified as a function performing A(vi) -> vf = A @ vi, and in principle
need not have any particular special properties, s... |
GMRES solves the linear system A x = b for x, given A and b.
A is specified as a function performing A(vi) -> vf = A @ vi, and in principle
need not have any particular special properties, such as symmetry. However,
convergence is often slow for nearly symmetric operators.
Parameters
----------
A: ndar... | gmres | python | jax-ml/jax | jax/_src/scipy/sparse/linalg.py | https://github.com/jax-ml/jax/blob/master/jax/_src/scipy/sparse/linalg.py | Apache-2.0 |
def bicgstab(A, b, x0=None, *, tol=1e-5, atol=0.0, maxiter=None, M=None):
"""Use Bi-Conjugate Gradient Stable iteration to solve ``Ax = b``.
The numerics of JAX's ``bicgstab`` should exact match SciPy's
``bicgstab`` (up to numerical precision), but note that the interface
is slightly different: you need to sup... | Use Bi-Conjugate Gradient Stable iteration to solve ``Ax = b``.
The numerics of JAX's ``bicgstab`` should exact match SciPy's
``bicgstab`` (up to numerical precision), but note that the interface
is slightly different: you need to supply the linear operator ``A`` as
a function instead of a sparse matrix or ``L... | bicgstab | python | jax-ml/jax | jax/_src/scipy/sparse/linalg.py | https://github.com/jax-ml/jax/blob/master/jax/_src/scipy/sparse/linalg.py | Apache-2.0 |
def __getitem__(self, indexer):
"""Extract rotation(s) at given index(es) from object."""
if self.single:
raise TypeError("Single rotation is not subscriptable.")
return Rotation(self.quat[indexer]) | Extract rotation(s) at given index(es) from object. | __getitem__ | python | jax-ml/jax | jax/_src/scipy/spatial/transform.py | https://github.com/jax-ml/jax/blob/master/jax/_src/scipy/spatial/transform.py | Apache-2.0 |
def __len__(self):
"""Number of rotations contained in this object."""
if self.single:
raise TypeError('Single rotation has no len().')
else:
return self.quat.shape[0] | Number of rotations contained in this object. | __len__ | python | jax-ml/jax | jax/_src/scipy/spatial/transform.py | https://github.com/jax-ml/jax/blob/master/jax/_src/scipy/spatial/transform.py | Apache-2.0 |
def mean(self, weights: jax.Array | None = None):
"""Get the mean of the rotations."""
w = jnp.ones(self.quat.shape[0], dtype=self.quat.dtype) if weights is None else jnp.asarray(weights, dtype=self.quat.dtype)
if w.ndim != 1:
raise ValueError("Expected `weights` to be 1 dimensional, got "
... | Get the mean of the rotations. | mean | python | jax-ml/jax | jax/_src/scipy/spatial/transform.py | https://github.com/jax-ml/jax/blob/master/jax/_src/scipy/spatial/transform.py | Apache-2.0 |
def logpmf(k: ArrayLike, p: ArrayLike, loc: ArrayLike = 0) -> Array:
r"""Bernoulli log probability mass function.
JAX implementation of :obj:`scipy.stats.bernoulli` ``logpmf``
The Bernoulli probability mass function is defined as
.. math::
f(k) = \begin{cases}
1 - p, & k = 0 \\
p, & k = 1... | Bernoulli log probability mass function.
JAX implementation of :obj:`scipy.stats.bernoulli` ``logpmf``
The Bernoulli probability mass function is defined as
.. math::
f(k) = \begin{cases}
1 - p, & k = 0 \\
p, & k = 1 \\
0, & \mathrm{otherwise}
\end{cases}
Args:
k: arrayli... | logpmf | python | jax-ml/jax | jax/_src/scipy/stats/bernoulli.py | https://github.com/jax-ml/jax/blob/master/jax/_src/scipy/stats/bernoulli.py | Apache-2.0 |
def cdf(k: ArrayLike, p: ArrayLike) -> Array:
r"""Bernoulli cumulative distribution function.
JAX implementation of :obj:`scipy.stats.bernoulli` ``cdf``
The Bernoulli cumulative distribution function is defined as:
.. math::
f_{cdf}(k, p) = \sum_{i=0}^k f_{pmf}(k, p)
where :math:`f_{pmf}(k, p)` is t... | Bernoulli cumulative distribution function.
JAX implementation of :obj:`scipy.stats.bernoulli` ``cdf``
The Bernoulli cumulative distribution function is defined as:
.. math::
f_{cdf}(k, p) = \sum_{i=0}^k f_{pmf}(k, p)
where :math:`f_{pmf}(k, p)` is the Bernoulli probability mass function
:func:`jax.... | cdf | python | jax-ml/jax | jax/_src/scipy/stats/bernoulli.py | https://github.com/jax-ml/jax/blob/master/jax/_src/scipy/stats/bernoulli.py | Apache-2.0 |
def ppf(q: ArrayLike, p: ArrayLike) -> Array:
"""Bernoulli percent point function.
JAX implementation of :obj:`scipy.stats.bernoulli` ``ppf``
The percent point function is the inverse of the cumulative
distribution function, :func:`jax.scipy.stats.bernoulli.cdf`.
Args:
k: arraylike, value at which to e... | Bernoulli percent point function.
JAX implementation of :obj:`scipy.stats.bernoulli` ``ppf``
The percent point function is the inverse of the cumulative
distribution function, :func:`jax.scipy.stats.bernoulli.cdf`.
Args:
k: arraylike, value at which to evaluate the PPF
p: arraylike, distribution shap... | ppf | python | jax-ml/jax | jax/_src/scipy/stats/bernoulli.py | https://github.com/jax-ml/jax/blob/master/jax/_src/scipy/stats/bernoulli.py | Apache-2.0 |
def logpdf(x: ArrayLike, a: ArrayLike, b: ArrayLike,
loc: ArrayLike = 0, scale: ArrayLike = 1) -> Array:
r"""Beta log probability distribution function.
JAX implementation of :obj:`scipy.stats.beta` ``logpdf``.
The pdf of the beta function is:
.. math::
f(x, a, b) = \frac{\Gamma(a + b)}{\Gamm... | Beta log probability distribution function.
JAX implementation of :obj:`scipy.stats.beta` ``logpdf``.
The pdf of the beta function is:
.. math::
f(x, a, b) = \frac{\Gamma(a + b)}{\Gamma(a)\Gamma(b)} x^{a-1}(1-x)^{b-1}
where :math:`\Gamma` is the :func:`~jax.scipy.special.gamma` function,
It is define... | logpdf | python | jax-ml/jax | jax/_src/scipy/stats/beta.py | https://github.com/jax-ml/jax/blob/master/jax/_src/scipy/stats/beta.py | Apache-2.0 |
def pdf(x: ArrayLike, a: ArrayLike, b: ArrayLike,
loc: ArrayLike = 0, scale: ArrayLike = 1) -> Array:
r"""Beta probability distribution function.
JAX implementation of :obj:`scipy.stats.beta` ``pdf``.
The pdf of the beta function is:
.. math::
f(x, a, b) = \frac{\Gamma(a + b)}{\Gamma(a)\Gamma(b)... | Beta probability distribution function.
JAX implementation of :obj:`scipy.stats.beta` ``pdf``.
The pdf of the beta function is:
.. math::
f(x, a, b) = \frac{\Gamma(a + b)}{\Gamma(a)\Gamma(b)} x^{a-1}(1-x)^{b-1}
where :math:`\Gamma` is the :func:`~jax.scipy.special.gamma` function.
It is defined for :... | pdf | python | jax-ml/jax | jax/_src/scipy/stats/beta.py | https://github.com/jax-ml/jax/blob/master/jax/_src/scipy/stats/beta.py | Apache-2.0 |
def cdf(x: ArrayLike, a: ArrayLike, b: ArrayLike,
loc: ArrayLike = 0, scale: ArrayLike = 1) -> Array:
r"""Beta cumulative distribution function
JAX implementation of :obj:`scipy.stats.beta` ``cdf``.
The cdf is defined as
.. math::
f_{cdf}(x, a, b) = \int_{-\infty}^x f_{pdf}(y, a, b)\mathrm{d}y
... | Beta cumulative distribution function
JAX implementation of :obj:`scipy.stats.beta` ``cdf``.
The cdf is defined as
.. math::
f_{cdf}(x, a, b) = \int_{-\infty}^x f_{pdf}(y, a, b)\mathrm{d}y
where :math:`f_{pdf}` is the beta distribution probability density function,
:func:`jax.scipy.stats.beta.pdf`.
... | cdf | python | jax-ml/jax | jax/_src/scipy/stats/beta.py | https://github.com/jax-ml/jax/blob/master/jax/_src/scipy/stats/beta.py | Apache-2.0 |
def logcdf(x: ArrayLike, a: ArrayLike, b: ArrayLike,
loc: ArrayLike = 0, scale: ArrayLike = 1) -> Array:
r"""Beta log cumulative distribution function.
JAX implementation of :obj:`scipy.stats.beta` ``logcdf``.
The cdf is defined as
.. math::
f_{cdf}(x, a, b) = \int_{-\infty}^x f_{pdf}(y, a, ... | Beta log cumulative distribution function.
JAX implementation of :obj:`scipy.stats.beta` ``logcdf``.
The cdf is defined as
.. math::
f_{cdf}(x, a, b) = \int_{-\infty}^x f_{pdf}(y, a, b)\mathrm{d}y
where :math:`f_{pdf}` is the beta distribution probability density function,
:func:`jax.scipy.stats.bet... | logcdf | python | jax-ml/jax | jax/_src/scipy/stats/beta.py | https://github.com/jax-ml/jax/blob/master/jax/_src/scipy/stats/beta.py | Apache-2.0 |
def sf(x: ArrayLike, a: ArrayLike, b: ArrayLike,
loc: ArrayLike = 0, scale: ArrayLike = 1) -> Array:
r"""Beta distribution survival function.
JAX implementation of :obj:`scipy.stats.beta` ``sf``.
The survival function is defined as
.. math::
f_{sf}(x, a, b) = 1 - f_{cdf}(x, a, b)
where :math:... | Beta distribution survival function.
JAX implementation of :obj:`scipy.stats.beta` ``sf``.
The survival function is defined as
.. math::
f_{sf}(x, a, b) = 1 - f_{cdf}(x, a, b)
where :math:`f_{cdf}(x, a, b)` is the beta cumulative distribution function,
:func:`jax.scipy.stats.beta.cdf`.
Args:
... | sf | python | jax-ml/jax | jax/_src/scipy/stats/beta.py | https://github.com/jax-ml/jax/blob/master/jax/_src/scipy/stats/beta.py | Apache-2.0 |
def logsf(x: ArrayLike, a: ArrayLike, b: ArrayLike,
loc: ArrayLike = 0, scale: ArrayLike = 1) -> Array:
r"""Beta distribution log survival function.
JAX implementation of :obj:`scipy.stats.beta` ``logsf``.
The survival function is defined as
.. math::
f_{sf}(x, a, b) = 1 - f_{cdf}(x, a, b)
... | Beta distribution log survival function.
JAX implementation of :obj:`scipy.stats.beta` ``logsf``.
The survival function is defined as
.. math::
f_{sf}(x, a, b) = 1 - f_{cdf}(x, a, b)
where :math:`f_{cdf}(x, a, b)` is the beta cumulative distribution function,
:func:`jax.scipy.stats.beta.cdf`.
Arg... | logsf | python | jax-ml/jax | jax/_src/scipy/stats/beta.py | https://github.com/jax-ml/jax/blob/master/jax/_src/scipy/stats/beta.py | Apache-2.0 |
def logpmf(k: ArrayLike, n: ArrayLike, a: ArrayLike, b: ArrayLike,
loc: ArrayLike = 0) -> Array:
r"""Beta-binomial log probability mass function.
JAX implementation of :obj:`scipy.stats.betabinom` ``logpmf``
The beta-binomial distribution's probability mass function is defined as
.. math::
f... | Beta-binomial log probability mass function.
JAX implementation of :obj:`scipy.stats.betabinom` ``logpmf``
The beta-binomial distribution's probability mass function is defined as
.. math::
f(k, n, a, b) = {n \choose k}\frac{B(k+a,n-k-b)}{B(a,b)}
where :math:`B(a, b)` is the :func:`~jax.scipy.special.... | logpmf | python | jax-ml/jax | jax/_src/scipy/stats/betabinom.py | https://github.com/jax-ml/jax/blob/master/jax/_src/scipy/stats/betabinom.py | Apache-2.0 |
def pmf(k: ArrayLike, n: ArrayLike, a: ArrayLike, b: ArrayLike,
loc: ArrayLike = 0) -> Array:
r"""Beta-binomial probability mass function.
JAX implementation of :obj:`scipy.stats.betabinom` ``pmf``.
The beta-binomial distribution's probability mass function is defined as
.. math::
f(k, n, a, b)... | Beta-binomial probability mass function.
JAX implementation of :obj:`scipy.stats.betabinom` ``pmf``.
The beta-binomial distribution's probability mass function is defined as
.. math::
f(k, n, a, b) = {n \choose k}\frac{B(k+a,n-k-b)}{B(a,b)}
where :math:`B(a, b)` is the :func:`~jax.scipy.special.beta` ... | pmf | python | jax-ml/jax | jax/_src/scipy/stats/betabinom.py | https://github.com/jax-ml/jax/blob/master/jax/_src/scipy/stats/betabinom.py | Apache-2.0 |
def logpmf(k: ArrayLike, n: ArrayLike, p: ArrayLike, loc: ArrayLike = 0) -> Array:
r"""Binomial log probability mass function.
JAX implementation of :obj:`scipy.stats.binom` ``logpmf``.
The binomial probability mass function is defined as
.. math::
f(k, n, p) = {n \choose k}p^k(1-p)^{n-k}
for :math:... | Binomial log probability mass function.
JAX implementation of :obj:`scipy.stats.binom` ``logpmf``.
The binomial probability mass function is defined as
.. math::
f(k, n, p) = {n \choose k}p^k(1-p)^{n-k}
for :math:`0\le p\le 1` and non-negative integers :math:`k`.
Args:
k: arraylike, value at wh... | logpmf | python | jax-ml/jax | jax/_src/scipy/stats/binom.py | https://github.com/jax-ml/jax/blob/master/jax/_src/scipy/stats/binom.py | Apache-2.0 |
def logpdf(x: ArrayLike, loc: ArrayLike = 0, scale: ArrayLike = 1) -> Array:
r"""Cauchy log probability distribution function.
JAX implementation of :obj:`scipy.stats.cauchy` ``logpdf``.
The Cauchy probability distribution function is
.. math::
f(x) = \frac{1}{\pi(1 + x^2)}
Args:
x: arraylike, v... | Cauchy log probability distribution function.
JAX implementation of :obj:`scipy.stats.cauchy` ``logpdf``.
The Cauchy probability distribution function is
.. math::
f(x) = \frac{1}{\pi(1 + x^2)}
Args:
x: arraylike, value at which to evaluate the PDF
loc: arraylike, distribution offset parameter... | logpdf | python | jax-ml/jax | jax/_src/scipy/stats/cauchy.py | https://github.com/jax-ml/jax/blob/master/jax/_src/scipy/stats/cauchy.py | Apache-2.0 |
def cdf(x: ArrayLike, loc: ArrayLike = 0, scale: ArrayLike = 1) -> Array:
r"""Cauchy cumulative distribution function.
JAX implementation of :obj:`scipy.stats.cauchy` ``cdf``.
The cdf is defined as
.. math::
f_{cdf} = \int_{-\infty}^x f_{pdf}(y) \mathrm{d}y
where here :math:`f_{pdf}` is the Cauchy p... | Cauchy cumulative distribution function.
JAX implementation of :obj:`scipy.stats.cauchy` ``cdf``.
The cdf is defined as
.. math::
f_{cdf} = \int_{-\infty}^x f_{pdf}(y) \mathrm{d}y
where here :math:`f_{pdf}` is the Cauchy probability distribution function,
:func:`jax.scipy.stats.cauchy.pdf`.
Args:... | cdf | python | jax-ml/jax | jax/_src/scipy/stats/cauchy.py | https://github.com/jax-ml/jax/blob/master/jax/_src/scipy/stats/cauchy.py | Apache-2.0 |
def sf(x: ArrayLike, loc: ArrayLike = 0, scale: ArrayLike = 1) -> Array:
r"""Cauchy distribution log survival function.
JAX implementation of :obj:`scipy.stats.cauchy` ``sf``.
The survival function is defined as
.. math::
f_{sf}(x) = 1 - f_{cdf}(x)
where :math:`f_{cdf}(x)` is the cumulative distribu... | Cauchy distribution log survival function.
JAX implementation of :obj:`scipy.stats.cauchy` ``sf``.
The survival function is defined as
.. math::
f_{sf}(x) = 1 - f_{cdf}(x)
where :math:`f_{cdf}(x)` is the cumulative distribution function,
:func:`jax.scipy.stats.cauchy.cdf`.
Args:
x: arraylike,... | sf | python | jax-ml/jax | jax/_src/scipy/stats/cauchy.py | https://github.com/jax-ml/jax/blob/master/jax/_src/scipy/stats/cauchy.py | Apache-2.0 |
def logsf(x: ArrayLike, loc: ArrayLike = 0, scale: ArrayLike = 1) -> Array:
r"""Cauchy distribution log survival function.
JAX implementation of :obj:`scipy.stats.cauchy` ``logsf``
The survival function is defined as
.. math::
f_{sf}(x) = 1 - f_{cdf}(x)
where :math:`f_{cdf}(x)` is the cumulative dis... | Cauchy distribution log survival function.
JAX implementation of :obj:`scipy.stats.cauchy` ``logsf``
The survival function is defined as
.. math::
f_{sf}(x) = 1 - f_{cdf}(x)
where :math:`f_{cdf}(x)` is the cumulative distribution function,
:func:`jax.scipy.stats.cauchy.cdf`.
Args:
x: arraylik... | logsf | python | jax-ml/jax | jax/_src/scipy/stats/cauchy.py | https://github.com/jax-ml/jax/blob/master/jax/_src/scipy/stats/cauchy.py | Apache-2.0 |
def isf(q: ArrayLike, loc: ArrayLike = 0, scale: ArrayLike = 1) -> Array:
r"""Cauchy distribution inverse survival function.
JAX implementation of :obj:`scipy.stats.cauchy` ``isf``.
Returns the inverse of the survival function,
:func:`jax.scipy.stats.cauchy.sf`.
Args:
q: arraylike, value at which to ev... | Cauchy distribution inverse survival function.
JAX implementation of :obj:`scipy.stats.cauchy` ``isf``.
Returns the inverse of the survival function,
:func:`jax.scipy.stats.cauchy.sf`.
Args:
q: arraylike, value at which to evaluate the ISF
loc: arraylike, distribution offset parameter
scale: arra... | isf | python | jax-ml/jax | jax/_src/scipy/stats/cauchy.py | https://github.com/jax-ml/jax/blob/master/jax/_src/scipy/stats/cauchy.py | Apache-2.0 |
def ppf(q: ArrayLike, loc: ArrayLike = 0, scale: ArrayLike = 1) -> Array:
r"""Cauchy distribution percent point function.
JAX implementation of :obj:`scipy.stats.cauchy` ``ppf``.
The percent point function is defined as the inverse of the
cumulative distribution function, :func:`jax.scipy.stats.cauchy.cdf`.
... | Cauchy distribution percent point function.
JAX implementation of :obj:`scipy.stats.cauchy` ``ppf``.
The percent point function is defined as the inverse of the
cumulative distribution function, :func:`jax.scipy.stats.cauchy.cdf`.
Args:
q: arraylike, value at which to evaluate the PPF
loc: arraylike,... | ppf | python | jax-ml/jax | jax/_src/scipy/stats/cauchy.py | https://github.com/jax-ml/jax/blob/master/jax/_src/scipy/stats/cauchy.py | Apache-2.0 |
def logpdf(x: ArrayLike, df: ArrayLike, loc: ArrayLike = 0, scale: ArrayLike = 1) -> Array:
r"""Chi-square log probability distribution function.
JAX implementation of :obj:`scipy.stats.chi2` ``logpdf``.
The chi-square probability distribution function is given by:
.. math::
f(x, k) = \begin{cases}
... | Chi-square log probability distribution function.
JAX implementation of :obj:`scipy.stats.chi2` ``logpdf``.
The chi-square probability distribution function is given by:
.. math::
f(x, k) = \begin{cases}
\frac{x^{k/2-1}e^{-x/2}}{2^{k/2}\Gamma(k/2)} & x \ge 0 \\
0 & \mathrm{otherwise}
\... | logpdf | python | jax-ml/jax | jax/_src/scipy/stats/chi2.py | https://github.com/jax-ml/jax/blob/master/jax/_src/scipy/stats/chi2.py | Apache-2.0 |
def cdf(x: ArrayLike, df: ArrayLike, loc: ArrayLike = 0, scale: ArrayLike = 1) -> Array:
r"""Chi-square cumulative distribution function.
JAX implementation of :obj:`scipy.stats.chi2` ``cdf``.
The cdf is defined as
.. math::
f_{cdf}(x, k) = \int_{-\infty}^x f_{pdf}(y, k)\mathrm{d}y
where :math:`f_{p... | Chi-square cumulative distribution function.
JAX implementation of :obj:`scipy.stats.chi2` ``cdf``.
The cdf is defined as
.. math::
f_{cdf}(x, k) = \int_{-\infty}^x f_{pdf}(y, k)\mathrm{d}y
where :math:`f_{pdf}` is the probability density function,
:func:`jax.scipy.stats.chi2.pdf`. JAX follows the s... | cdf | python | jax-ml/jax | jax/_src/scipy/stats/chi2.py | https://github.com/jax-ml/jax/blob/master/jax/_src/scipy/stats/chi2.py | Apache-2.0 |
def sf(x: ArrayLike, df: ArrayLike, loc: ArrayLike = 0, scale: ArrayLike = 1) -> Array:
r"""Chi-square survival function.
JAX implementation of :obj:`scipy.stats.chi2` ``sf``.
The survival function is defined as
.. math::
f_{sf}(x, k) = 1 - f_{cdf}(x, k)
where :math:`f_{cdf}(x, k)` is the cumulative... | Chi-square survival function.
JAX implementation of :obj:`scipy.stats.chi2` ``sf``.
The survival function is defined as
.. math::
f_{sf}(x, k) = 1 - f_{cdf}(x, k)
where :math:`f_{cdf}(x, k)` is the cumulative distribution function,
:func:`jax.scipy.stats.chi2.cdf`. JAX follows the scipy
convention... | sf | python | jax-ml/jax | jax/_src/scipy/stats/chi2.py | https://github.com/jax-ml/jax/blob/master/jax/_src/scipy/stats/chi2.py | Apache-2.0 |
def logpdf(x: ArrayLike, loc: ArrayLike = 0, scale: ArrayLike = 1) -> Array:
r"""Exponential log probability distribution function.
JAX implementation of :obj:`scipy.stats.expon` ``logpdf``.
The Exponential probability distribution function is
.. math::
f(x) = \begin{cases}
e^{-x} & x \ge 0 \\
... | Exponential log probability distribution function.
JAX implementation of :obj:`scipy.stats.expon` ``logpdf``.
The Exponential probability distribution function is
.. math::
f(x) = \begin{cases}
e^{-x} & x \ge 0 \\
0 & \mathrm{otherwise}
\end{cases}
Args:
x: arraylike, value at w... | logpdf | python | jax-ml/jax | jax/_src/scipy/stats/expon.py | https://github.com/jax-ml/jax/blob/master/jax/_src/scipy/stats/expon.py | Apache-2.0 |
def cdf(x: ArrayLike, loc: ArrayLike = 0, scale: ArrayLike = 1) -> Array:
r"""Exponential cumulative density function.
JAX implementation of :obj:`scipy.stats.expon` ``cdf``.
The cdf is defined as
.. math::
f_{cdf}(x) = \int_{-\infty}^x f_{pdf}(y)\mathrm{d}y
where :math:`f_{pdf}` is the exponential ... | Exponential cumulative density function.
JAX implementation of :obj:`scipy.stats.expon` ``cdf``.
The cdf is defined as
.. math::
f_{cdf}(x) = \int_{-\infty}^x f_{pdf}(y)\mathrm{d}y
where :math:`f_{pdf}` is the exponential distribution probability density function,
:func:`jax.scipy.stats.expon.pdf`.
... | cdf | python | jax-ml/jax | jax/_src/scipy/stats/expon.py | https://github.com/jax-ml/jax/blob/master/jax/_src/scipy/stats/expon.py | Apache-2.0 |
def logsf(x: ArrayLike, loc: ArrayLike = 0, scale: ArrayLike = 1) -> Array:
r"""Exponential log survival function.
JAX implementation of :obj:`scipy.stats.expon` ``logsf``.
The survival function is defined as
.. math::
f_{sf}(x) = 1 - f_{cdf}(x)
where :math:`f_{cdf}(x)` is the exponential cumulative... | Exponential log survival function.
JAX implementation of :obj:`scipy.stats.expon` ``logsf``.
The survival function is defined as
.. math::
f_{sf}(x) = 1 - f_{cdf}(x)
where :math:`f_{cdf}(x)` is the exponential cumulative distribution function,
:func:`jax.scipy.stats.expon.cdf`.
Args:
x: array... | logsf | python | jax-ml/jax | jax/_src/scipy/stats/expon.py | https://github.com/jax-ml/jax/blob/master/jax/_src/scipy/stats/expon.py | Apache-2.0 |
def ppf(q: ArrayLike, loc: ArrayLike = 0, scale: ArrayLike = 1) -> Array:
r"""Exponential survival function.
JAX implementation of :obj:`scipy.stats.expon` ``ppf``.
The percent point function is defined as the inverse of the
cumulative distribution function, :func:`jax.scipy.stats.expon.cdf`.
Args:
x: ... | Exponential survival function.
JAX implementation of :obj:`scipy.stats.expon` ``ppf``.
The percent point function is defined as the inverse of the
cumulative distribution function, :func:`jax.scipy.stats.expon.cdf`.
Args:
x: arraylike, value at which to evaluate the PDF
loc: arraylike, distribution o... | ppf | python | jax-ml/jax | jax/_src/scipy/stats/expon.py | https://github.com/jax-ml/jax/blob/master/jax/_src/scipy/stats/expon.py | Apache-2.0 |
def logpdf(x: ArrayLike, a: ArrayLike, loc: ArrayLike = 0, scale: ArrayLike = 1) -> Array:
r"""Gamma log probability distribution function.
JAX implementation of :obj:`scipy.stats.gamma` ``logpdf``.
The Gamma probability distribution is given by
.. math::
f(x, a) = \frac{1}{\Gamma(a)}x^{a-1}e^{-x}
W... | Gamma log probability distribution function.
JAX implementation of :obj:`scipy.stats.gamma` ``logpdf``.
The Gamma probability distribution is given by
.. math::
f(x, a) = \frac{1}{\Gamma(a)}x^{a-1}e^{-x}
Where :math:`\Gamma(a)` is the :func:`~jax.scipy.special.gamma` function.
It is defined for :mat... | logpdf | python | jax-ml/jax | jax/_src/scipy/stats/gamma.py | https://github.com/jax-ml/jax/blob/master/jax/_src/scipy/stats/gamma.py | Apache-2.0 |
def cdf(x: ArrayLike, a: ArrayLike, loc: ArrayLike = 0, scale: ArrayLike = 1) -> Array:
r"""Gamma cumulative distribution function.
JAX implementation of :obj:`scipy.stats.gamma` ``cdf``.
The cdf is defined as
.. math::
f_{cdf}(x, a) = \int_{-\infty}^x f_{pdf}(y, a)\mathrm{d}y
where :math:`f_{pdf}` ... | Gamma cumulative distribution function.
JAX implementation of :obj:`scipy.stats.gamma` ``cdf``.
The cdf is defined as
.. math::
f_{cdf}(x, a) = \int_{-\infty}^x f_{pdf}(y, a)\mathrm{d}y
where :math:`f_{pdf}` is the probability density function,
:func:`jax.scipy.stats.gamma.pdf`.
Args:
x: arra... | cdf | python | jax-ml/jax | jax/_src/scipy/stats/gamma.py | https://github.com/jax-ml/jax/blob/master/jax/_src/scipy/stats/gamma.py | Apache-2.0 |
def sf(x: ArrayLike, a: ArrayLike, loc: ArrayLike = 0, scale: ArrayLike = 1) -> Array:
r"""Gamma survival function.
JAX implementation of :obj:`scipy.stats.gamma` ``sf``.
The survival function is defined as
.. math::
f_{sf}(x, k) = 1 - f_{cdf}(x, k)
where :math:`f_{cdf}(x, k)` is the cumulative dist... | Gamma survival function.
JAX implementation of :obj:`scipy.stats.gamma` ``sf``.
The survival function is defined as
.. math::
f_{sf}(x, k) = 1 - f_{cdf}(x, k)
where :math:`f_{cdf}(x, k)` is the cumulative distribution function,
:func:`jax.scipy.stats.gamma.cdf`.
Args:
x: arraylike, value at w... | sf | python | jax-ml/jax | jax/_src/scipy/stats/gamma.py | https://github.com/jax-ml/jax/blob/master/jax/_src/scipy/stats/gamma.py | Apache-2.0 |
def logpdf(x: ArrayLike, beta: ArrayLike) -> Array:
r"""Generalized normal log probability distribution function.
JAX implementation of :obj:`scipy.stats.gennorm` ``logpdf``.
The generalized normal probability distribution function is defined as
.. math::
f(x, \beta) = \frac{\beta}{2\Gamma(1/\beta)}\ex... | Generalized normal log probability distribution function.
JAX implementation of :obj:`scipy.stats.gennorm` ``logpdf``.
The generalized normal probability distribution function is defined as
.. math::
f(x, \beta) = \frac{\beta}{2\Gamma(1/\beta)}\exp(-|x|^\beta)
where :math:`\Gamma` is the :func:`~jax.s... | logpdf | python | jax-ml/jax | jax/_src/scipy/stats/gennorm.py | https://github.com/jax-ml/jax/blob/master/jax/_src/scipy/stats/gennorm.py | Apache-2.0 |
def cdf(x: ArrayLike, beta: ArrayLike) -> Array:
r"""Generalized normal cumulative distribution function.
JAX implementation of :obj:`scipy.stats.gennorm` ``cdf``.
The cdf is defined as
.. math::
f_{cdf}(x, k) = \int_{-\infty}^x f_{pdf}(y, k)\mathrm{d}y
where :math:`f_{pdf}` is the probability densi... | Generalized normal cumulative distribution function.
JAX implementation of :obj:`scipy.stats.gennorm` ``cdf``.
The cdf is defined as
.. math::
f_{cdf}(x, k) = \int_{-\infty}^x f_{pdf}(y, k)\mathrm{d}y
where :math:`f_{pdf}` is the probability density function,
:func:`jax.scipy.stats.gennorm.pdf`.
... | cdf | python | jax-ml/jax | jax/_src/scipy/stats/gennorm.py | https://github.com/jax-ml/jax/blob/master/jax/_src/scipy/stats/gennorm.py | Apache-2.0 |
def logpmf(k: ArrayLike, p: ArrayLike, loc: ArrayLike = 0) -> Array:
r"""Geometric log probability mass function.
JAX implementation of :obj:`scipy.stats.geom` ``logpmf``.
The Geometric probability mass function is given by
.. math::
f(k) = (1 - p)^{k-1}p
for :math:`k\ge 1` and :math:`0 \le p \le 1`... | Geometric log probability mass function.
JAX implementation of :obj:`scipy.stats.geom` ``logpmf``.
The Geometric probability mass function is given by
.. math::
f(k) = (1 - p)^{k-1}p
for :math:`k\ge 1` and :math:`0 \le p \le 1`.
Args:
k: arraylike, value at which to evaluate the PMF
p: arra... | logpmf | python | jax-ml/jax | jax/_src/scipy/stats/geom.py | https://github.com/jax-ml/jax/blob/master/jax/_src/scipy/stats/geom.py | Apache-2.0 |
def evaluate(self, points):
"""Evaluate the Gaussian KDE on the given points."""
check_arraylike("evaluate", points)
points = self._reshape_points(points)
result = _gaussian_kernel_eval(False, self.dataset.T, self.weights[:, None],
points.T, self.inv_cov)
return re... | Evaluate the Gaussian KDE on the given points. | evaluate | python | jax-ml/jax | jax/_src/scipy/stats/kde.py | https://github.com/jax-ml/jax/blob/master/jax/_src/scipy/stats/kde.py | Apache-2.0 |
def integrate_gaussian(self, mean, cov):
"""Integrate the distribution weighted by a Gaussian."""
mean = jnp.atleast_1d(jnp.squeeze(mean))
cov = jnp.atleast_2d(cov)
if mean.shape != (self.d,):
raise ValueError(f"mean does not have dimension {self.d}")
if cov.shape != (self.d, self.d):
r... | Integrate the distribution weighted by a Gaussian. | integrate_gaussian | python | jax-ml/jax | jax/_src/scipy/stats/kde.py | https://github.com/jax-ml/jax/blob/master/jax/_src/scipy/stats/kde.py | Apache-2.0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.