[mlpack-git] master: Added Smooth and Filter functions (16e1dee)

gitdub at big.cc.gt.atl.ga.us gitdub at big.cc.gt.atl.ga.us
Thu Mar 5 22:01:53 EST 2015


Repository : https://github.com/mlpack/mlpack

On branch  : master
Link       : https://github.com/mlpack/mlpack/compare/904762495c039e345beba14c1142fd719b3bd50e...f94823c800ad6f7266995c700b1b630d5ffdcf40

>---------------------------------------------------------------

commit 16e1dee24445230b2e51985b71b94adc3fcdcab2
Author: michaelfox99 <michaelfox99 at gmail.com>
Date:   Sun Nov 2 17:45:05 2014 +0000

    Added Smooth and Filter functions


>---------------------------------------------------------------

16e1dee24445230b2e51985b71b94adc3fcdcab2
 src/mlpack/methods/hmm/hmm.hpp | 40 +++++++++++++++++++++++++++++++++++-----
 1 file changed, 35 insertions(+), 5 deletions(-)

diff --git a/src/mlpack/methods/hmm/hmm.hpp b/src/mlpack/methods/hmm/hmm.hpp
index b3a3fe9..05300be 100644
--- a/src/mlpack/methods/hmm/hmm.hpp
+++ b/src/mlpack/methods/hmm/hmm.hpp
@@ -261,6 +261,36 @@ class HMM
    */
   double LogLikelihood(const arma::mat& dataSeq) const;
 
+  /**
+   * HMM filtering. Computes the k-step-ahead expected emission at each time
+   * conditioned only on prior observations. That is
+   * E{ Y[t+k] | Y[0], ..., Y[t] }.
+   * The returned matrix has columns equal to the number of observations. Note
+   * that the expectation may not be meaningful for discrete emissions.
+   * 
+   * @param dataSeq Sequence of observations.
+   * @param filterSeq Vector in which the expected emission sequence will be
+   *    stored.
+   * @param ahead Number of steps ahead (k) for expectations.
+   */
+  void Filter(const arma::mat& dataSeq,
+              arma::mat& filterSeq,
+              size_t ahead = 0) const;
+  
+  /**
+   * HMM smoothing. Computes expected emission at each time conditioned on all
+   * observations. That is
+   * E{ Y[t] | Y[0], ..., Y[T] }.
+   * The returned matrix has columns equal to the number of observations. Note
+   * that the expectation may not be meaningful for discrete emissions.
+   *  
+   * @param dataSeq Sequence of observations.
+   * @param smoothSeq Vector in which the expected emission sequence will be
+   *    stored.
+   */
+  void Smooth(const arma::mat& dataSeq,
+              arma::mat& smoothSeq) const;
+  
   //! Return the vector of initial state probabilities.
   const arma::vec& Initial() const { return initial; }
   //! Modify the vector of initial state probabilities.
@@ -301,9 +331,8 @@ class HMM
    */
   static std::string const Type() { return "HMM"; }
 
- private:
+ protected:
   // Helper functions.
-
   /**
    * The Forward algorithm (part of the Forward-Backward algorithm).  Computes
    * forward probabilities for each state for each observation in the given data
@@ -333,15 +362,16 @@ class HMM
                 const arma::vec& scales,
                 arma::mat& backwardProb) const;
 
+  //! Set of emission probability distributions; one for each state.
+  std::vector<Distribution> emission;
+  
+ private:
   //! Initial state probability vector.
   arma::vec initial;
 
   //! Transition probability matrix.
   arma::mat transition;
 
-  //! Set of emission probability distributions; one for each state.
-  std::vector<Distribution> emission;
-
   //! Dimensionality of observations.
   size_t dimensionality;
 



More information about the mlpack-git mailing list