
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%% EE 675 - Fall 2015
%%%% Simple Code to show How to generate simulated data sets 
%%%%
%%%% Things to learn and try:
%%%% 1. Varying group means m1 and m2
%%%% 2. Varying group standard deviations sd1 and sd2
%%%% 3. Varying the above for multi-dimensional space
%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


%%%%%############################## Generate and visualize 1D data sets
Nf= 1;                      % number of features used
Ntrain= 1000;               % number of training samples
Ntest=  1000;               % number of training samples
m1=     100;                % mean of Group 1 samples
m2=     120;                % mean of Group 2 samples
sd1=    10;                 % std dev of Group 1 samples
sd2=    10;                 % std dev of Group 2 samples

%%%%%%%%%%%%%% Generate data
%%%%% x = Features
%%%%% y = Group labels 

%%%%% Generate samples for each group (training and testing samples)
x1_train=   randn(Ntrain,Nf)*sd1 + m1;       % Group 1 training samples
x2_train=   randn(Ntrain,Nf)*sd2 + m2;       % Group 2 training samples
x1_test=    randn(Ntest,Nf)*sd1 + m1;        % Group 1 testing samples
x2_test=    randn(Ntest,Nf)*sd2 + m2;        % Group 2 testing samples

%%%%% Labels for each group
y1_train=   ones(Ntrain,1);                 % Group 1 train label = 1
y1_test=    ones(Ntest,1);                  % Group 1 test label = 1
y2_train=   2*ones(Ntrain,1);               % Group 2 train label = 2
y2_test=    2*ones(Ntest,1);                % Group 2 test label = 2

figure(1);
plot(1:Ntrain, x1_train,'xb', 1:Ntrain, x2_train,'or');
xlabel('Sample');
ylabel('Value');
legend('Class 1','Class 2','Location','best')
title('1-D Simulated Data Set')


%%%%%############################## Generate and visualize 2D data sets
Nf= 2;                      % number of features used
Ntrain= 1000;               % number of training samples
Ntest=  1000;               % number of training samples
m1=     [100 200];          % means of Group 1 samples
m2=     [120 180];           % means of Group 2 samples
sd1=    [10 20];             % std devs of Group 1 samples
sd2=    [20 10];             % std devs of Group 2 samples

%%%%%%%%%%%%%% Generate data
%%%%% x = Features
%%%%% y = Group labels 

%%%%% Generate samples for each group (training and testing samples)
x1_train=   randn(Ntrain,Nf)*diag(sd1) + ones(Ntrain,Nf)*diag(m1);       % Group 1 training samples
x2_train=   randn(Ntrain,Nf)*diag(sd2) + ones(Ntrain,Nf)*diag(m2);       % Group 2 training samples
x1_test=    randn(Ntest,Nf)*diag(sd1) + ones(Ntrain,Nf)*diag(m1);        % Group 1 testing samples
x2_test=    randn(Ntest,Nf)*diag(sd2) + ones(Ntrain,Nf)*diag(m2);        % Group 2 testing samples

figure(2);
plot(x1_train(:,1), x1_train(:,2),'xb', x2_train(:,1), x2_train(:,2),'or');
xlabel('Feature 1');
ylabel('Feature 2');
legend('Class 1','Class 2','Location','best');
title('2-D Simulated Data Set');
 


%%%%%############################## Generate and visualize 3D data sets
Nf= 3;                      % number of features used
Ntrain= 1000;               % number of training samples
Ntest=  1000;               % number of training samples
m1=     [100 200 50];          % means of Group 1 samples
m2=     [120 180 20];           % means of Group 2 samples
sd1=    [10 20 30];             % std devs of Group 1 samples
sd2=    [20 10 15];             % std devs of Group 2 samples

%%%%%%%%%%%%%% Generate data
%%%%% x = Features
%%%%% y = Group labels 

%%%%% Generate samples for each group (training and testing samples)
x1_train=   randn(Ntrain,Nf)*diag(sd1) + ones(Ntrain,Nf)*diag(m1);       % Group 1 training samples
x2_train=   randn(Ntrain,Nf)*diag(sd2) + ones(Ntrain,Nf)*diag(m2);       % Group 2 training samples
x1_test=    randn(Ntest,Nf)*diag(sd1) + ones(Ntrain,Nf)*diag(m1);        % Group 1 testing samples
x2_test=    randn(Ntest,Nf)*diag(sd2) + ones(Ntrain,Nf)*diag(m2);        % Group 2 testing samples

figure(3);
plot3(x1_train(:,1), x1_train(:,2), x1_train(:,3),'xb', x2_train(:,1), x2_train(:,2), x2_train(:,3),'or');
xlabel('Feature 1');
ylabel('Feature 2');
zlabel('Feature 3');
legend('Class 1','Class 2', 'Location','best');
grid on
title('3-D Simulated Data Set');
 


