#C11.txt, Oct. 13, 2016 Help:=proc() print(` Roulette(L) , Snk(n,k) , RSPnk(n,k), Grab(pi,i) , PtoC(pi) `): end: #Inputs a list of pos. integers L, and outputs an integer from 1 to nops(L) #such that the prob. of getting i is L[i]/convert(L,`+`): Roulette:=proc(L) local r,N,i,j: N:=convert(L,`+`): r:=rand(1..N)(): for i from 1 to nops(L) while add(L[j],j=1..i)i do C:=[op(C),j]: j:=pi[j]: od: C: i1:=min[index](C): [op(i1..nops(C),C),op(1..i1-1,C)]: end: PtoC:=proc(pi) local C, S,LO: LO:={seq(i,i=1..nops(pi))}: S:={}: while LO<>{} do C:=Grab(pi,LO[1]): S:=S union {C}: LO:=LO minus {op(C)}: od: S: end: