Table[{n, FindDistribution[RandomSample[
Join @@ Table[ConstantArray[k, Binomial[n, k]], {k, 0, n}]
], TargetFunctions -> "Discrete"]}, {n, 15}] // TableForm
returns this table:
1 BinomialDistribution[1,0.5]
2 BinomialDistribution[2,0.5]
3 BinomialDistribution[4,0.375]
4 BinomialDistribution[5,0.4]
5 BinomialDistribution[6,0.416667]
6 BinomialDistribution[7,0.428571]
7 BinomialDistribution[8,0.4375]
8 BinomialDistribution[8,0.5]
9 BinomialDistribution[10,0.450662]
10 BinomialDistribution[11,0.441601]
11 BinomialDistribution[12,0.461921]
12 BinomialDistribution[12,0.500552]
13 BinomialDistribution[13,0.512226]
14 BinomialDistribution[18,0.384842]
15 BinomialDistribution[16,0.473303]
But in fact the data provided should give in the $n$th row BinomialDistribution[n,0.5]
since the frequencies literally coincide with those corresponding to the probability formula $\binom nk(0.5)^n$. In some cases (for $n=1,2,8,12$) the answer is very close to it, but in many others quite far. Why?
Can one do something to achieve better results?
RandomChoice
rather thanRandomSample
will get you sampling with replacement. (But that's not the only issue here.) $\endgroup$RandomSample
frequencies are as in the "ideal case" - predicted by the PDF: $\binom nk$ copies of $k$, with size of the sample $2^n$. $\endgroup$RandomSample
if it doesn't matter? Also, note that you are attempting to estimate two parameters: $n$ and $p$. $\endgroup$