alpha=0:100/100
nloci=1000
p_teo=runif(nloci) # vector of allele freqs at every SNP in teo synthetic
p_nam=runif(nloci) # vector as above but in NAM
n_syn=40 # size of the sample of the synthetic generation analyzed
alpha=0:100/100 # grid over which to estimate alpha
 # total number of SNPs
surface=as.numeric() # vector of probs in log10 

# so let's fake alpha=0.3
fake_alpha=0.3
p_syn=fake_alpha*p_teo+(1-fake_alpha)*p_nam
obs_count=round(p_syn*n_syn) # vector of observed allele count in SYN for each locus. 

for(locus in 1:1){
  surface=log10(dbinom(obs_count[locus],n_syn,(1-alpha)*p_nam[locus]+p_teo[locus]*alpha))
}

plot(surface~alpha,type="b",pch=19,cex=0.5)
MLE=alpha[which(surface==max(surface))]
abline(v=MLE)
text(x=MLE,y=(max(surface)+min(surface))/2,paste("MLE =",MLE))