Home > Mateda2.0 > sampling > SampleMixtureofFullGaussianModels.m

# SampleMixtureofFullGaussianModels

## PURPOSE

[NewPop] = SampleMixtureofFullGaussianModels(NumbVar,model,RangeValues,AuxPop,AuxFunVal,sampling_params)

## SYNOPSIS

function [NewPop] = SampleMixtureofFullGaussianModels(NumbVar,model,RangeValues,AuxPop,AuxFunVal,sampling_params)

## DESCRIPTION

      [NewPop] = SampleMixtureofFullGaussianModels(NumbVar,model,RangeValues,AuxPop,AuxFunVal,sampling_params)
     SampleMixtureFullGaussianModels:         Samples a population of individuals from
                                              a mixture of full multivariate Gaussian  model
     INPUTS
     NumbVar: Number of variables
     model: model{1,i} = mean of the variables for solutions in  cluster i
            model{2,i} = covariance of the variables for solutions in cluster i
            model{3,i} = coefficient associated to component i of the mixture
     RangeValues: Matrix of two vectors with the minimum and maximum real values
                  each variable can take
     AuxPop: Auxiliary (selected) population (May be use for partial sampling or resampling)
     AuxFunVal: Evaluation of the data set (required for some sampling algorithms, not for this one)
     sampling_params{1,1} = PopSize: Number of generated individuals
     sampling_params{1,2} = var_scaling: Scaling for the covariance values. A
                            very low variance tends to move the algorith to stagnation. Scaling is a partial
                            solution to this problem. Dynamic scaling should
                            be implemented as a more robust solution
     OUTPUTS
     NewPop: Sampled individuals

     Last version 8/26/2008. Roberto Santana (roberto.santana@ehu.es)

## CROSS-REFERENCE INFORMATION

This function calls:

- sus [Index]=sus(SelCant,Sumvector)

This function is called by:

## SOURCE CODE

    0001 function [NewPop] =  SampleMixtureofFullGaussianModels(NumbVar,model,RangeValues,AuxPop,AuxFunVal,sampling_params)
    0002 %  [NewPop] = SampleMixtureofFullGaussianModels(NumbVar,model,RangeValues,AuxPop,AuxFunVal,sampling_params)
    0003 % SampleMixtureFullGaussianModels:         Samples a population of individuals from
    0004 %                                          a mixture of full multivariate Gaussian  model
    0005 % INPUTS
    0006 % NumbVar: Number of variables
    0007 % model: model{1,i} = mean of the variables for solutions in  cluster i
    0008 %        model{2,i} = covariance of the variables for solutions in cluster i
    0009 %        model{3,i} = coefficient associated to component i of the mixture
    0010 % RangeValues: Matrix of two vectors with the minimum and maximum real values
    0011 %              each variable can take
    0012 % AuxPop: Auxiliary (selected) population (May be use for partial sampling or resampling)
    0013 % AuxFunVal: Evaluation of the data set (required for some sampling algorithms, not for this one)
    0014 % sampling_params{1,1} = PopSize: Number of generated individuals
    0015 % sampling_params{1,2} = var_scaling: Scaling for the covariance values. A
    0016 %                        very low variance tends to move the algorith to stagnation. Scaling is a partial
    0017 %                        solution to this problem. Dynamic scaling should
    0018 %                        be implemented as a more robust solution
    0019 % OUTPUTS
    0020 % NewPop: Sampled individuals
    0021 %
    0022 % Last version 8/26/2008. Roberto Santana (roberto.santana@ehu.es)
    0023
    0024 PopSize = cell2num(sampling_params{1}(1));
    0025 var_scaling = cell2num(sampling_params{1}(2));
    0026
    0027 nclusters = size(model,2);
    0028 for j=1:nclusters
    0029  prob_vector(j) = model{3,j};
    0030 end
    0031 partialsum=cumsum(prob_vector);
    0032
    0033 Index=sus(PopSize,partialsum);  % Individuals to be selected from each cluster
    0034
    0035 for i=1:PopSize,
    0036  vars_means = model{1,Index(i)};
    0037  vars_cov =   var_scaling*model{2,Index(i)};
    0038  NewPop(i,:) = mvnrnd(vars_means,vars_cov);
    0039 end
    0040
    0041 return;