mvem.mixture.skewnorm

mvem.mixture.skewnorm.fit

mvem.mixture.skewnorm.fit(y, g, mu=None, Sigma=None, shape=None, pi=None, kmeans_init=True, k_max_iter=50, k_n_init=1, max_iter=100, error=0.0001, uni_Gamma=False, criteria=True, group=True, obs_prob=True)[source]

Fit a multivariate skew normal mixture model using an EM algorithm.

Parameters
  • y (np.ndarray) – An array of shape (n, p) containing n observations of some p-variate data with n > p.

  • g (int) – The number of cluster to be considered.

  • mu (list, optional) – Initial location parameters of the skew-normal distributions. List of length g containing np.ndarrays of shape (p,).

  • Sigma (list, optional) – Initial shape parameters of the skew-normal distributions. List of length g containingpositive semidefinite np.ndarrays of shape (p, p).

  • shape (list, optional) – Initial skewness parameters of the skew-normal distributions. List of length g containing np.ndarrays of shape (p,).

  • pi (list, optional) – A vector of initial values, with length g, for the weights for each cluster. Must sum one.

  • kmeans_init – If True, the initial values, which are not specified, are generated via k-means. pi is computed via k-means, whether specified or not. Defaults to True.

  • k_max_iter (int, optional) – Maximum number of iterations of the k-means algorithm for a single run. Defaults to 50.

  • k_n_init (int, optional) – Number of time the k-means algorithm will be run with different centroid seeds. Defaults to 1.

  • max_iter (int, optional) – The maximum number of iterations of the EM algorithm. Defaults to 100.

  • error (float, optional) – The covergence maximum error for log-likelihood. Defaults to 1e-4.

  • uni_Gamma (bool, optional) – If True, the Gamma parameters are restricted to be the same for all clusters. Defaults to False.

  • criteria (bool, optional) – If True, log-likelihood, AIC, DIC, EDC and ICL will be calculated. Defaults to True.

  • group (bool, optional) – If True, the vector with the classification of the response is returned. Defaults to True.

  • obs_prob (bool, optional) – If True, the posterior probability of each observation belonging to one of the g groups is reported. Defaults to True.

Returns

The fitted parameters as well as any other specified metrics.

Return type

dict

mvem.mixture.skewnorm.pdf

mvem.mixture.skewnorm.pdf(y, pi, mu, Sigma, lmbda)[source]

Probability density function of the multivariate skew-normal mixture model.

Parameters
  • y (np.ndarray) – An array of shape (n, p) containing n observations of some p-variate data with n > p.

  • pi (np.ndarray) – List of weights for all groups. Length g. Elements must sum to 1.

  • mu (list) – Location parameters of the skew-normal distributions. List of length g containing np.ndarrays of shape (p,).

  • Sigma (list) – Shape parameters of the skew-normal distributions. List of length g containingpositive semidefinite np.ndarrays of shape (p, p).

  • lmbda (list) – Skewness parameters of the skew-normal distributions. List of length g containing np.ndarrays of shape (p,).

Returns

The log-density at each observation.

Return type

np.ndarray with shape (n,).

mvem.mixture.skewnorm.predict

mvem.mixture.skewnorm.predict(y, mu, Sigma, lmbda)[source]

Predict probability of cluster belonging in multivariate skew-normal mixture model.

Parameters
  • y (np.ndarray) – An array of shape (n, p) containing n observations of some p-variate data with n > p.

  • mu (list) – Location parameters of the skew-normal distributions. List of length g containing np.ndarrays of shape (p,).

  • Sigma (list) – Shape parameters of the skew-normal distributions. List of length g containingpositive semidefinite np.ndarrays of shape (p, p).

  • lmbda (list) – Skewness parameters of the skew-normal distributions. List of length g containing np.ndarrays of shape (p,).

Returns

The probability of belonging to each of the g clusters, for each observation.

Return type

np.ndarray with shape (n, g).

mvem.mixture.skewnorm.rvs

mvem.mixture.skewnorm.rvs(pi, mu, Sigma, lmbda, size=1)[source]

Random number generator of multivariate skew-normal mixture model.

Parameters
  • pi (np.ndarray) – List of weights for all groups. Length g. Elements must sum to 1.

  • mu (list) – Location parameters of the skew-normal distributions. List of length g containing np.ndarrays of shape (p,).

  • Sigma (list) – Shape parameters of the skew-normal distributions. List of length g containingpositive semidefinite np.ndarrays of shape (p, p).

  • lmbda (list) – Skewness parameters of the skew-normal distributions. List of length g containing np.ndarrays of shape (p,).

  • size (int, optional) – The number of random numbers to generate. Defaults to 1.

Returns

The generated random numbers.

Return type

np.ndarray with shape (n,p).