24/04/21 18:25:00.29 KNrj0Rg+.net
>>376
これをWolframで計算させようと思ったのだが、組み合わせを列挙する関数、Rのcombnに相当する方法がみつからなかった。
RLink`を使ってRのcombnを呼び出して使用。
n=30
m=10
a=5
d={-2,1,0,4,1,-3,4,-1,2,4,0,-3,-4,-5,-5,0,5,-4,2,4,-4,3,5,2,-4,2,-1,-3,-5};
da=Accumulate[d];
t1=m - Total[da]/n;
ts=Prepend[da+t1,t1]
Needs["RLink`"]
InstallR[]
combn = REvaluate["combn"];
y=combn[n,a]; (* y=REvaluate["combn(30,5)"] ; *)
nc=Length[y[[1]]]; (* number of comibination *)
re=Mean[Table[ts[[y[[i]][[j]]]],{i,a},{j,nc}]];
Mean[re]
Quantile[re,{0.025,0.5,0.975}]
計算結果
In[25]:= Mean[re]
Out[25]= 10
In[26]:= Quantile[re,{0.025,0.5,0.975}]
32/5 10 68/5
Wolfram言語の使える方の検証希望。