![]() |
randPURPOSE
Generates random points on a GMixture.
SYNOPSIS
function v=rand(gm,varargin)
DESCRIPTION
Generates random points on a GMixture. Return random vectors following the distribution represented by the mixture. Observe that this works for unnormalized mixtures too. The components are selected proportionally to the absolute value of their corresponding weigth. This function accepts two parameters - The Gaussian mixture. - The number of samples to drawn. If not given only one sample is generated. CROSS-REFERENCE INFORMATION
This function calls:
SOURCE CODE
0001 function v=rand(gm,varargin) 0002 % Generates random points on a GMixture. 0003 % 0004 % Return random vectors following the distribution represented by the 0005 % mixture. Observe that this works for unnormalized mixtures too. The 0006 % components are selected proportionally to the absolute value of their 0007 % corresponding weigth. 0008 % This function accepts two parameters 0009 % - The Gaussian mixture. 0010 % - The number of samples to drawn. If not given only one sample is 0011 % generated. 0012 0013 if gm.n==0 0014 v=0; 0015 else 0016 if nargin>1 0017 n=varargin{1}; 0018 else 0019 n=1; 0020 end 0021 0022 dim=get(gm.g{1},'dim'); 0023 v=zeros(dim,n); 0024 for i=1:n 0025 v(:,i)=rand(gm.g{RandVector(gm.w)},1); 0026 end 0027 end 0028 |