alt_3_50.m

Show better fit after data swap.
load fly

uniqueTemp = unique(Temperature);
nT = length(uniqueTemp);
meanFacet = nan(nT,1);

for ii = 1:nT
   index = Temperature==uniqueTemp(ii);
   meanFacet(ii) = mean(FacetNumber(index));
end

%  Swap 2 points
temp = meanFacet(5);
meanFacet(5) = meanFacet(6);
meanFacet(6) = temp;

p = polyfit(uniqueTemp(:),meanFacet(:),1);
fitFacet = polyval(p,uniqueTemp);
residual = meanFacet(:)-fitFacet(:);

normalqqplot(residual)