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