From afd3dc323cb333cea8b791106002a920d0d1c68f Mon Sep 17 00:00:00 2001 From: Jakob Date: Fri, 19 Jan 2024 08:49:13 +0100 Subject: [PATCH] Added normalization of the input values --- R/kld.R | 2 ++ 1 file changed, 2 insertions(+) diff --git a/R/kld.R b/R/kld.R index 8e99f3c..243b48b 100644 --- a/R/kld.R +++ b/R/kld.R @@ -23,6 +23,8 @@ #' #' @export lfa_kld <- function(p, q, epsilon = 1e-10) { + p <- p / sum(p) + q <- q / sum(q) p <- p + epsilon q <- q + epsilon return(sum(p * log(p / q)))