Portability | portable |
---|---|
Stability | experimental |
Maintainer | felipe.lessa@gmail.com |
Safe Haskell | Safe-Infered |
- data DirichletMixture = DM {
- dmWeights :: !(Vector Double)
- dmDensities :: !Matrix
- dmComponents :: DirichletMixture -> Int
- dmParameters :: DirichletMixture -> Int
- dmDensitiesL :: DirichletMixture -> [DirichletDensity]
- (!!!) :: DirichletMixture -> Int -> Vector Double
- empty :: Int -> Int -> Double -> DirichletMixture
- type Component = (Double, [Double])
- fromList :: [Component] -> DirichletMixture
- toList :: DirichletMixture -> [Component]
- fromDD :: DirichletDensity -> DirichletMixture
- data TrainingData
- prepareTraining :: TrainingVectors -> TrainingData
- derive :: DirichletMixture -> Predicate -> StepSize -> TrainingData -> Result DirichletMixture
- cost :: TrainingData -> DirichletMixture -> Double
- del_cost_w :: TrainingData -> DirichletMixture -> Matrix
Data types
data DirichletMixture Source
A Dirichlet mixture.
dmComponents :: DirichletMixture -> IntSource
Number of components in a dirichlet mixture.
dmParameters :: DirichletMixture -> IntSource
Number of parameters each component has.
dmDensitiesL :: DirichletMixture -> [DirichletDensity]Source
Separated list of densities.
(!!!) :: DirichletMixture -> Int -> Vector DoubleSource
dm !!! i
is the i
-th density. No bounding checks are
made.
empty :: Int -> Int -> Double -> DirichletMixtureSource
empty q n x
is an "empty" Dirichlet mixture with q
components and n
parameters. Each component has size n
,
weight inversely proportional to its index and all alphas set
to x
.
fromList :: [Component] -> DirichletMixtureSource
fromList xs
constructs a Dirichlet mixture from a
non-empty list of components. Each component has a weight and
a list of alpha values. The weights sum to 1, all lists must
have the same number of values and every number must be
non-negative. None of these preconditions are verified.
toList :: DirichletMixture -> [Component]Source
toList dm
is the inverse of fromList
, constructs a list
of components from a Dirichlet mixture. There are no error
conditions and toList . fromList == id
.
fromDD :: DirichletDensity -> DirichletMixtureSource
Constructs a Dirichlet mixture of one component from a Dirichlet density.
Training data
data TrainingData Source
Pre-processed training vectors (see prepareTraining
).
prepareTraining :: TrainingVectors -> TrainingDataSource
Prepares training vectors to be used as training data. Anything that depends only on the training vectors is precalculated here.
We also try to find columns where all training vectors are zero. Those columns are removed from the derivation process and every component will have zero value on that column. Note that at least one column should have non-zero training vectors.
Functions
derive :: DirichletMixture -> Predicate -> StepSize -> TrainingData -> Result DirichletMixtureSource
Derive a Dirichlet mixture using a maximum likelihood method as described by Karplus et al (equation 25) using CG_DESCENT method by Hager and Zhang (see Numeric.Optimization.Algorithms.HagerZhang05). All training vectors should have the same length, however this is not verified.
cost :: TrainingData -> DirichletMixture -> DoubleSource
Cost function for deriving a Dirichlet mixture (equation
18). This function is minimized by derive
. Calculated
using (17) and (54).
del_cost_w :: TrainingData -> DirichletMixture -> MatrixSource
Derivative of the cost function with respect w_{i,j}
,
defined by Equation (22). The result is given in the same
size and order as the dmDensitites
vector.