ELI5: Explain Like I'm 5

Jensen–Shannon divergence

Imagine you have two bags of candy. The first bag, called Bag A, has 5 chocolates and 5 gummy bears. The second bag, called Bag B, has 6 chocolates and 4 gummy bears.

To measure how different the two bags are from each other, we can use something called the Jensen-Shannon divergence. It's like a scale that tells you how far apart the two bags are from each other.

First, we need to find the probability of getting each type of candy from each bag. Probability is a way of saying how likely it is that you'll get a certain candy. We divide the number of chocolates or gummy bears by the total number of candies in each bag.

In Bag A, the probability of getting a chocolate is 5/10 or 0.5. The probability of getting a gummy bear is also 0.5.

In Bag B, the probability of getting a chocolate is 6/10 or 0.6. The probability of getting a gummy bear is 0.4.

Next, we use these probabilities to calculate something called the Shannon entropy. Entropy is like a measure of uncertainty. The more evenly distributed the probabilities are, the higher the entropy. The formula for calculating entropy looks scary, but it's really just a bunch of multiplication and addition.

In Bag A, the entropy is:

-(0.5 * log2(0.5)) - (0.5 * log2(0.5)) = 1

In Bag B, the entropy is:

-(0.6 * log2(0.6)) - (0.4 * log2(0.4)) = 0.971

Now we use the entropy values to calculate the Jensen-Shannon divergence. We add the entropy values together, divide by 2, and then subtract the entropy of the average of the two bags. This gives us a number between 0 and 1 that tells us how different the two bags are.

The Jensen-Shannon divergence between Bag A and Bag B is:

(1 + 0.971) / 2 - [(1 + 0.971) / 2 + (1 + 0.971) / 2] / 2 = 0.047

This number means that Bag A and Bag B are not very different from each other. If the number was closer to 1, it would mean that the two bags are very different from each other.

So, the Jensen-Shannon divergence is a way of measuring how different two probability distributions are from each other. It's like a scale that tells you how far apart two bags of candy are from each other.