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

Class LidstoneProbDist

source code

object --+    
         |    
 ProbDistI --+
             |
            LidstoneProbDist
Known Subclasses:

The Lidstone estimate for the probability distribution of the experiment used to generate a frequency distribution. The Lidstone estimate is paramaterized by a real number gamma, which typically ranges from 0 to 1. The Lidstone estimate approximates the probability of a sample with count c from an experiment with N outcomes and B bins as (c+gamma)/(N+B*gamma). This is equivalant to adding gamma to the count for each bin, and taking the maximum likelihood estimate of the resulting frequency distribution.

Instance Methods [hide private]
 
__init__(self, freqdist, gamma, bins=None)
Use the Lidstone estimate to create a probability distribution for the experiment used to generate freqdist.
source code
FreqDist
freqdist(self)
Returns: The frequency distribution that this probability distribution is based on.
source code
float
prob(self, sample)
Returns: 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
string
__repr__(self)
Returns: A string representation of this ProbDist.
source code

Inherited from ProbDistI: generate, logprob

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

Class Variables [hide private]
  SUM_TO_ONE = False
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, freqdist, gamma, bins=None)
(Constructor)

source code 

Use the Lidstone estimate to create a probability distribution for the experiment used to generate freqdist.

Parameters:
  • freqdist (FreqDist) - The frequency distribution that the probability estimates should be based on.
  • gamma (float) - A real number used to paramaterize the estimate. The Lidstone estimate is equivalant to adding gamma to the count for each bin, and taking the maximum likelihood estimate of the resulting frequency distribution.
  • bins (int) - The number of sample values that can be generated by the experiment that is described by the probability distribution. This value must be correctly set for the probabilities of the sample values to sum to one. If bins is not specified, it defaults to freqdist.B().
Overrides: ProbDistI.__init__

freqdist(self)

source code 
Returns: FreqDist
The frequency distribution that this probability distribution is based on.

prob(self, sample)

source code 
Parameters:
  • sample - 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].
Overrides: ProbDistI.prob
(inherited documentation)

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.
Overrides: ProbDistI.max
(inherited documentation)

samples(self)

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

discount(self)

source code 
Returns: float
The ratio by which counts are discounted on average: c*/c
Overrides: ProbDistI.discount
(inherited documentation)

__repr__(self)
(Representation operator)

source code 

repr(x)

Returns: string
A string representation of this ProbDist.
Overrides: object.__repr__