ele frequencies
#&#39; @param x an R vector of genotypes
likelihood = function(p,x){
  return(prod(p^x*(1-p)^(1-x)))
}

#&#39; normalize a vector, x, so it&#39;s elements sum to 1
#&#39; @param x a vector
normalize = function(x){x/sum(x)}

#&#39; Compute posterior assignment probabilities
#&#39; @param x an n by R matrix of genotypes
#&#39; @param P a 2 by R matrix of allele frequencies
#&#39; @param w a 2-vector of prior probabilities
posterior_prob_assignment=function(x,P,w){
  n = nrow(x)
  K = length(w)