annotate maths/KLDivergence.h @ 73:dcb555b90924

* Key detector: when returning key strengths, use the peak value of the three underlying chromagram correlations (from 36-bin chromagram) corresponding to each key, instead of the mean. Rationale: This is the same method as used when returning the key value, and it's nice to have the same results in both returned value and plot. The peak performed better than the sum with a simple test set of triads, so it seems reasonable to change the plot to match the key output rather than the other way around. * FFT: kiss_fftr returns only the non-conjugate bins, synthesise the rest rather than leaving them (perhaps dangerously) undefined. Fixes an uninitialised data error in chromagram that could cause garbage results from key detector. * Constant Q: remove precalculated values again, I reckon they're not proving such a good tradeoff.
author cannam
date Fri, 05 Jun 2009 15:12:39 +0000
parents 499d438b52ba
children e5907ae6de17
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.
cannam@31 8 All rights reserved.
cannam@31 9 */
cannam@31 10
cannam@31 11 #ifndef KLDIVERGENCE_H
cannam@31 12 #define KLDIVERGENCE_H
cannam@31 13
cannam@31 14 #include <vector>
cannam@31 15
cannam@31 16 using std::vector;
cannam@31 17
cannam@31 18 /**
cannam@33 19 * Helper methods for calculating Kullback-Leibler divergences.
cannam@31 20 */
cannam@31 21 class KLDivergence
cannam@31 22 {
cannam@31 23 public:
cannam@31 24 KLDivergence() { }
cannam@31 25 ~KLDivergence() { }
cannam@31 26
cannam@33 27 /**
cannam@33 28 * Calculate a symmetrised Kullback-Leibler divergence of Gaussian
cannam@33 29 * models based on mean and variance vectors. All input vectors
cannam@33 30 * must be of equal size.
cannam@33 31 */
cannam@33 32 double distanceGaussian(const vector<double> &means1,
cannam@33 33 const vector<double> &variances1,
cannam@33 34 const vector<double> &means2,
cannam@33 35 const vector<double> &variances2);
cannam@33 36
cannam@33 37 /**
cannam@33 38 * Calculate a Kullback-Leibler divergence of two probability
cannam@33 39 * distributions. Input vectors must be of equal size. If
cannam@33 40 * symmetrised is true, the result will be the symmetrised
cannam@33 41 * distance (equal to KL(d1, d2) + KL(d2, d1)).
cannam@33 42 */
cannam@33 43 double distanceDistribution(const vector<double> &d1,
cannam@33 44 const vector<double> &d2,
cannam@33 45 bool symmetrised);
cannam@31 46 };
cannam@31 47
cannam@31 48 #endif
cannam@31 49