The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.


Math::Vector::Real::MultiNormalMixture - Multinormal Mixture distribution


  use Math::Vector::Real::MultiNormalMixture;

  my $mnm = Math::Vector::Real::MultiNormalMixture->new(
       mu    => [[0.0, 0.0], [1.0, 0.0], [0.0, 1.5]],
       sigma => [ 1.0,        1.0,        2.0      ],
       alpha => [ 0.5,        0.25,       0.25     ]

  my $d = $mnm->density([0.5, 0.2]);


This module allows to calculate the density of a mixture of n multivariate normal simetric distributions.

Given a multivariate normal simetric distributions in IR**k (IR := the real numbers domain) such that its density function can be calculated as...

  p($x) = (sqrt(2*pi)*$sigma)**(-$k) * exp(|$x-$mu|/$sigma)**2)


    $x is a vector of dimension k,
    $mu is the median vector of the distribution,
    $d = |$x - $mu|, the distance between the median and x
    $sigma is the standard deviation,
    (the covariance matrix is restricted to $sigma*$Ik being $Ik
     the identity matrix of size k)

A multivariate normal distribution mixin is defined as a weighted mix of a set of multivariate normal simetric distributions, such that its density function is...

  pm(x) = sum ( $alpha[$i] * p[$i](x) )


The following methods are available:

$mnm = Math::Vector::Real::MultiNormalMixture->new(%opts)

Creates a new Multivariate Normal Mixture distribution object.

The accepted arguments are as follow:

mu => \@mu

An array of vectors (or array references) containing the mediams of the single multinormal distributions.

alpha => \@alpha

An array of coeficients with the mixing weights. This argument is optional.

sigma => \@sigma

An array with the sigma parameter for every one of the multinormal distributions.

A single value can also be provided and all the multinormal distributions will have it.

The default sigma value is 1.0.


Returns the distribution density at the given point.

$mnm->density_portion($x, $i0, $i1, $i2, ...)

Returns the density portion associated to the multivariate normals with indexes $i0, $i1, etc.

$dd = $mnm->density_and_gradient($x)

Returns density and the gradient of the density function at the given point.

$d = $mnm->max_density_estimation

Returns the maximun value of the density in IR**k.


Mixture distribution on the wikipedia:

Multivariate normal distribution on the wikipedia:



Salvador Fandiño, <>


Copyright (C) 2011 by Salvador Fandino

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.12.3 or, at your option, any later version of Perl 5 you may have available.