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

Class ConditionalProbDist

source code

          object --+    
                   |    
ConditionalProbDistI --+
                       |
                      ConditionalProbDist

A conditional probability distribution modelling the experiments that were used to generate a conditional frequency distribution. A ConditoinalProbDist is constructed from a ConditionalFreqDist and a ProbDist factory:

The first argument to the ProbDist factory is the frequency distribution that it should model; and the remaining arguments are specified by the factory_args parameter to the ConditionalProbDist constructor. For example, the following code constructs a ConditionalProbDist, where the probability distribution for each condition is an ELEProbDist with 10 bins:

>>> cpdist = ConditionalProbDist(cfdist, ELEProbDist, 10)
>>> print cpdist['run'].max()
'NN'
>>> print cpdist['run'].prob('NN')
0.0813
Instance Methods [hide private]
 
__init__(self, cfdist, probdist_factory, supply_condition=False, *factory_args)
Construct a new conditional probability distribution, based on the given conditional frequency distribution and ProbDist factory.
source code
 
__contains__(self, condition) source code
ProbDistI
__getitem__(self, condition)
Returns: The probability distribution for the experiment run under the given condition.
source code
list
conditions(self)
Returns: A list of the conditions that are represented by this ConditionalProbDist.
source code
int
__len__(self)
Returns: The number of conditions that are represented by this ConditionalProbDist.
source code
string
__repr__(self)
Returns: A string representation of this ConditionalProbDist.
source code

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

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, cfdist, probdist_factory, supply_condition=False, *factory_args)
(Constructor)

source code 

Construct a new conditional probability distribution, based on the given conditional frequency distribution and ProbDist factory.

Parameters:
  • cfdist (ConditionalFreqDist) - The ConditionalFreqDist specifying the frequency distribution for each condition.
  • probdist_factory (class or function) - The function or class that maps a condition's frequency distribution to its probability distribution. The function is called with the frequency distribution as its first argument, the condition as its second argument (only if supply_condition=True), and factory_args as its remaining arguments.
  • supply_condition (bool) - If true, then pass the condition as the second argument to probdist_factory.
  • factory_args ((any)) - Extra arguments for probdist_factory. These arguments are usually used to specify extra properties for the probability distributions of individual conditions, such as the number of bins they contain.
Overrides: ConditionalProbDistI.__init__

__getitem__(self, condition)
(Indexing operator)

source code 
Parameters:
  • condition - The condition whose probability distribution should be returned.
Returns: ProbDistI
The probability distribution for the experiment run under the given condition.
Overrides: ConditionalProbDistI.__getitem__
(inherited documentation)

conditions(self)

source code 
Returns: list
A list of the conditions that are represented by this ConditionalProbDist. Use the indexing operator to access the probability distribution for a given condition.
Overrides: ConditionalProbDistI.conditions
(inherited documentation)

__len__(self)
(Length operator)

source code 
Returns: int
The number of conditions that are represented by this ConditionalProbDist.
Overrides: ConditionalProbDistI.__len__
(inherited documentation)

__repr__(self)
(Representation operator)

source code 

repr(x)

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