KL divergence in R using base 2 logarithm
I want to find JS divergence of two distributions in R. wikipedia says that Jensen–Shannon divergence is bounded by 1, given that one uses the base 2 logarithm. I want that my resulting JS divergence lies between 0 and 1. I am using KLdiv function in R to find JS:
where Kullback–Leibler divergence KLdiv(P,M) = D(P || M)
But I want to specify that I need base 2 logarithm. Looks like KLdiv does not allow me to specify which log I want to use. Any clue as to how to do that?
Ok this is the R code for finding JSdivergence between 2 distributions ..
I want a JS value between 0 and 1 which as per wiki is possible only if I take base 2 logarithm. How can I do this with my exisiting R code