function New_GM=GrandMean_Updater(Current_Complete_Data, CURRENT_PARS, PRIORS)
%function New_GM=GrandMean_Updater(Current_Complete_Data, CURRENT_PARS, PRIORS)
% Updates the grand mean. 
% INPUTS: Current completed-by-imputation data matrix, current parameter
% values structure, and the Prior structure. 

mean_PRIOR=PRIORS.GM(1);
var_PRIOR=PRIORS.GM(2);

var_Errs_Current=CURRENT_PARS.sigma2;

nu=sum(Current_Complete_Data(:))/var_Errs_Current + mean_PRIOR/var_PRIOR;

Post_var=(numel(Current_Complete_Data)/var_Errs_Current + 1/var_PRIOR)^(-1);

Post_mean=nu*Post_var;

New_GM=Post_mean+sqrt(Post_var)*randn(1);