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