naginterfaces.library.mv.gaussian_​mixture

naginterfaces.library.mv.gaussian_mixture(x, nvar, ng, sopt, isx=None, prob=None, niter=15, riter=0, tol=0.0)[source]

gaussian_mixture performs a mixture of Normals (Gaussians) for a given (co)variance structure.

For full information please refer to the NAG Library document for g03ga

https://support.nag.com/numeric/nl/nagdoc_30.2/flhtml/g03/g03gaf.html

Parameters
xfloat, array-like, shape

must contain the value of the th variable for the th object, for , for .

nvarint

, the number of variables included in the calculations.

ngint

, the number of groups in the mixture model.

soptint

Determines the (co)variance structure:

Groupwise covariance matrices.

Pooled covariance matrix.

Groupwise variances.

Pooled variances.

Overall variance.

isxNone or int, array-like, shape , optional

Note: the required length for this argument is determined as follows: if : ; otherwise: .

If all available variables are included in the model and is not referenced; otherwise the th variable will be included in the analysis if and excluded if , for .

probNone or float, array-like, shape , optional

If is not None, is the probability that the th object belongs to the th group. (These probabilities are normalised internally.) Otherwise, the initial membership probabilities are set internally.

niterint, optional

The maximum number of iterations.

riterint, optional

If , membership probabilities are rounded to or after the completion of the first iterations.

tolfloat, optional

Iterations cease the first time an improvement in log-likelihood is less than . If a value of is used.

Returns
probfloat, ndarray, shape

is the probability of membership of the th object to the th group for the fitted model.

niterint

The number of completed iterations.

wfloat, ndarray, shape

, the mixing probability for the th group.

gfloat, ndarray, shape

gives the estimated mean of the th variable in the th group.

sfloat, ndarray, shape

If , gives the th element of the th group.

If , gives the th element of the pooled covariance.

If , gives the th variance in the th group.

If , gives the th pooled variance.

If , gives the overall variance.

ffloat, ndarray, shape

gives the -variate Normal (Gaussian) density of the th object in the th group.

loglikfloat

The log-likelihood for the fitted mixture model.

Raises
NagValueError
(errno )

On entry, and .

Constraint: , the number of parameters, i.e., too few objects have been supplied for the model.

(errno )

On entry, .

Constraint: .

(errno )

On entry, and .

Constraint: .

(errno )

On entry, and is invalid.

(errno )

On entry, .

Constraint: .

(errno )

On entry, row of supplied does not sum to .

(errno )

On entry, .

Constraint: .

(errno )

On entry, , , , or .

(errno )

A covariance matrix is not positive definite, try a different initial allocation.

(errno )

An iteration cannot continue due to an empty group, try a different initial allocation.

Notes

A Normal (Gaussian) mixture model is a weighted sum of group Normal densities given by,

where:

is a -dimensional object of interest;

is the mixture weight for the th group and ;

is a -dimensional vector of means for the th group;

is the covariance structure for the th group;

is the -variate Normal density:

Optionally, the (co)variance structure may be pooled (common to all groups) or calculated for each group, and may be full or diagonal.

References

Hartigan, J A, 1975, Clustering Algorithms, Wiley