,idx) \ y;
           Xmode(i,:) = x';
           Emode(i) = norm(A*x-y)^2;  <span class="comment">% SSD</span>
       <span class="keyword">end</span>

       <span class="comment">% weigh each mode by its probability (via its residual)</span>
       logprob = Emode/(2*noise^2);
       logprob = logprob - min(logprob);
       Pmode = exp(-logprob)/sum(exp(-logprob));

       <span class="comment">% viz all posterior modes</span>
       bar(1:Ns,Pmode);
       title([<span class="string">'case '</span> num2