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