c@256: /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ c@256: /* c@256: QM DSP Library c@256: c@256: Centre for Digital Music, Queen Mary, University of London. c@258: This file copyright 2008 QMUL. c@309: c@309: This program is free software; you can redistribute it and/or c@309: modify it under the terms of the GNU General Public License as c@309: published by the Free Software Foundation; either version 2 of the c@309: License, or (at your option) any later version. See the file c@309: COPYING included with this distribution for more information. c@256: */ c@256: cannam@489: #ifndef QM_DSP_KLDIVERGENCE_H cannam@489: #define QM_DSP_KLDIVERGENCE_H c@256: c@256: #include c@256: c@256: /** c@258: * Helper methods for calculating Kullback-Leibler divergences. c@256: */ c@256: class KLDivergence c@256: { c@256: public: c@256: KLDivergence() { } c@256: ~KLDivergence() { } c@256: c@258: /** c@258: * Calculate a symmetrised Kullback-Leibler divergence of Gaussian c@258: * models based on mean and variance vectors. All input vectors c@258: * must be of equal size. c@258: */ cannam@493: double distanceGaussian(const std::vector &means1, cannam@493: const std::vector &variances1, cannam@493: const std::vector &means2, cannam@493: const std::vector &variances2); c@258: c@258: /** c@258: * Calculate a Kullback-Leibler divergence of two probability c@258: * distributions. Input vectors must be of equal size. If c@258: * symmetrised is true, the result will be the symmetrised c@258: * distance (equal to KL(d1, d2) + KL(d2, d1)). c@258: */ cannam@493: double distanceDistribution(const std::vector &d1, cannam@493: const std::vector &d2, c@258: bool symmetrised); c@256: }; c@256: c@256: #endif c@256: