Posterior mean and mode calculation

Hi.
I can calculate perior mean and perior mode for beta(a,b) and gamma(a,b) distributions and can get their graph in MATLAB. But my question is that how dynare calculate posterior mean and posterior mode of beta and gamma distribution. There are different formulas in the literature for this issue. In a bayesian DSGE estimation model I have three variables including Y C K . Each has 99 observations and therefore we have 297 observations in total and summation of these observations is about 0.1. I have a and b values in beta and gamma distributions, but how dynare calculate posterior mean and posterior mode and posterior variance in the model.

Thank you so much.

The posterior distributions are generate by a posterior sampler, usually the Metropolis-Hastings algorithm as there are no formulas available for the unknown form of the posterior distribution that DSGE models generate.