Uniform continuous distribution for cycles.

70 Views Asked by At

Let there be $n$ people standing in a circle and holding hands with probability $p$.

What is the expectation value $E(X)$ for the number of 'chains' when $p=.5$?

For what $p$ is $E(X)$ largest?

Edit: a chain is defined by two or more people next to one another holding hands.

1

There are 1 best solutions below

0
On

I made a short python script to run a monte carlo simulation on this. In this, I assumed that if there was a ring (so everyone holds hands), then this would not be a chain. One could do it the other way, but this way means that the number of chains can be counted by counting the number of substrings in the ring that are equal to $T,F$.

enter image description here

Under these conditions it looks like the peak is pretty much at $p=0.5$ for all $n$. In fact the graph looks pretty much exactly like $np(p-1)$, like one of the commenters guessed.

The code, in case you're interested, is here:

#http://math.stackexchange.com/questions/1359692/uniform-continuous-distribution-for-cycles

import pylab as py
import numpy as np

def noChains(hands):
    hands2 = np.zeros(hands.shape,dtype=bool)
    hands2[:,:-1] = hands[:,:-1] & np.logical_not(hands[:,1:])
    hands2[:,-1]  = hands[:,-1]  & np.logical_not(hands[:,0])
    return np.sum(hands2,axis=1)

fig = py.figure()
ax1 = fig.add_subplot(111)

noPs = 50        
ps = np.linspace(0,1,noPs).reshape((noPs,1))
reps = 10000

for n in [1,2,5,10,20,30,40,50,60,70,80,90,100]:
    E = np.zeros(noPs)

    for i in range(reps):
        E += noChains(np.repeat(np.random.random(n).reshape((1,n)),noPs,axis=0)<=ps)
    E = E/reps
    ax1.plot(ps,E,"-")
    ax1.text(ps[25],E[25],"$n=%d$"%n)
    print(n,np.argmax(E),ps[np.argmax(E)],np.max(E))
ax1.set_title("$E(X)$ vs $p$ for various $n$")
ax1.set_xlabel("$p$")
ax1.set_ylabel("$E(X)$")
ax1.set_xlim(0.000000,1.000000)
ax1.set_ylim(0.000000,26.000000)


py.savefig("E vs p for n3.png")