function [Btdraw,Qdraw] = drawBmcmc(y,Z,Ht,Qdraw,K,M,t,B_0_prmean,B_0_prvar,Q_prmean,Q_prvar)

[Btdraw,log_lik] = carter_kohn2(y,Z,Ht,Qdraw,K,M,t,B_0_prmean,B_0_prvar);
   
%=====| Draw Q, the covariance of B(t) (from iWishart)  
% Take the SSE in the state equation of B(t)
Btemp = Btdraw(:,2:t) - Btdraw(:,1:t-1);
sse_2 = Btemp*Btemp';   
% ...and subsequently draw Q, the covariance matrix of B(t)
Qinv = inv(sse_2 + Q_prmean);
Qinvdraw = wish(Qinv,t + Q_prvar);
Qdraw = inv(Qinvdraw);  % this is a draw from Q