3.3.4.1.2. statsmodels.distributions.mixture_rvs.mv_mixture_rvs¶
-
statsmodels.distributions.mixture_rvs.
mv_mixture_rvs
(prob, size, dist, nvars, **kwargs)[source]¶ Sample from a mixture of multivariate distributions.
Parameters: prob : array-like
Probability of sampling from each distribution in dist
size : int
The length of the returned sample.
dist : array-like
An iterable of distributions instances with callable method rvs.
nvargs : int
dimension of the multivariate distribution, could be inferred instead
kwargs : tuple of dicts, optional
ignored
Examples
Say we want 2000 random variables from mixture of normals with two multivariate normal distributions, and we want to sample from the first with probability .4 and the second with probability .6.
import statsmodels.sandbox.distributions.mv_normal as mvd
- cov3 = np.array([[ 1. , 0.5 , 0.75],
- [ 0.5 , 1.5 , 0.6 ], [ 0.75, 0.6 , 2. ]])
mu = np.array([-1, 0.0, 2.0]) mu2 = np.array([4, 2.0, 2.0]) mvn3 = mvd.MVNormal(mu, cov3) mvn32 = mvd.MVNormal(mu2, cov3/2., 4) rvs = mix.mv_mixture_rvs([0.4, 0.6], 2000, [mvn3, mvn32], 3)