Function to calculate KL divergence for continuous distributions using histograms
Arguments
- P
Numeric vector representing the empirical distribution
- Q
Numeric vector representing the theoretical distribution
Value
KL divergence between P and Q
Examples
P <- c(0.2, 0.3, 0.5)
Q <- c(0.1, 0.4, 0.5)
misc::KL_divergence_hist(P, Q)
#> [1] 0.05232481