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

Class UniformProbDist

source code

object --+    
         |    
 ProbDistI --+
             |
            UniformProbDist

A probability distribution that assigns equal probability to each sample in a given set; and a zero probability to all other samples.

Instance Methods [hide private]
 
__init__(self, samples)
Construct a new uniform probability distribution, that assigns equal probability to each sample in samples.
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
 
__repr__(self)
repr(x)
source code

Inherited from ProbDistI: discount, generate, logprob

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

Class Variables [hide private]

Inherited from ProbDistI: SUM_TO_ONE

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, samples)
(Constructor)

source code 

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.
Overrides: ProbDistI.__init__

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)

__repr__(self)
(Representation operator)

source code 

repr(x)

Overrides: object.__repr__
(inherited documentation)