Updating mean and standard deviation
Mostrar comentarios más antiguos
Hi
I am working on a project which includes Bayesian inversion. And am working on an idea about updating the prior model iteratively, in a loop.
Here is a simplification of the code that troubles me.
xAll = zeros(4, 400000);
for i = 1:400000
x = randi(5, 4, 1);
xAll(:, i) = x;
mu = mean(xAll, 2);
sigma = std(xAll, 0, 2);
fvec = (mu-x)./sigma;
logprior = -1/2*sum(fvec.^2);
% Then comes lots of other stuff that uses the above, but is not relevant for the time being.
% But normally this section would determine a new "x".
end
When determining the "logprior"-value I need the mean and std of "xAll". This takes time to do over and over again. Do any of you know a way of updating "mu" and "sigma", without recomputing them?
Thanks in advance
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Binomial Distribution en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!