function LD = linkage_disequlibrium(genotype)

%N_loci = size(genotype,1);
N_pop = size(genotype,2);

Pjoint = (genotype*genotype'./4)./N_pop;

Pmarg = sum(genotype./2,2)./N_pop;

LD = Pjoint - Pmarg*Pmarg';

LD(logical(eye(size(LD)))) = 0;


end