Module mixture :: Class DirichletPrior
[hide private]
[frames] | no frames]

Class DirichletPrior

source code


Dirichlet distribution as Bayesian prior for MultinomialDistribution and derived .

Instance Methods [hide private]
 
__init__(self, M, alpha)
Constructor
source code
 
__copy__(self)
Interface for the copy.copy function
source code
 
__str__(self)
String representation of the DataSet
source code
 
__eq__(self, other)
Interface for the '==' operation
source code
 
sample(self)
Samples from Dirichlet distribution
source code
 
pdf(self, m)
Returns the log-density of the ProbDistribution object(s) 'm' under the prior.
source code
 
posterior(self, m, x)
Returns the posterior for multinomial distribution 'm' for multinomial count data 'x' The posterior is again Dirichlet.
source code
 
marginal(self, x)
Returns the log marginal likelihood of multinomial counts 'x' (sufficient statistics) with Dirichlet prior 'self' integrated over all parameterizations of the multinomial.
source code
 
mapMStep(self, dist, posterior, data, mix_pi=None, dist_ind=None)
Maximization step of the maximum aposteriori EM procedure.
source code
 
mapMStepMerge(self, group_list)
Computes the MAP parameter estimates for a candidate merge in the structure learning based on the information of two CandidateGroup objects.
source code
 
mapMStepSplit(self, toSplitFrom, toBeSplit)
Computes the MAP parameter estimates for a candidate merge in the structure learning based on the information of two CandidateGroup objects.
source code
 
isValid(self, x)
Checks whether 'x' is a valid argument for the distribution and raises InvalidDistributionInput exception if that is not the case.
source code
 
flatStr(self, offset)
Returns the model parameters as a string compatible with the WriteMixture/ReadMixture flat file format.
source code

Inherited from PriorDistribution: updateHyperparameters

Inherited from ProbDistribution: MStep, formatData, merge, posteriorTraceback, sampleSet, sufficientStatistics, update_suff_p

Method Details [hide private]

__init__(self, M, alpha)
(Constructor)

source code 

Constructor

Parameters:
  • M - number of dimensions
  • alpha - distribution parameters
Overrides: ProbDistribution.__init__

__copy__(self)

source code 

Interface for the copy.copy function

Overrides: ProbDistribution.__copy__
(inherited documentation)

__str__(self)
(Informal representation operator)

source code 

String representation of the DataSet

Returns:
string representation
Overrides: ProbDistribution.__str__
(inherited documentation)

__eq__(self, other)
(Equality operator)

source code 

Interface for the '==' operation

Parameters:
  • other - object to be compared
Overrides: ProbDistribution.__eq__
(inherited documentation)

sample(self)

source code 

Samples from Dirichlet distribution

Returns:
sampled value
Overrides: ProbDistribution.sample

pdf(self, m)

source code 

Returns the log-density of the ProbDistribution object(s) 'm' under the prior.

Parameters:
  • m - single appropriate ProbDistribution object or list of ProbDistribution objects
Returns:
log-value of the density function for each sample in 'data'
Overrides: ProbDistribution.pdf
(inherited documentation)

posterior(self, m, x)

source code 

Returns the posterior for multinomial distribution 'm' for multinomial count data 'x' The posterior is again Dirichlet.

Overrides: PriorDistribution.posterior

marginal(self, x)

source code 

Returns the log marginal likelihood of multinomial counts 'x' (sufficient statistics) with Dirichlet prior 'self' integrated over all parameterizations of the multinomial.

Overrides: PriorDistribution.marginal

mapMStep(self, dist, posterior, data, mix_pi=None, dist_ind=None)

source code 

Maximization step of the maximum aposteriori EM procedure. Reestimates the distribution parameters of argument 'dist' using the posterior distribution, the data and a conjugate prior.

MUST accept either numpy or DataSet object of appropriate values. numpys are used as input for the atomar distributions for efficiency reasons.

Parameters:
  • dist - distribution whose parameters are to be maximized
  • posterior - posterior distribution of component membership
  • data - DataSet object or 'numpy' of samples
  • mix_pi - mixture weights, necessary for MixtureModels as components.
  • dist_ind - optional index of 'dist', necessary for ConditionalGaussDistribution.mapMStep (XXX)
Overrides: PriorDistribution.mapMStep
(inherited documentation)

mapMStepMerge(self, group_list)

source code 

Computes the MAP parameter estimates for a candidate merge in the structure learning based on the information of two CandidateGroup objects.

Parameters:
  • group_list - list of CandidateGroup objects
Returns:
CandidateGroup object with MAP parameters
Overrides: PriorDistribution.mapMStepMerge
(inherited documentation)

mapMStepSplit(self, toSplitFrom, toBeSplit)

source code 

Computes the MAP parameter estimates for a candidate merge in the structure learning based on the information of two CandidateGroup objects.

Returns:
CandidateGroup object with MAP parameters
Overrides: PriorDistribution.mapMStepSplit
(inherited documentation)

isValid(self, x)

source code 

Checks whether 'x' is a valid argument for the distribution and raises InvalidDistributionInput exception if that is not the case.

Parameters:
  • x - single sample in external representation, i.e.. an entry of DataSet.dataMatrix
Returns:
True/False flag
Overrides: ProbDistribution.isValid
(inherited documentation)

flatStr(self, offset)

source code 

Returns the model parameters as a string compatible with the WriteMixture/ReadMixture flat file format.

Parameters:
  • offset - number of ' ' characters to be used in the flatfile.
Overrides: ProbDistribution.flatStr
(inherited documentation)