Home > Mateda2.0 > sampling > SampleFDA.m

SampleFDA

PURPOSE ^

[NewPop] = SampleFDA(NumbVar,model,Card,AuxPop,AuxFunVal,sampling_params)

SYNOPSIS ^

function [NewPop] = SampleFDA(NumbVar,model,Card,AuxPop,AuxFunVal,sampling_params)

DESCRIPTION ^

 [NewPop] = SampleFDA(NumbVar,model,Card,AuxPop,AuxFunVal,sampling_params)
 SampleFDA:         Samples a population of individuals from a factorized model
 INPUTS
 NumbVar:   Number of variables
 model:     Markov network model containing the structure (model{1} = Cliques)
            and the parameters (model{2} = Tables)
 Card:      Vector with the dimension of all the variables. 
 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) = N: Number of generated individuals 
 OUTPUTS
 NewPop: Sampled individuals

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

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [NewPop] = SampleFDA(NumbVar,model,Card,AuxPop,AuxFunVal,sampling_params)
0002 % [NewPop] = SampleFDA(NumbVar,model,Card,AuxPop,AuxFunVal,sampling_params)
0003 % SampleFDA:         Samples a population of individuals from a factorized model
0004 % INPUTS
0005 % NumbVar:   Number of variables
0006 % model:     Markov network model containing the structure (model{1} = Cliques)
0007 %            and the parameters (model{2} = Tables)
0008 % Card:      Vector with the dimension of all the variables.
0009 % AuxPop:    Auxiliary (selected) population (May be use for partial sampling or resampling)
0010 % AuxFunVal: Evaluation of the data set (required for some sampling algorithms, not for this one)
0011 % sampling_params{1}(1) = N: Number of generated individuals
0012 % OUTPUTS
0013 % NewPop: Sampled individuals
0014 %
0015 % Last version 8/26/2008. Roberto Santana (roberto.santana@ehu.es)
0016 
0017 N = cell2num(sampling_params{1}(1)); 
0018 
0019 Cliques = model{1};
0020 Tables = model{2};
0021 NumberCliques = size(Cliques,1);
0022 
0023 
0024  NewPop=zeros(N,NumbVar);
0025 
0026  % The new population is generated
0027  
0028  for i=1:NumberCliques
0029   eval(['aux = Tables{',num2str(i),'};']);
0030   sizeCliqOther = Cliques(i,2);
0031   sizeCliqSolap = Cliques(i,1);
0032  
0033 
0034   if(sizeCliqSolap > 0)
0035     CliqSolap = Cliques(i,3:Cliques(i,1)+2);
0036     AccCardSolap = FindAccCard(sizeCliqSolap,Card(CliqSolap));
0037     dimSolap =   NumconvertCard(Card(CliqSolap)-1,sizeCliqSolap,AccCardSolap)+1;
0038   else 
0039     CliqSolap = [];
0040     AccCardSolap = [];
0041     dimSolap = 1;
0042   end
0043    
0044   CliqOther = Cliques(i,Cliques(i,1)+3:Cliques(i,1)+Cliques(i,2)+2);
0045   AccCardOther = FindAccCard(sizeCliqOther,Card(CliqOther));
0046   dimOther =   NumconvertCard(Card(CliqOther)-1,sizeCliqOther,AccCardOther)+1;
0047 
0048   AllVars = [CliqSolap,CliqOther];
0049 
0050   if sizeCliqSolap==0          % If it is a root node
0051      index=sus(N,cumsum(aux)); % Values are chosen using SUS
0052      for j=1:N
0053        allvarvalues = IndexconvertCard(index(j)-1,sizeCliqOther,AccCardOther);
0054        NewPop(j,CliqOther) = allvarvalues;
0055      end
0056   else
0057 
0058       auxNewPop=NewPop(:,CliqSolap);
0059 
0060       % For each of the overlappings, non-overlapped variables are
0061       % assigned its values using SUS
0062     
0063       for k=1:dimSolap
0064                 solapval = IndexconvertCard(k-1,sizeCliqSolap,AccCardSolap);
0065             % which stores all the individuals for which the overlapping
0066             % has the same value k-1
0067               
0068                
0069         if sizeCliqSolap==1
0070          which=find( (auxNewPop==repmat(solapval,N,1)) == sizeCliqSolap);
0071         else
0072          which=find(sum((auxNewPop==repmat(solapval,N,1))') == sizeCliqSolap)';
0073         end
0074 
0075         % In index are stored the values that will be assigned to non-overlapped
0076         % variables whose overlapping is k
0077 
0078          if size(which,1)>0
0079           % It might be normalize before generation
0080           %aux(k,:)=aux(k,:)/sum(aux(k,:));
0081           index=sus(size(which,1),cumsum(aux(k,:)));
0082           for j=1:size(which,1)
0083                           solapval = IndexconvertCard(index(j)-1,sizeCliqOther,AccCardOther);
0084               NewPop(which(j),CliqOther)=solapval;
0085           end
0086          end    
0087      end         % End del for de la variabla k
0088     end          % End del Else
0089   end            % End del for de la variable i
0090 
0091    
0092  
0093  
0094 % Last version 10/05/2005. Roberto Santana (rsantana@si.ehu.es)

Generated on Fri 04-Dec-2009 13:38:29 by m2html © 2003