brainmass.objectives.ks_distance#
- brainmass.objectives.ks_distance(p, q)[source]#
Kolmogorov-Smirnov statistic between two 1-D densities / histograms.
Each cumulative sum is normalised to a proper CDF before the supremum is taken, so the result lies in
[0, 1]independent of bin width and is directly comparable toscipy.stats.ks_2samp().\[D = \sup_x \left| F_p(x) - F_q(x) \right|.\]- Parameters:
p (array) – Densities or (unnormalised) histograms on a shared, ordered grid.
q (array) – Densities or (unnormalised) histograms on a shared, ordered grid.
- Returns:
Scalar KS statistic in
[0, 1].- Return type:
jax.Array
Notes
The supremum (
max) makes this non-smooth: its gradient is the indicator at the argmax, so preferwasserstein_1d()(andfcd_wasserstein()) when the distance is a fitting loss. Use KS for evaluation / reporting, where literature comparability matters.See also
wasserstein_1dsmooth, gradient-friendly distributional distance.