Package jazzparser :: Package utils :: Package nltk :: Module probability :: Class WittenBellProbDistFix
[hide private]
[frames] | no frames]

Class WittenBellProbDistFix

source code

                     object --+        
                              |        
     nltk.probability.ProbDistI --+    
                                  |    
nltk.probability.WittenBellProbDist --+
                                      |
                                     WittenBellProbDistFix

There's a nasty bug in WittenBellProbDist, but the fix is very simple. Use this instead of WittenBellProbDist.

Instance Methods [hide private]
 
__init__(self, freqdist, bins=None)
Creates a distribution of Witten-Bell probability estimates.
source code

Inherited from nltk.probability.WittenBellProbDist: __repr__, discount, freqdist, max, prob, samples

Inherited from nltk.probability.ProbDistI: generate, logprob

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Variables [hide private]

Inherited from nltk.probability.ProbDistI: SUM_TO_ONE

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, freqdist, bins=None)
(Constructor)

source code 

Creates a distribution of Witten-Bell probability estimates. This distribution allocates uniform probability mass to as yet unseen events by using the number of events that have only been seen once. The probability mass reserved for unseen events is equal to:

  • T / (N + T)

where T is the number of observed event types and N is the total number of observed events. This equates to the maximum likelihood estimate of a new type event occuring. The remaining probability mass is discounted such that all probability estimates sum to one, yielding:

  • p = T / Z (N + T), if count = 0
  • p = c / (N + T), otherwise

The parameters T and N are taken from the freqdist parameter (the B() and N() values). The normalising factor Z is calculated using these values along with the bins parameter.

Parameters:
  • freqdist - The frequency counts upon which to base the estimation.
  • bins - The number of possible event types. This must be at least as large as the number of bins in the freqdist. If None, then it's assumed to be equal to that of the freqdist
Overrides: object.__init__
(inherited documentation)