Popular recipes tagged "probability"http://code.activestate.com/recipes/tags/probability/2010-11-14T08:52:51-08:00ActiveState Code RecipesProbability Dictionary (Python) 2010-11-14T08:52:51-08:00Felipehttp://code.activestate.com/recipes/users/4175871/http://code.activestate.com/recipes/577460-probability-dictionary/ <p style="color: grey"> Python recipe 577460 by <a href="/recipes/users/4175871/">Felipe</a> (<a href="/recipes/tags/dictionary/">dictionary</a>, <a href="/recipes/tags/normalize/">normalize</a>, <a href="/recipes/tags/probability/">probability</a>). Revision 2. </p> <p>A subclass of dictionary that ensures that values are nonnegative, less than or equal to 1, and sum to 1. It also gives 0 for any attempt at looking up a key not in it, and purges keys whose associated value falls to 0.</p>