Package nltk_lite :: Module probability :: Class DictionaryProbDist
[show private | hide private]
[frames | no frames]

Type DictionaryProbDist

object --+    
         |    
 ProbDistI --+
             |
            DictionaryProbDist


A probability distribution whose probabilities are directly specified by a given dictionary. The given dictionary maps samples to probabilities.
Method Summary
  __init__(self, prob_dict, log, normalize)
Construct a new probability distribution from the given dictionary, which maps values to probabilities (or to log probabilities, if log is true).
  __repr__(self)
float logprob(self, sample)
Return the natural logarithm of the probability for a given sample.
any max(self)
Return the sample with the greatest probability.
float prob(self, sample)
Return the probability for a given sample.
list samples(self)
Return a list of all samples that have nonzero probabilities.
Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __setattr__, __str__

Method Details

__init__(self, prob_dict=None, log=False, normalize=False)
(Constructor)

Construct a new probability distribution from the given dictionary, which maps values to probabilities (or to log probabilities, if log is true). If normalize is true, then the probability values are scaled by a constant factor such that they sum to 1.
Overrides:
nltk_lite.probability.ProbDistI.__init__

logprob(self, sample)

Parameters:
sample - The sample whose probability should be returned.
           (type=any)
Returns:
the natural logarithm of the probability for a given sample. Log probabilities range from negitive infinity to zero.
           (type=float)
Overrides:
nltk_lite.probability.ProbDistI.logprob (inherited documentation)

max(self)

Returns:
the sample with the greatest probability. If two or more samples have the same probability, return one of them; which sample is returned is undefined.
           (type=any)
Overrides:
nltk_lite.probability.ProbDistI.max (inherited documentation)

prob(self, sample)

Parameters:
sample - The sample whose probability should be returned.
           (type=any)
Returns:
the probability for a given sample. Probabilities are always real numbers in the range [0, 1].
           (type=float)
Overrides:
nltk_lite.probability.ProbDistI.prob (inherited documentation)

samples(self)

Returns:
A list of all samples that have nonzero probabilities. Use prob to find the probability of each sample.
           (type=list)
Overrides:
nltk_lite.probability.ProbDistI.samples (inherited documentation)

Generated by Epydoc 2.1 on Tue Sep 5 09:37:21 2006 http://epydoc.sf.net