genellemeleri için tanımladığınız yöntem . [ 1 .. N ] ' nin tüm permütasyonlarının taraflı bir kalıpla bile eşit derecede olası olduğunu kullanıyoruz (rulolar bağımsız olduğu için). Bu nedenle, son N rulo gibi bir permütasyon görene ve son ruloyu çıkana kadar ilerlemeye devam edebiliriz .N=2[1..N]N
A general analysis is tricky; it is clear, however, that the expected number of rolls grows quickly in N since the probability of seeing a permutation at any given step is small (and not independent of the steps before and after, hence tricky). It is greater than 0 for fixed N, however, so the procedure terminates almost surely (i.e. with probability 1).
For fixed N we can construct a Markov chain over the set of Parikh-vectors that sum to ≤N, summarising the results of the last N rolls, and determine the expected number of steps until we reach (1,…,1) for the first time. This is sufficient since all permutations that share a Parikh-vector are equally likely; the chains and calculations are simpler this way.
Assume we are in state v=(v1,…,vN) with ∑ni=1vi≤N. Then, the probability of gaining an element i (i.e. the next roll is i) is always given by
Pr[gain i]=pi.
On the other hand, the propability of dropping an element i from the history is given by
Prv[drop i]=viN
whenever ∑ni=1vi=N (and 0 otherwise) precisely because all permutations with Parikh-vector v are equally likely. These probabilities are independent (since the rolls are independent), so we can compute the transition probabilities as follows:
Pr[v→(v1,…,vj+1,…,vN)]={Pr[gain j]0,∑v<N, else,Pr[v→(v1,…,vi−1,…vj+1,…,vN)]={0Prv[drop i]⋅Pr[gain j],∑v<N∨vi=0∨vj=N, else andPr[v→v]={0∑vi≠0Prv[drop i]⋅Pr[gain i],∑v<N, else;
all other transition probabilities are zero. The single absorbing state is (1,…,1), the Parikh-vector of all permutations of [1..N].
For N=2 the resulting Markov chain¹ is
[source]
with expected number of steps until absorption
Esteps=2p0p1⋅2+∑i≥3(pi−10p1+pi−11p0)⋅i=1−p0+p20p0−p20,
using for simplification that p1=1−p0. If now, as suggested, p0=12±ϵ for some ϵ∈[0,12), then
Esteps=3+4ϵ21−4ϵ2.
For N≤6 and uniform distributions (the best case) I have performed the calculations with computer algebra²; since the state space explodes quickly, larger values are hard to evaluate. The results (rounded upwards) are
Plots show Esteps as a function of N; to the left a regular and to the right a logarithmic plot.
The growth seems to be exponential but the values are too small to give good estimates.
As for stability against perturbations of the pi we can look at the situation for N=3:
Plot shows Esteps as a function of p0 and p1; naturally, p2=1−p0−p1.
Assuming similar pictures for larger N (kernel crashes computing symbolic results even for N=4), the expected number of steps seems to be quite stable for all but the most extreme choices (almost all or none mass at some pi).
For comparison, simulating an ϵ-biased coin (e.g. by assigning die results to 0 and 1 as evenly as possible), using this to simulate a fair coin and finally performing bit-wise rejection sampling requires at most
2⌈logN⌉⋅3+4ϵ21−4ϵ2
die rolls in expectation -- you should probably stick with that.
- Since the chain is absorbing in (11) the edges hinted at in gray are never traversed and do not influence the calculations. I include them merely for completeness and illustrative purposes.
- Implementation in Mathematica 10 (Notebook, Bare Source); sorry, it's what I know for these kinds of problems.