spm_vb_alpha.m 958 B

123456789101112131415161718192021222324252627282930313233
  1. function [block] = spm_vb_alpha(Y,block)
  2. % Variational Bayes for GLM-AR models - Update alpha
  3. % FORMAT [block] = spm_vb_alpha(Y,block)
  4. %
  5. % Y - [T x N] time series
  6. % block - data structure (see spm_vb_glmar)
  7. %__________________________________________________________________________
  8. % Copyright (C) 2005-2014 Wellcome Trust Centre for Neuroimaging
  9. % Will Penny and Nelson Trujillo-Barreto
  10. % $Id: spm_vb_alpha.m 6079 2014-06-30 18:25:37Z spm $
  11. if block.verbose
  12. disp('Updating alpha');
  13. end
  14. N = block.N;
  15. k = block.k;
  16. % Convert from Sigma_n to Sigma_k
  17. for n=1:N
  18. for j=1:k
  19. w_cov_k(n,j) = block.w_cov{n}(j,j);
  20. end
  21. end
  22. for j=1:k
  23. subblock_k = j:k:N*k;
  24. H = sum(spdiags(block.Dw,0).*w_cov_k(:,j)) + block.w_mean(subblock_k)'*block.Dw*block.w_mean(subblock_k);
  25. % Equation 15 in paper VB4
  26. block.b_alpha(j) = 1./(H./2 + 1./block.b_alpha_prior(j));
  27. block.mean_alpha(j) = block.c_alpha(j)*block.b_alpha(j);
  28. end