Package nltk :: Module probability :: Class ProbDistI
[hide private]
[frames] | no frames]

Class ProbDistI

source code

object --+
         |
        ProbDistI
Known Subclasses:

A probability distribution for the outcomes of an experiment. A probability distribution specifies how likely it is that an experiment will have any given outcome. For example, a probability distribution could be used to predict the probability that a token in a document will have a given type. Formally, a probability distribution can be defined as a function mapping from samples to nonnegative real numbers, such that the sum of every number in the function's range is 1.0. ProbDists are often used to model the probability distribution of the experiment used to generate a frequency distribution.

Instance Methods [hide private]
 
__init__(self)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
source code
float
prob(self, sample)
Returns: the probability for a given sample.
source code
float
logprob(self, sample)
Returns: the base 2 logarithm of the probability for a given sample.
source code
any
max(self)
Returns: the sample with the greatest probability.
source code
list
samples(self)
Returns: A list of all samples that have nonzero probabilities.
source code
float
discount(self)
Returns: The ratio by which counts are discounted on average: c*/c
source code
 
generate(self)
Returns: A randomly selected sample from this probabilitiy distribution.
source code

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__

Class Variables [hide private]
  SUM_TO_ONE = True
True if the probabilities of the samples in this probability distribution will always sum to one.
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self)
(Constructor)

source code 

x.__init__(...) initializes x; see x.__class__.__doc__ for signature

Overrides: object.__init__
(inherited documentation)

prob(self, sample)

source code 
Parameters:
  • sample (any) - The sample whose probability should be returned.
Returns: float
the probability for a given sample. Probabilities are always real numbers in the range [0, 1].

logprob(self, sample)

source code 
Parameters:
  • sample (any) - The sample whose probability should be returned.
Returns: float
the base 2 logarithm of the probability for a given sample. Log probabilities range from negitive infinity to zero.

max(self)

source code 
Returns: any
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.

samples(self)

source code 
Returns: list
A list of all samples that have nonzero probabilities. Use prob to find the probability of each sample.

discount(self)

source code 
Returns: float
The ratio by which counts are discounted on average: c*/c

generate(self)

source code 
Returns:
A randomly selected sample from this probabilitiy distribution. The probability of returning each sample samp is equal to self.prob(samp).