class LidstoneProbDist(ProbDistI): (source)
Known subclasses: nltk.probability.ELEProbDist
, nltk.probability.LaplaceProbDist
Constructor: LidstoneProbDist(freqdist, gamma, bins)
The Lidstone estimate for the probability distribution of the experiment used to generate a frequency distribution. The "Lidstone estimate" is parameterized 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 equivalent to adding gamma to the count for each bin, and taking the maximum likelihood estimate of the resulting frequency distribution.
Method | __init__ |
Use the Lidstone estimate to create a probability distribution for the experiment used to generate freqdist. |
Method | __repr__ |
Return a string representation of this ProbDist. |
Method | discount |
Return the ratio by which counts are discounted on average: c*/c |
Method | freqdist |
Return the frequency distribution that this probability distribution is based on. |
Method | max |
Return 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. |
Method | prob |
Return the probability for a given sample. Probabilities are always real numbers in the range [0, 1]. |
Method | samples |
Return a list of all samples that have nonzero probabilities. Use prob to find the probability of each sample. |
Constant | SUM |
True if the probabilities of the samples in this probability distribution will always sum to one. |
Instance Variable | _bins |
Undocumented |
Instance Variable | _divisor |
Undocumented |
Instance Variable | _freqdist |
Undocumented |
Instance Variable | _gamma |
Undocumented |
Instance Variable | _N |
Undocumented |
Inherited from ProbDistI
:
Method | generate |
Return a randomly selected sample from this probability distribution. The probability of returning each sample samp is equal to self.prob(samp). |
Method | logprob |
Return the base 2 logarithm of the probability for a given sample. |
nltk.probability.ProbDistI.__init__
nltk.probability.ELEProbDist
, nltk.probability.LaplaceProbDist
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 parameterize the estimate. The Lidstone estimate is equivalent 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(). |
nltk.probability.ELEProbDist
, nltk.probability.LaplaceProbDist
Return a string representation of this ProbDist.
Returns | |
str | Undocumented |
nltk.probability.ProbDistI.discount
Return the ratio by which counts are discounted on average: c*/c
Returns | |
float | Undocumented |
Return the frequency distribution that this probability distribution is based on.
Returns | |
FreqDist | Undocumented |
nltk.probability.ProbDistI.max
Return 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.
Returns | |
any | Undocumented |
nltk.probability.ProbDistI.prob
Return the probability for a given sample. Probabilities are always real numbers in the range [0, 1].
Parameters | |
sample:any | The sample whose probability should be returned. |
Returns | |
float | Undocumented |
nltk.probability.ProbDistI.samples
Return a list of all samples that have nonzero probabilities. Use prob to find the probability of each sample.
Returns | |
list | Undocumented |
nltk.probability.ProbDistI.SUM_TO_ONE
True if the probabilities of the samples in this probability distribution will always sum to one.
Value |
|