function Forest = learnForest(X,y,n)
% Forest = learnForest(X,y,n)
%
% X,y labeled examples to train
% n number of trees in the random forest
%
% Trains random forest on samples from X and returns a list of decision trees

Forest={};
if nargin < 2 %if the number of argument is less than 2 return error
	error('Too few input parameters.');
elseif nargin < 3 %if the number of decision trees isn't specified then use the default value 100
	n=100;
end
for i=1:n
	indexes=randsample(1:length(y),length(y),true); %sample indexes with replacement depending on the size of the dataset
	Forest{i}  = learnTree(X(indexes,:), y(indexes)); %train a decision tree on the sampled dataset
end


