Learn R Programming

mispitools (version 1.2.0)

klPIE: Calculate Kullback-Leibler Divergence with Base 10 Logarithm

Description

This function computes the Kullback-Leibler (KL) divergence between two probability distributions represented by matrices, using a base 10 logarithm. The function calculates KL divergence in both directions (P || Q and Q || P) and handles zero probabilities by replacing them with a minimum value to avoid undefined logarithms.

Usage

klPIE(P, Q, min_value = 1e-12)

Value

A named numeric vector with two elements:

"P || Q"

The KL divergence from P to Q (P || Q).

"Q || P"

The KL divergence from Q to P (Q || P).

Arguments

P

A numeric matrix representing the first probability distribution. The entire matrix should sum to 1.

Q

A numeric matrix representing the second probability distribution. The entire matrix should sum to 1.

min_value

A numeric value representing the minimum value to replace any zero probabilities. Defaults to 1e-12.