am P a 2 by R matrix of allele frequencies
r_simplemix = function(n,P){
  R = ncol(P) # number of loci
  z = rep(0,n) # used to store population of origin of each individual
  x = matrix(nrow = n, ncol=R) #used to store genotypes
  
  for(i in 1:n){
    z[i] = sample(1:2, size=1, prob=c(0.5,0.5))
    x[i,] = r_haploid_genotypes(1,P[z[i],])
  }
  return(list(x=x,z=z))
}</code></pre>
<div id="example-1" class="section level3">
<h3>Example</h3>
<p>Here we sample 20 individuals: in one population the frequencie