spm_LAP_pg.m 742 B

12345678910111213141516171819202122232425262728
  1. function p = spm_LAP_pg(x,v,h,M);
  2. % default precision function for LAP models (hidden states)
  3. % FORMAT p = spm_LAP_pg(x,v,h,M);
  4. %
  5. % x - hidden states
  6. % v - causal states
  7. % h - precision parameters
  8. %__________________________________________________________________________
  9. % Copyright (C) 2008 Wellcome Trust Centre for Neuroimaging
  10. % Karl Friston
  11. % $Id: spm_LAP_pg.m 3694 2010-01-22 14:16:51Z karl $
  12. % fixed components
  13. %--------------------------------------------------------------------------
  14. p = sparse(M.n,1);
  15. try
  16. W = diag(M.W);
  17. if all(W)
  18. p = log(W);
  19. end
  20. end
  21. % free components
  22. %--------------------------------------------------------------------------
  23. for i = 1:length(M.R)
  24. p = p + h(i)*diag(M.R{i});
  25. end