Statistical Methods
Compare Category Compositions with Jensen–Shannon Distance
Define the task
Use a composition distance when the practical question concerns relative category frequencies rather than total sample volume. Align category definitions and order across both inputs, inserting genuine zero counts where appropriate. The tool normalizes each nonnegative vector separately and uses base-two logarithms. It reports both Jensen–Shannon divergence and its square root, the distance. Neither quantity is a hypothesis test or an adjustment for unequal sampling uncertainty.
Carry out the check
After normalization, form the midpoint distribution m=(p+q)/2. Average the two relative entropies to m, treating a zero probability contribution as zero. Take the square root for the distance. With base two, both reported quantities lie between zero and one. A vector whose total is zero is invalid because no composition can be defined. This comparison ignores distances between categories; adjacent age bands and distant bands are simply distinct categories unless a different method is selected.
Worked hypothetical example
For hypothetical p=(1,0) and q=(0,1), the midpoint is (0.5,0.5), divergence is one bit and distance is one. Identical normalized compositions have distance zero, even if counts are (2,2) versus (200,200). That equality does not establish equal precision or equal populations. Record denominators separately and avoid interpreting a descriptive distance as clinical importance. Confirm that missing or unclassified records were handled consistently before comparing compositions.
Method checked 19 November 2026 against Primary method documentation: jensenshannon.