 need finite noise</span>
<span class="keyword">if</span> k0==0, k0 = fix(n/2); <span class="keyword">end</span>;   <span class="comment">% k0 can not be 0</span>
k0 = min([k0 n]);               <span class="comment">% k0 must be &lt;= n</span>

<span class="comment">% single-k  (n-choose-k)  or  all-k  (2^n - 2 patterns)</span>
<span class="keyword">if</span> k &gt; 0, kset = k; <span class="keyword">else</span>, kset = 1:n-1; <span class="keyword">end</span>

<span class="keyword">for</span> kk = kset

  