function [pred_dist, pred_cdf, CI1, CI2] = PostPredict(preds_in,data)

preds = preds_in(2:end); %exclude lowest linewidth to make sure preds and dpres are same length

NN = length(data); %number of data points

%mean and mean square of log data
Xbar = sum(log(data))./NN;
X2bar = sum(log(data).^2)./NN;

%paramters of t-distribution
mutilde = Xbar;
nutilde = NN - 1;
sigtilde = sqrt(((NN+1)./(NN-1)).*(X2bar - Xbar.^2));

mumu = mutilde;
numu = nutilde;
sigmu = sqrt((1./(NN-1)).*(X2bar - Xbar.^2));

%calculate pdf values from t-dist
pd_pred = makedist('tLocationScale','mu',mutilde,'sigma',sigtilde,'nu',nutilde);
pd_mu = makedist('tLocationScale','mu',mumu,'sigma',sigmu,'nu',numu);
pred_dist = pdf(pd_pred,log(preds));

%calculate cdf
logdpreds = log(preds_in(2:end)) - log(preds_in(1:end-1));
pred_cdf = cumsum(pred_dist.*logdpreds);

ps = [0.025 0.975];

CI1 = exp(icdf(pd_pred,ps));
CI2 = exp(icdf(pd_mu,ps));

end