function [X, Y] = dummy_data(n)
% generate a dummy dataset for HW2
%
% Input
%   n: number of data samples
%
% Return
%   X: array of size [n, 2]
%      training data
%   Y: array of size [n, 1]
%      training label, -1 (negative) or 1 (positive)

    n_positive = randi([30, 70], 1)/100;
    n_positive = floor(n*n_positive);
    n_negative = n - n_positive;

    X_positive = sample(n_positive, [20, 60], [40, 80]);
    X_negative = sample(n_negative, [-30, 40], [-20, 70]);
    X = [X_positive; X_negative];

    Y = [ones(n_positive,1); -1*ones(n_negative, 1)];

    idx = randperm(size(Y,1));
    X = X(idx, :);
    Y = Y(idx, :);
end

function rst = sample(num, xrange, yrange)
    X = randi(xrange, num, 1);
    Y = randi(yrange, num, 1);
    rst = [X Y];
end
