load supreme_agree.dat
inperm = [1 2 3 4 5 6 7 8 9];
proxpermut = supreme_agree(inperm,inperm);
[fit,diff,coord] = linfit(proxpermut,1:9)
[monprox,vaf,diff] = proxmon(proxpermut,fit)
sumfitsq = sum(sum(fit.^2));

for i = 1:100
    
    [fit,diff,coord] = linfit(monprox,1:9);
    
    sumnewfitsq = sum(sum(fit.^2));
    
    fit = sqrt(sumfitsq)*(fit/sumnewfitsq);
    
    [monprox,vaf,diff] = proxmon(proxpermut,fit);
    
end

fit
coord
vaf
diff
monprox


disparities = squareform(monprox);

dissimilarities = squareform(proxpermut);

distances = squareform(fit);

[dum, ord] = sortrows([disparities(:) dissimilarities(:)]);

plot(dissimilarities, distances, 'bo', dissimilarities(ord),disparities(ord),'r.-')

xlabel('Dissimilarities')

ylabel('Distances/Disparities')

legend({'Distances' 'Disparities'},'Location','NorthWest');




    