Skip to main content
. 2017 Mar 21;17(3):649. doi: 10.3390/s17030649
Algorithm 2. Improved Viterbi algorithm.
Input: The proposed HMM tuples <N={ni|i=1,2,,NN}, M={mi|i=1,2,,NM}, C, π>; HAR classification results H={hi|i=1,2,,NH}; PDR distance information D={di|i=1,2,,ND}; Initial direction of magnetometer O; Initial pressure of barometer F; dσ is the distance threshold.
Output: Prediction trajectory.
1: OstartO, FstartF/* Determine the initial orientation and floor
2: for i from 1 to NM do
3: for each path pass through ni1 to ni do
4:   if ((Distance(d(ni1), d(ni)) - di)<dσ) and (P(ni)>0) then /* Determine whether the distance between two landmark nodes coincides with the distance information estimated by PDR
5:    Path(Ns, P(Ns))Obtain the subset data
6:   end if
7: end for
8: end for
9: for pathj in Path(Ns, P(Ns)) do
10: H(pathj)={hi|i=1,2,,NH}Obtain the landmark data set
11: if H(pathj) match with HAR data H then
12:   Path(Nf, P(Nf))Add this trajectory to the final trajectory data set
13: end for
14 return Max(Path(Nf, P(Nf)))/* Return the trajectory of the maximum probability