nltk.probability.UniformProbDist¶
- class nltk.probability.UniformProbDist[source]¶
Bases:
ProbDistI
A probability distribution that assigns equal probability to each sample in a given set; and a zero probability to all other samples.
- __init__(samples)[source]¶
Construct a new uniform probability distribution, that assigns equal probability to each sample in
samples
.- Parameters
samples (list) – The samples that should be given uniform probability.
- Raises
ValueError – If
samples
is empty.
- 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()[source]¶
Return the ratio by which counts are discounted on average: c*/c
- Return type
float