Opened 13 years ago

Closed 13 years ago

#8732 closed defect (fixed)

bug in new HMM code

Reported by: William Stein Owned by: amhou
Priority: blocker Milestone: sage-4.4
Component: statistics Keywords:
Cc: mhampton, Kelly Boothby, Jason Grout Merged in: sage-4.4.alpha2
Authors: William Stein Reviewers: Marshall Hampton
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Status badges


Crap, there is a bug in the new HMM code (#8547) that just went into sage-4.4.alpha0:

Try this:

sage: m = hmm.DiscreteHiddenMarkovModel([[1/3]*3]*3, [ [5]*5 ]*3, [1/3]*3, 'abcde'); m
sage: v = list('a'*100); v
sage: m.baum_welch(v)
sage: m.sample(10)
['e', 'a', 'e', 'e', 'a', 'c', 'c', 'c', 'c', 'a']
sage: m
Discrete Hidden Markov Model with 3 States and 5 Emissions
Transition matrix:
[0.333333333333 0.333333333333 0.333333333333]
[0.333333333333 0.333333333333 0.333333333333]
[0.333333333333 0.333333333333 0.333333333333]
Emission matrix:
[1.0 0.0 0.0 0.0 0.0]
[1.0 0.0 0.0 0.0 0.0]
[1.0 0.0 0.0 0.0 0.0]
Initial probabilities: [0.3333, 0.3333, 0.3333]

Notice above that it is impossible for the model to emit anything except 'a'. Yet in the sample it does!

This bug wasn't in the previous HMM code, of course. I'll fix this ASAP for sage-4.4.


Attachments (1)

trac_8732.patch (4.8 KB) - added by William Stein 13 years ago.

Download all attachments as: .zip

Change History (5)

Changed 13 years ago by William Stein

Attachment: trac_8732.patch added

comment:1 Changed 13 years ago by William Stein

Status: newneeds_review

I had a C array index backwards.

comment:2 Changed 13 years ago by John Palmieri

Cc: mhampton Kelly Boothby Jason Grout added

I'm cc'ing some possible reviewers...

comment:3 Changed 13 years ago by mhampton

Status: needs_reviewpositive_review

OK, patch looks good. Passes tests and coverage, change makes sense, and I did some random testing so I am giving this a positive review.

comment:4 Changed 13 years ago by John Palmieri

Authors: William Stein
Merged in: sage-4.4.alpha2
Resolution: fixed
Reviewers: Marshall Hampton
Status: positive_reviewclosed

Merged into 4.4.alpha2.

Note: See TracTickets for help on using tickets.