
Problem 2
How many time do we need to toss to estimate the fairness of a coin?
Checking whether a coin is fair
Problem 1
The expectation times of sampling to get a number twice from a discrete uniform distribution .
denotes the probability that are distinct numbers, and .
Solution
Expectation:
where
Variance:
I don’t find a good way to calculate it yet.
pr[x_,n_] := x * Product[(n-i), {i, 0, x - 1}] / n^(x+1)
en1[n_] := Sum[i * pr[i, n], {i, 1, n}]
ens1[n_] := Sum[i * i * pr[i, n], {i, 1, n}]
prlist[n_] := NestList[{#[[1]] + 1, (#[[1]] + 1) / n * (n - #[[1]]) / #[[1]] * #[[2]]} &, {1, 1/n}, n - 1]
en2[n_] := Total[Apply[Times, prlist[n], {1}]]
ens2[n_] := Total[Apply[Function[{a,b}, a*a*b], prlist[n], {1}]]
en[n_] := (E/n)^n * Gamma[n+1,n] - 1
varn[n_] := ens2[n] - en[n]^2
N[en[10], 10]
N[en[100], 10]
N[en[200], 10]
N[varn[10], 10]
N[varn[100], 10]
N[varn[200], 10]
cdf[n_,p_] :=
Catch[
Fold[
Function[{s, x}, Print[{x[[1]],N[x[[2]] + s]}];
If[x[[2]] + s >= p,
Throw[x[[1]]],
s + x[[2]]]],
0, prlist[n]]]
cdf[1000, 0.99]
Problem 0
Sample numbers without replacement from . Let . Find and .
Solution
en := m/(n+m) * Sum[i, {i,1,n+m}]
ens := m/(n+m) * Sum[i^2, {i, 1, n+m}] + m(m-1)/((m+n)(n+m-1)) * Sum[Sum[2*i*j, {j, i+1, n+m}], {i,1,n+m-1}]
varn := Simplify[ens - en^2]




近期评论