


[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)

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