function [ percVals, gofHvals, gofmse ] = computePercGoF( values, percentile, dist )
    percVals = zeros(size(values, 1), 1);
    gofHvals = zeros(size(values, 1), 1);
    gofmse = zeros(size(values, 1), 1);
    for i = 21:size(values, 1)
        pd = fitdist(squeeze(values(i,:)'), dist);
        [h, p] = chi2gof(squeeze(values(i,:)'),'CDF',pd,'alpha',0.01);
%         [h, p] = lillietest(squeeze(values(i,:)'));
        percVals(i) = icdf(pd, percentile);
        gofHvals(i) = h;
        
%         h = histfit(squeeze(values(i,:)'),50,dist);
%         histdata = get(h(1),'XData');                   % Get Histogram Data
%         redcurve = get(h(2),'YData');                   % Get Fit Data
%         histctrs = mean(histdata);                      % Mean Of Bin Edges
%         redcurve2 = mean(reshape(redcurve, 2, []));     % Mean Of Bin Edges Fit
%         fit_err = histctrs - redcurve2;                 % Error
%         SSE = sum(fit_err.^2);                          % Sum-Squared Error
%         MSE = mean(fit_err.^2);                         % Mean-Squared-Error
%         RMSE = sqrt(MSE);                               % Root-Mean-Squared-Error
%         
%         gofmse(i) = MSE;
    end
end

