Participer au site avec un Tip
Rechercher
 

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 :

Vous êtes un professionnel et vous avez besoin d'une formation ? Deep Learning avec Python
et Keras et Tensorflow
Voir le programme détaillé
Module « scipy.special »

Fonction stirling2 - module scipy.special

Signature de la fonction stirling2

def stirling2(N, K, *, exact=False) 

Description

help(scipy.special.stirling2)

Generate Stirling number(s) of the second kind.

Stirling numbers of the second kind count the number of ways to
partition a set with N elements into K non-empty subsets.

The values this function returns are calculated using a dynamic
program which avoids redundant computation across the subproblems
in the solution. For array-like input, this implementation also
avoids redundant computation across the different Stirling number
calculations.

The numbers are sometimes denoted

.. math::

    {N \brace{K}}

see [1]_ for details. This is often expressed-verbally-as
"N subset K".

Parameters
----------
N : int, ndarray
    Number of things.
K : int, ndarray
    Number of non-empty subsets taken.
exact : bool, optional
    Uses dynamic programming (DP) with floating point
    numbers for smaller arrays and uses a second order approximation due to
    Temme for larger entries  of `N` and `K` that allows trading speed for
    accuracy. See [2]_ for a description. Temme approximation is used for
    values ``n>50``. The max error from the DP has max relative error
    ``4.5*10^-16`` for ``n<=50`` and the max error from the Temme approximation
    has max relative error ``5*10^-5`` for ``51 <= n < 70`` and
    ``9*10^-6`` for ``70 <= n < 101``. Note that these max relative errors will
    decrease further as `n` increases.

Returns
-------
val : int, float, ndarray
    The number of partitions.

See Also
--------
comb : The number of combinations of N things taken k at a time.

Notes
-----
- If N < 0, or K < 0, then 0 is returned.
- If K > N, then 0 is returned.

The output type will always be `int` or ndarray of `object`.
The input must contain either numpy or python integers otherwise a
TypeError is raised.

References
----------
.. [1] R. L. Graham, D. E. Knuth and O. Patashnik, "Concrete
    Mathematics: A Foundation for Computer Science," Addison-Wesley
    Publishing Company, Boston, 1989. Chapter 6, page 258.

.. [2] Temme, Nico M. "Asymptotic estimates of Stirling numbers."
    Studies in Applied Mathematics 89.3 (1993): 233-243.

Examples
--------
>>> import numpy as np
>>> from scipy.special import stirling2
>>> k = np.array([3, -1, 3])
>>> n = np.array([10, 10, 9])
>>> stirling2(n, k)
array([9330.0, 0.0, 3025.0])



Vous êtes un professionnel et vous avez besoin d'une formation ? Machine Learning
avec Scikit-Learn
Voir le programme détaillé