annotate maths/KLDivergence.h @ 136:9c16683f58eb

...
author Chris Cannam
date Mon, 21 Oct 2013 09:24:59 +0100
parents e5907ae6de17
children 701233f8ed41
rev   line source
cannam@31 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
cannam@31 2
cannam@31 3 /*
cannam@31 4 QM DSP Library
cannam@31 5
cannam@31 6 Centre for Digital Music, Queen Mary, University of London.
cannam@33 7 This file copyright 2008 QMUL.
Chris@84 8
Chris@84 9 This program is free software; you can redistribute it and/or
Chris@84 10 modify it under the terms of the GNU General Public License as
Chris@84 11 published by the Free Software Foundation; either version 2 of the
Chris@84 12 License, or (at your option) any later version. See the file
Chris@84 13 COPYING included with this distribution for more information.
cannam@31 14 */
cannam@31 15
cannam@31 16 #ifndef KLDIVERGENCE_H
cannam@31 17 #define KLDIVERGENCE_H
cannam@31 18
cannam@31 19 #include <vector>
cannam@31 20
cannam@31 21 using std::vector;
cannam@31 22
cannam@31 23 /**
cannam@33 24 * Helper methods for calculating Kullback-Leibler divergences.
cannam@31 25 */
cannam@31 26 class KLDivergence
cannam@31 27 {
cannam@31 28 public:
cannam@31 29 KLDivergence() { }
cannam@31 30 ~KLDivergence() { }
cannam@31 31
cannam@33 32 /**
cannam@33 33 * Calculate a symmetrised Kullback-Leibler divergence of Gaussian
cannam@33 34 * models based on mean and variance vectors. All input vectors
cannam@33 35 * must be of equal size.
cannam@33 36 */
cannam@33 37 double distanceGaussian(const vector<double> &means1,
cannam@33 38 const vector<double> &variances1,
cannam@33 39 const vector<double> &means2,
cannam@33 40 const vector<double> &variances2);
cannam@33 41
cannam@33 42 /**
cannam@33 43 * Calculate a Kullback-Leibler divergence of two probability
cannam@33 44 * distributions. Input vectors must be of equal size. If
cannam@33 45 * symmetrised is true, the result will be the symmetrised
cannam@33 46 * distance (equal to KL(d1, d2) + KL(d2, d1)).
cannam@33 47 */
cannam@33 48 double distanceDistribution(const vector<double> &d1,
cannam@33 49 const vector<double> &d2,
cannam@33 50 bool symmetrised);
cannam@31 51 };
cannam@31 52
cannam@31 53 #endif
cannam@31 54