%% HW8 - Question 1
clear all; close all; clc;
%% Load Data
load('mnist_cluster.mat','Xtrain','Ytrain');

% Xtrain = N x D (Number of images x Features)
% Ytrain = N x 1 (True Labels)
% Obtain true cluster center first for problem d before randomizing
trueCenter = zeros(1,D);
for i = 1:10
    trueCenter(i,:) = mean(Xtrain((i-1)*N+1:i*N, :));
end;

% Randomly permute the data ordering
reset(RandStream.getDefaultStream);
rindx = randperm(size(Xtrain,1));
Xtrain = Xtrain(rindx,:);
Ytrain = Ytrain(rindx,:);

%% problem b) - 
% Write a function to implement kmeans

%%  problem c)
% Generate random center indx for each run
% Run kmeans for 10 random initializations
% Write a function to compute the kmeans score
reset(RandStream.getDefaultStream)

%% problem d) 
% Start from the true cluster center
% Compare to ground truth label by valid_RandIndex (2nd output argument)

%% problem e) 
% Run k-means for K = [5, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]
