フィルターのクリア

Using the hmmestimate function

8 ビュー (過去 30 日間)
Elliot Lang
Elliot Lang 2023 年 8 月 22 日
回答済み: Shreshth 2024 年 1 月 4 日
Hello!
I am currently using Matlab in my master's thesis work and I would like to test if a hidden markov model could suit my problem at hand. I have a data set with 30 channels of observations with 6783 entries (originally from a time table from sensor data). I have a corresponding set of states, each observation of the 6783 has been labelled with a state.
My attempt at implementation was simply:
[Trans_EST, EMIS_EST] = hmmgenerate(observations, states);
I have already tried converting the input matrices into different data types but that didn't help. I consistantly get an error (Context: there are 4 different possible states)
Index in position 1 exceeds array bounds. Index must not exceed 4.
Error in hmmestimate (line 162) tr(states(count),states(count+1)) = tr(states(count),states(count+1)) + 1;
I can't figure out what I am doing wrong or how the hmmestimate function is even supposed to work when looking at the code. Any help/insight or experience with this function would be much appreciated!
  1 件のコメント
Dyuman Joshi
Dyuman Joshi 2023 年 8 月 22 日
Please attach the variables states, count and tr.

サインインしてコメントする。

回答 (1 件)

Shreshth
Shreshth 2024 年 1 月 4 日
Hello Elliot,
I understand that you are trying to apply a Hidden Markov Model (HMM) to their dataset using MATLAB but are encountering an error which indicates that an index is out of bounds, specifically that the index must not exceed 4.
It seems like you are trying to estimate the parameters of a Hidden Markov Model (HMM) using the ‘hmmestimate’ function in MATLAB, but you mentioned using ‘hmmgenerate’, which is actually used for generating sequences from a given HMM, not for parameter estimation.
The error message you are seeing suggests that the index being used to access an array in the ‘hmmestimate’ function is exceeding the maximum allowed value. This often happens when the function expects the states to be indexed from 1 to N (where N is the number of states), but the provided states are indexed differently (e.g., from 0 to N-1 or from 1 to N+1).
Here is a step-by-step guide on how to use the hmmestimate function correctly:
  1. Prepare Your Observations and States: Make sure that your observations are coded as integers from 1 to M, where M is the number of possible observation symbols. Similarly, ensure your states are coded as integers from 1 to N, where N is the number of states.
  2. Use ‘hmmestimate’: The ‘hmmestimate’ function is used to estimate the transition and emission probabilities of an HMM given a sequence of observations and the corresponding sequence of states. The correct usage is:
[TRANS_EST, EMIS_EST] = hmmestimate(seq, states)
where seq is the sequence of observations and states is the sequence of true states for the observations.
3.Check Your Data: Make sure there are no states labelled with a number higher than 4 since you mentioned there are only 4 different possible states. Also, ensure that there are no zero or negative state labels.
4.Check for Missing Data: If you have missing data in your sequences, you need to handle that appropriately before using ‘hmmestimate.’
You can also refer to the documentation by MathWorks for further reference
Thank you,
Shubham Shreshth.

カテゴリ

Help Center および File ExchangeMATLAB についてさらに検索

製品


リリース

R2023a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by