de>1</code> and second row is the allele frequencies for population <code>2</code>. (So element <code>P[k,r]</code> is the frequency of the <code>1</code> alleles in population <code>k</code> at locus <code>r</code>.) For each individual <code>i</code> it randomly samples the population (<code>z[i]</code>) to be 1 or 2, and then uses the <code>r_haploid_genotypes</code> to generate the genotypes (<code>x[i,]</code>) from that population.</p>
<pre class="r"><code>#&#39; @param n number of samples
#&#39; @par