nltk.probability.MLEProbDist

class nltk.probability.MLEProbDist[source]

Bases: ProbDistI

The maximum likelihood estimate for the probability distribution of the experiment used to generate a frequency distribution. The “maximum likelihood estimate” approximates the probability of each sample as the frequency of that sample in the frequency distribution.

__init__(freqdist, bins=None)[source]

Use the maximum likelihood 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.

freqdist()[source]

Return the frequency distribution that this probability distribution is based on.

Return type

FreqDist

prob(sample)[source]

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.

Return type

float

max()[source]

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.

Return type

any

samples()[source]

Return a list of all samples that have nonzero probabilities. Use prob to find the probability of each sample.

Return type

list

SUM_TO_ONE = True

True if the probabilities of the samples in this probability distribution will always sum to one.

discount()

Return the ratio by which counts are discounted on average: c*/c

Return type

float

generate()

Return a randomly selected sample from this probability distribution. The probability of returning each sample samp is equal to self.prob(samp).

logprob(sample)

Return the base 2 logarithm of the probability for a given sample.

Parameters

sample (any) – The sample whose probability should be returned.

Return type

float