Remy José Cano on Wed, 23 May 2018 08:32:55 +0200 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: Fisher-Yates reverse shuffle is possible? |
Hi, Please ensure you're not using the Sattolo's variant... If it is mandatory to answer right now, the answer is: No. Look, please look the problem is not the seed of a PRNG, The actual question is what you need to achieve by implementing it. Also please consider that small sets of permutations give more chances of getting their elements correclty reversed by guess: =-=-=-=-=-=-=-= For example: =-=-=-=-=-=-=-= N=3, if you pick "randomly" (3,1,2) and apply (2,3,1) to it, you'll get the target or goal: (1,2,3), but then you have ( N! )^2 possible ways (of course few ways are actually correct in such sense); If k <= ( N! )^2, and it represent the number of times you're allowed to *correctly reverse a given permutation... clearly an "almost-reverse" finder becomes "interesting". =-=-=-=-=-=-=-= =-=-=-=-=-=-=-= =-=-=-=-=-=-=-= Good luck. I hope this help. Remy P.S.: I did mean, an inmediate reverse shouldn't be possible if the suffle indeed was made randomly. On 23/05/2018, chandra sekaran <sekar.bc@gmail.com> wrote: > Hi, > > By setting seed number of the random generator, is it possible to write > reverse the shuffle? > > Regards > Chandrasekaran B > > > On Wed, May 23, 2018 at 11:09 AM, Remy José Cano <cano.remy.jose@gmail.com> > wrote: > >> Hi again, >> >> Not much time ago I was intrigued by the same kind of questions >> involving randomness, >> >> I must say that a true FY implementation cannot, *must not* have >> reverse. >> >> Please take a look to https://www.random.org/ >> >> Cheers, >> >> Remy >> >> >> >> On 23/05/2018, Remy José Cano <cano.remy.jose@gmail.com> wrote: >> > Hi, >> > >> > With respect, if something like that were reversible, the undelying >> > process has not to do with randomness (a way of defining random is: >> > The lack of pattern at all). >> > >> > Sorry, as far I know, the answer definitely is NO. >> > >> > In other hand, please notice the code you pasted from Rosetta is NOT >> > optimal, and likely wrong due 1) to place a my() inside a loop, 2) By >> > desing, for using a forstep() where a for() suffices. 2.999999....) a >> > "};" instead of "}" followed by a line break. >> > >> > Cheers, >> > >> > Remy >> > >> > P.S.: Always ensure anywhere wether a function named "random" uses a >> > provably random source of "entropy". >> > >> > >> > On 23/05/2018, chandra sekaran <sekar.bc@gmail.com> wrote: >> >> Fisher-Yates reverse shuffle is possible? >> >> >> >> Following PARI-GP code. from www.rosettacode.org >> >> >> >> FY(v)={ >> >> forstep(n=#v,2,-1, >> >> my(i=random(n)+1,t=v[i]); >> >> v[i]=v[n]; >> >> v[n]=t >> >> ); >> >> v >> >> }; >> >> >> >> (09:56) gp > FY(vector(10,i,i)) >> >> %14 = [2, 10, 7, 4, 5, 1, 9, 8, 3, 6] >> >> (09:56) gp > FY(vector(10,i,i)) >> >> %15 = [2, 8, 1, 5, 9, 3, 7, 4, 6, 10] >> >> (09:56) gp > FY(vector(10,i,i)) >> >> %16 = [8, 7, 2, 5, 4, 10, 6, 9, 3, 1] >> >> (09:56) gp > FY(vector(10,i,i)) >> >> %17 = [10, 4, 2, 5, 7, 3, 6, 9, 1, 8] >> >> >> >> Regards, >> >> Chandrasekaran B >> >> >> > >> > >> > -- >> > _____________________________ >> > >> > Remy José Cano Ramírez >> > 1-43 Entrada principal a Santa Juana. Mérida, ME 5101, Venezuela >> > Phone: +58 412 077 6 077; >> > Page: https://www.oeis.org/wiki/User:R._J._Cano >> > Email: cano.remy.jose@gmail.com >> > >> >> >> -- >> _____________________________ >> >> Remy José Cano Ramírez >> 1-43 Entrada principal a Santa Juana. Mérida, ME 5101, Venezuela >> Phone: +58 412 077 6 077; >> Page: https://www.oeis.org/wiki/User:R._J._Cano >> Email: cano.remy.jose@gmail.com >> > -- _____________________________ Remy José Cano Ramírez 1-43 Entrada principal a Santa Juana. Mérida, ME 5101, Venezuela Phone: +58 412 077 6 077; Page: https://www.oeis.org/wiki/User:R._J._Cano Email: cano.remy.jose@gmail.com