Think Bayes in Raku - Suite class, take 2

TL;DR

Of course there had to be a follow-up on the Suite class.

In previous post Think Bayes in Raku - Pmf class, take 2 we saw an evolution of the Pmf class to support multiplication of a Pmf object by a hash of key/values, representing the *likelihood` of each key.

So I decided that `Suite’ had to evolve too:

class Suite is Pmf {
   has &!likelihood is required;
   submethod BUILD (:lh(:&!likelihood)) { }
   method update ($data) { return self.multiply(&!likelihood($data)) }
}

This is it. Now &!likelihood is supposed to be called with $data only, and it takes care to calculate the likelihood across all possible keys.

Thanks to the simplification, this implementation is simpler too, and also closer to how the data are used.


Comments? Octodon, , GitHub, Reddit, or drop me a line!