Calculator: Jensen–Shannon divergence

Enter the labelled inputs to calculate: Entropy (bit); Distance √JSD.

Entropy (bit)
0.0487949407
Distance √JSD
0.2208957688

How the calculation works

M=(P+Q)/2; JSD=½DKL(P‖M)+½DKL(Q‖M)

Paired lists must have equal lengths. Variances use sample standard deviations where labelled. Probabilities must be nonnegative and sum to one; information is in bits, with zero-mass terms omitted. Pearson statistics use no continuity correction. Wilson uses the supplied normal critical value z.

Values must satisfy the formula’s domain. Nonzero results too small or too large for reliable representation are rejected.

Frequently asked questions

How is the result calculated?

M=(P+Q)/2; JSD=½DKL(P‖M)+½DKL(Q‖M)

What assumptions apply?

Paired lists must have equal lengths. Variances use sample standard deviations where labelled. Probabilities must be nonnegative and sum to one; information is in bits, with zero-mass terms omitted. Pearson statistics use no continuity correction. Wilson uses the supplied normal critical value z.

How precise are the displayed results?

Numerical results show up to ten significant digits. Rounding does not improve the accuracy of the input measurements or the model. Values must satisfy the formula’s domain. Nonzero results too small or too large for reliable representation are rejected.

How we verified this calculator

The calculator is checked against 3 reference cases computed independently of its code. Last passed: .

# Inputs Expected result
1
Values (spaces or semicolons; decimal point) P = 1 0
Values (spaces or semicolons; decimal point) Q = 0 1
Entropy (bit): 1
Distance √JSD: 1
2
Values (spaces or semicolons; decimal point) P = 0.7 0.2 0.1
Values (spaces or semicolons; decimal point) Q = 0.5 0.3 0.2
Entropy (bit): 0.03159672229
Distance √JSD: 0.1777546688
3
Values (spaces or semicolons; decimal point) P = 0.5 0.5
Values (spaces or semicolons; decimal point) Q = 0.25 0.75
Entropy (bit): 0.0487949407
Distance √JSD: 0.2208957688

How we test our calculators →

Also try:

Back to category →