% hw2.m
%
% A script for generating datasets data_2C, data_50C, data_1R, data_10R

% Generate data_2C
%
N1 = 400; N2 = 600;
positive_attr = randn(N1,2);
positive_class = ones(N1,1);
%
negative_attr = randn(N2,2) + ones(N2,2);
negative_class = zeros(N2,1);
%
data_2C = [positive_attr positive_class; negative_attr negative_class];
%
% shuffle the data
tmp = rand(N1+N2,1);
[trash,q] = sort(tmp);
data_2C = data_2C(q,:);
%
train_2C = data_2C(1:500,:);
test_2C = data_2C(501:1000,:);
%
save data_2C train_2C test_2C
clear

% Generate data_50C
%
N1 = 400; N2 = 600;
positive_attr = randn(N1,50);
positive_class = ones(N1,1);
%
negative_attr = randn(N2,50);
negative_attr(:,1:2) = negative_attr(:,1:2) + ones(N2,2);
negative_class = zeros(N2,1);
%
data_50C = [positive_attr positive_class; negative_attr negative_class];
%
% shuffle the data
tmp = rand(N1+N2,1);
[trash,q] = sort(tmp);
data_50C = data_50C(q,:);
%
train_50C = data_50C(1:500,:);
test_50C = data_50C(501:1000,:);
%
save data_50C train_50C test_50C
clear

% Generate data_1R
%
N = 200;
attr = randn(N,1);
target = 3.5*ones(N,1) - 2.5*attr + 0.5*randn(N,1);
data_1R = [attr target];
%
train_1R = data_1R(1:100,:);
test_1R = data_1R(101:200,:);
%
save data_1R train_1R test_1R
clear

% Generate data_10R
%
N = 200;
attr = randn(N,10);
target = 3.5*ones(N,1) - 2.5*attr(:,1) + 1.1*attr(:,3) - 2.1*attr(:,10) + 0.5*randn(N,1);
data_10R = [attr target];
%
train_10R = data_10R(1:100,:);
test_10R = data_10R(101:200,:);
%
save data_10R train_10R test_10R
clear