dtkirsch/hmm — pull request #1 by jimlindstrom (2013-01-26 17:18:57+00:00)
Title: Instead of recomputing log()s of @a, @b, and @pi as needed, this does it...

... once, lazily. @log_a, @log_b, @log_pi are calculated the first time they're needed. These are also invalidated (then recalculated, as needed) by the various training methods.

I'm using HMM to estimate the key of a musical phrase, in https://github.com/jimlindstrom/multi_markov_composer/blob/key-detection/lib/note_queue.rb. When repeatedly calling decode() and likelihood() for different sequences, but without retraining, I noticed that log() was being called a LOT. Precalculating the logs makes my usage of HMM about 2x faster.