:
Clear[getFrequencies];
Module[{t =
Developer`ToPackedArray[
Table[FromDigits[
Tuples[Transpose[{
PadLeft[IntegerDigits[i, 2], 3],
PadLeft[IntegerDigits[j, 2], 3]}]],
{i, 0, 7}, {j, 0, 7}]
]},
getFrequencies[ind_] :=
With[{extracted =
Partition[
Flatten@Extract[t, Flatten[ind.(2^Range[0, 2]) + 1, 1]],
Ne*8]},
Map[
Sort@Join[
extracted
][[All, All, 2]]/(Ne*8)
]
]
40 . :
In[372]:= Ne=300;np=3^7;
(*This table may be arbitrary with the same shape*)
inds=Table[{{0,0,0},{1,1,1}},{np},{Ne}];
In[374]:=
getFrequencies[inds]
Out[374]= {0.282,{{1/8,1/8,1/8,1/8,1/8,1/8,1/8,1/8},<<2185>>,
{1/8,1/8,1/8,1/8,1/8,1/8,1/8,1/8}}}
In[375]:=
Timing[
gamsInPop=Table[Join@@Table[Tuples@Transpose@inds[[i,j]],{j,1,Ne}],{i,1,np}];
gamFrq=Total[Developer`ToPackedArray[gamsInPop/.Table[allGam[[i]]->
Insert[{0,0,0,0,0,0,0},1,i],{i,1,8}]],{2}]/(8 Ne)
Out[375]= {10.563,{{1/8,1/8,1/8,1/8,1/8,1/8,1/8,1/8},<<2185>>,
{1/8,1/8,1/8,1/8,1/8,1/8,1/8,1/8}}}
, ( ) - ,
In[393]:= fr[[All,{1,5,3,7,2,6,4,8}]] == gamFrq
Out[393]= True
: -, t, : 0 7, , . , , {i,j}, i (), j - , ( {i,j}). , , . :
In[396]:= t
Out[396]
{0,1,2,3,0,1,2,3},{0,0,0,0,4,4,4,4},{0,1,0,1,4,5,4,5},{0,0,2,2,4,4,6,6},
{0,1,2,3,4,5,6,7}},<<6>>,{{7,6,5,4,3,2,1,0},{7,7,5,5,3,3,1,1},{7,6,7,6,3,2,3,2},
<<2>>,{7,7,5,5,7,7,5,5},{7,6,7,6,7,6,7,6},{7,7,7,7,7,7,7,7}}}
() .
Flatten[ind.(2^Range[0, 2]) + 1, 1]] , 1, , t . Extract Flatten Partition . Tally, ( Join[#, Thread[{Complement[Range[0, 7], #[[All, 1]]], 0}]]) Sort . , .
, . . .