Home > Mateda2.0 > otherfiles > sus.m

# sus

## PURPOSE

[Index]=sus(SelCant,Sumvector)

## SYNOPSIS

function[Index]=sus(SelCant,Sumvector)

## DESCRIPTION

     [Index]=sus(SelCant,Sumvector)
     sus:  Stocastic Universal Sampling method. Use as an alternative to
           roullete wheel selection to choose a sample of SelCant points according to a distribution for
           different type of samples
     INPUTS
     SelCant: Number of samples
     Sumvector: Cumulative distribution of an original distribution specifying
                the probability associated to each class.
     OUTPUTS
      Index:   Index(i) specifies to which class sample i belongs to, where
               the number of classes is size(Sumvector,2)

     EXAMPLE
             [Index]=sus(10,[0.8,1.0]): Choose 10 samples from two classes.
             The first with probability 0.8, the second with probability 0.2

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

## CROSS-REFERENCE INFORMATION

This function calls:

This function is called by:

- MakeConfObjectivesFormulas [Formulas]=MakeConfObjectivesFormulas(n,m,c,cfixed)
- MakeIndObjectivesFormulas [Formulas]=MakeIndObjectivesFormulas(n,m,c,cfixed,fixedvars)
- MakeRandomFormulas [Formulas]=MakeRandomFormulas(n,m,c)
- MakeVarDepFormulas [Formulas]=MakeVarDepFormulas(n,m,c,relatedvars,ratio)
- SampleFDA [NewPop] = SampleFDA(NumbVar,model,Card,AuxPop,AuxFunVal,sampling_params)
- SampleMixtureofFullGaussianModels [NewPop] = SampleMixtureofFullGaussianModels(NumbVar,model,RangeValues,AuxPop,AuxFunVal,sampling_params)
- SampleMixtureofUnivGaussianModels [NewPop] = SampleMixtureofUnivGaussianModels(NumbVar,model,RangeValues,AuxPop,AuxFunVal,sampling_params)
- exp_selection [SelPop,SelFunVal]=exp_selection(Pop,FunVal,selection_params)
- prop_selection [SelPop,SelFunVal]= prop_selection(Pop,FunVal,selection_params)

## SOURCE CODE

    0001 function[Index]=sus(SelCant,Sumvector)
    0002 % [Index]=sus(SelCant,Sumvector)
    0003 % sus:  Stocastic Universal Sampling method. Use as an alternative to
    0004 %       roullete wheel selection to choose a sample of SelCant points according to a distribution for
    0005 %       different type of samples
    0006 % INPUTS
    0007 % SelCant: Number of samples
    0008 % Sumvector: Cumulative distribution of an original distribution specifying
    0009 %            the probability associated to each class.
    0010 % OUTPUTS
    0011 %  Index:   Index(i) specifies to which class sample i belongs to, where
    0012 %           the number of classes is size(Sumvector,2)
    0013 %
    0014 % EXAMPLE
    0015 %         [Index]=sus(10,[0.8,1.0]): Choose 10 samples from two classes.
    0016 %         The first with probability 0.8, the second with probability 0.2
    0017 %
    0018 % Last version 8/26/2008. Roberto Santana (roberto.santana@ehu.es)
    0019
    0020 aux=rand(1,1);
    0021
    0022 toadd=1/SelCant;
    0023
    0024 cant=1;
    0025
    0026 while cant<=SelCant
    0027  count=1;
    0028   while aux>Sumvector(count)
    0029    count=count+1;
    0030   end
    0031   Index(cant)=count;
    0032   cant=cant+1;
    0033   aux=aux+toadd;
    0034   if aux>1
    0035    aux=aux-1;
    0036   end
    0037 end
    0038
    0039 torandomize = randperm(SelCant);
    0040 Index = Index(torandomize);
    0041 return
    0042