Skip to content

Commit

Permalink
Added normalization of the input values
Browse files Browse the repository at this point in the history
  • Loading branch information
jakobdanel committed Jan 19, 2024
1 parent e3626a3 commit afd3dc3
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions R/kld.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
Expand Down

0 comments on commit afd3dc3

Please sign in to comment.