gmm.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /*
  2. * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
  3. *
  4. * Use of this source code is governed by a BSD-style license
  5. * that can be found in the LICENSE file in the root of the source
  6. * tree. An additional intellectual property rights grant can be found
  7. * in the file PATENTS. All contributing project authors may
  8. * be found in the AUTHORS file in the root of the source tree.
  9. */
  10. #ifndef MODULES_AUDIO_PROCESSING_VAD_GMM_H_
  11. #define MODULES_AUDIO_PROCESSING_VAD_GMM_H_
  12. namespace webrtc {
  13. // A structure that specifies a GMM.
  14. // A GMM is formulated as
  15. // f(x) = w[0] * mixture[0] + w[1] * mixture[1] + ... +
  16. // w[num_mixtures - 1] * mixture[num_mixtures - 1];
  17. // Where a 'mixture' is a Gaussian density.
  18. struct GmmParameters {
  19. // weight[n] = log(w[n]) - |dimension|/2 * log(2*pi) - 1/2 * log(det(cov[n]));
  20. // where cov[n] is the covariance matrix of mixture n;
  21. const double* weight;
  22. // pointer to the first element of a |num_mixtures|x|dimension| matrix
  23. // where kth row is the mean of the kth mixture.
  24. const double* mean;
  25. // pointer to the first element of a |num_mixtures|x|dimension|x|dimension|
  26. // 3D-matrix, where the kth 2D-matrix is the inverse of the covariance
  27. // matrix of the kth mixture.
  28. const double* covar_inverse;
  29. // Dimensionality of the mixtures.
  30. int dimension;
  31. // number of the mixtures.
  32. int num_mixtures;
  33. };
  34. // Evaluate the given GMM, according to |gmm_parameters|, at the given point
  35. // |x|. If the dimensionality of the given GMM is larger that the maximum
  36. // acceptable dimension by the following function -1 is returned.
  37. double EvaluateGmm(const double* x, const GmmParameters& gmm_parameters);
  38. } // namespace webrtc
  39. #endif // MODULES_AUDIO_PROCESSING_VAD_GMM_H_