Repository: scipy/scipy
File: scipy/special/_add_newdocs.py (Python)

Code before:
    >>> ax.set_xlabel(r"$x$")
    >>> ax.set_ylabel(r"$P_\nu^1(x)$")
    >>> plt.show()

    Order 2.

    >>> fig, ax = plt.subplots()
    >>> ax.plot(xs, lpmv(2, nus, xs[:, np.newaxis]), "-")
    >>> ax.legend([rf"$\nu={nu}$" for nu in nus])
    >>> ax.set_xlabel(r"$x$")
    >>> ax.set_ylabel(r"$P_\nu^2(x)$")
    >>> plt.show()
    """)

add_newdoc("nbdtr",
    r"""
    nbdtr(k, n, p, out=None)

    Negative binomial cumulative distribution function.

    Returns the sum of the terms 0 through `k` of the negative binomial
    distribution probability mass function,

    .. math::

        F(p) = \sum_{j=0}^k {{n + j - 1}\choose{j}} p^n (1 - p)^j.

    In a sequence of Bernoulli trials with individual success probabilities
    `p`, this is the probability that `k` or fewer failures precede the nth
    success.

    Parameters
    ----------
    k : array_like
        The maximum number of allowed failures (nonnegative int).
    n : array_like
        The target number of successes (positive int).
    p : array_like
        Probability of success in a single event (float).
    out : ndarray, optional
        Optional output array for the function results

    Returns
    -------
    scalar or ndarray
        The probability of `k` or fewer failures before `n` successes in a
        sequence of events with individual success probability `p`.

    See Also
    --------
    nbdtrc : Negative binomial survival function

Review comment (suggestion):
The primary argument should be `k`: `F(k) = ...`. Alternatively, include `k` and the distribution parameters as `F(k, n, p) = ...` or `F(k; n, p) = ...`.  (And likewise for `S` in the `nbdtrc` docstring.)

Code after:
    >>> ax.set_xlabel(r"$x$")
    >>> ax.set_ylabel(r"$P_\nu^1(x)$")
    >>> plt.show()

    Order 2.

    >>> fig, ax = plt.subplots()
    >>> ax.plot(xs, lpmv(2, nus, xs[:, np.newaxis]), "-")
    >>> ax.legend([rf"$\nu={nu}$" for nu in nus])
    >>> ax.set_xlabel(r"$x$")
    >>> ax.set_ylabel(r"$P_\nu^2(x)$")
    >>> plt.show()
    """)

add_newdoc("nbdtr",
    r"""
    nbdtr(k, n, p, out=None)

    Negative binomial cumulative distribution function.

    Returns the sum of the terms 0 through `k` of the negative binomial
    distribution probability mass function,

    .. math::

        F(k) = \sum_{j=0}^k {{n + j - 1}\choose{j}} p^n (1 - p)^j.

    In a sequence of Bernoulli trials with individual success probabilities
    `p`, this is the probability that `k` or fewer failures precede the nth
    success.

    Parameters
    ----------
    k : array_like
        The maximum number of allowed failures (nonnegative int).
    n : array_like
        The target number of successes (positive int).
    p : array_like
        Probability of success in a single event (float).
    out : ndarray, optional
        Optional output array for the function results

    Returns
    -------
    scalar or ndarray
        The probability of `k` or fewer failures before `n` successes in a
        sequence of events with individual success probability `p`.

    See Also
    --------
    nbdtrc : Negative binomial survival function