function P=M_to_P(M)
%marginal frequencies M(1:2^L-1) -> genotype frequencies P(1:2^L-1)
%0 index omitted
N=length(M); %N=2^L-1
P=zeros(N,1); %genotype frequencies
column=uint16(1:N);
for row=uint16(N:-1:1)
    A= column==bitor(column,row);
    P(row)= M(row)- sum(P(A));
end    