| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → Statistics Toolbox |
| Contents | Index |
| Learn more about Statistics Toolbox |
Random numbers from Gaussian mixture distribution
y = random(obj)
Y = random(obj,n)
[Y,idx] = random(obj,n)
y = random(obj) generates a 1-by-d vector y drawn at random from the d-dimensional Gaussian mixture distribution defined by obj. obj is an object created by gmdistribution or fit.
Y = random(obj,n) generates an n-by-d matrix Y of n d-dimensional random samples.
[Y,idx] = random(obj,n) also returns an n-by-1 vector idx, where idx(I) is the index of the component used to generate Y(I,:).
Create a gmdistribution object defining a two-component mixture of bivariate Gaussian distributions:
MU = [1 2;-3 -5]; SIGMA = cat(3,[2 0;0 .5],[1 0;0 1]); p = ones(1,2)/2; obj = gmdistribution(MU,SIGMA,p); ezcontour(@(x,y)pdf(obj,[x y]),[-10 10],[-10 10]) hold on

Generate 1000 random values:
Y = random(obj,1000); scatter(Y(:,1),Y(:,2),10,'.')

![]() | random | random (piecewisedistribution) | ![]() |

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |