dataFrame.columns.stat — divergence()
Description
The divergence() method of the stat object computes the divergence between the distributions represented by two selected columns.
Signature
dataFrame.columns(...columnNames).stat.divergence({ method: 'jensenShannon' })Arguments
...columnNames( string[] )- The name of the columns from which to compute divergence.
options(object)- Divergence computation options.
Option
method(string)- The divergence measure used for the computation.
jensenShannon(default)kullbackLeibler
Returns
divergence(number)- The computed divergence value.
Notes
- The method requires exactly two selected columns.
- The columns are interpreted as distributions.
- Kullback-Leibler divergence is directional and depends on the order of the selected columns.
- Jensen-Shannon divergence is symmetric and does not depend on column order.
- A divergence of
0indicates identical distributions. - Larger values indicate greater differences between distributions.
- When using Kullback-Leibler divergence, reversing the column order may produce a different result.
Example
// evaluate the divergence of the values of 2 columns of the dataFrame
var divergence = dataFrame.columns('age', 'income').stat.divergence();
// log the stat
notebook.log(divergence);