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 ? RAG (Retrieval-Augmented Generation)
et Fine Tuning d'un LLM
Voir le programme détaillé
Module « scipy.special »

Fonction rel_entr - module scipy.special

Signature de la fonction rel_entr

def rel_entr(*args, **kwargs) 

Description

help(scipy.special.rel_entr)

rel_entr(x1, x2, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature])

rel_entr(x, y, out=None)

Elementwise function for computing relative entropy.

.. math::

    \mathrm{rel\_entr}(x, y) =
        \begin{cases}
            x \log(x / y) & x > 0, y > 0 \\
            0 & x = 0, y \ge 0 \\
            \infty & \text{otherwise}
        \end{cases}

Parameters
----------
x, y : array_like
    Input arrays
out : ndarray, optional
    Optional output array for the function results

Returns
-------
scalar or ndarray
    Relative entropy of the inputs

See Also
--------
entr, kl_div, scipy.stats.entropy

Notes
-----
.. versionadded:: 0.15.0

This function is jointly convex in x and y.

The origin of this function is in convex programming; see
[1]_. Given two discrete probability distributions :math:`p_1,
\ldots, p_n` and :math:`q_1, \ldots, q_n`, the definition of relative
entropy in the context of *information theory* is

.. math::

    \sum_{i = 1}^n \mathrm{rel\_entr}(p_i, q_i).

To compute the latter quantity, use `scipy.stats.entropy`.

See [2]_ for details.

References
----------
.. [1] Boyd, Stephen and Lieven Vandenberghe. *Convex optimization*.
       Cambridge University Press, 2004.
       :doi:`https://doi.org/10.1017/CBO9780511804441`
.. [2] Kullback-Leibler divergence,
       https://en.wikipedia.org/wiki/Kullback%E2%80%93Leibler_divergence


Vous êtes un professionnel et vous avez besoin d'une formation ? Coder avec une
Intelligence Artificielle
Voir le programme détaillé