You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
`template
void HMM::Generate(const size_t length,
arma::mat& dataSequence,
arma::Row<size_t>& stateSequence,
const size_t startState) const
{
// Set vectors to the right size.
stateSequence.set_size(length);
dataSequence.set_size(dimensionality, length);
// Set start state (default is 0).
stateSequence[0] = startState;
// Choose first emission state.
double randValue = ((double)rand() / (RAND_MAX)) + 1;
// We just have to find where our random value sits in the probability
// distribution of emissions for our starting state.
dataSequence.col(0) = emission[startState].Random();
// Now choose the states and emissions for the rest of the sequence.
for (size_t t = 1; t < length; t++)
{
// First choose the hidden state.
randValue = ((double)rand() / (RAND_MAX)) + 1;
// Now find where our random value sits in the probability distribution of
// state changes.
double probSum = 0;
for (size_t st = 0; st < transition.n_rows; st++)
{
probSum += transition(st, stateSequence[t - 1]);
if (randValue <= probSum)
{
stateSequence[t] = st;
break;
}
}
// Now choose the emission.
dataSequence.col(t) = emission[stateSequence[t]].Random();
}
}`
Hi, I don't understand what the problem here is. Can you provide more information on what you were trying to do, what the problem was, what the output was, and so forth? I can't help out unless I know what the issue is.
` mat observation;//obseration matrix
Row<size_t> sequence;//label
`template
void HMM::Generate(const size_t length,
arma::mat& dataSequence,
arma::Row<size_t>& stateSequence,
const size_t startState) const
{
// Set vectors to the right size.
stateSequence.set_size(length);
dataSequence.set_size(dimensionality, length);
I found some reasons:dataSequence.col(t) = emission[stateSequence[t]].Random(); is error
http://stackoverflow.com/questions/9100848/vector-subscript-out-of-range-error-in-c
The text was updated successfully, but these errors were encountered: