Quantcast
Channel: random permutation - Stack Overflow
Browsing latest articles
Browse All 10 View Live

Image may be NSFW.
Clik here to view.

Answer by Clark Thomborson for random permutation

See https://doi.org/10.1145/3009909 for a careful analysis of the number of random bits required to generate a random permutation. (It's open-access, but it's not easy reading! Bottom line: if...

View Article



Answer by Pauli for random permutation

Are you sure that your mathematical and algorithmical approach to the problem is correct?I hit exactly same problem where Fisher–Yates shuffle will be bottleneck in corner cases. But for me the real...

View Article

Answer by ShinTakezou for random permutation

Generate N numbers (N < of the number of random number you need) before to do the computation, or store them in an array as data, with your slow but good random generator; then pick up a number...

View Article

Answer by ony for random permutation

Usually there is no need in full-range of next random value, so to use exactly the same amount of randomness you can use next approach (which is almost like random(0,N!), I guess):// ...m = 1; // range...

View Article

Answer by user97370 for random permutation

As other answers suggest, you can make a random integer in the range 0 to N! and use it to produce a shuffle. Although theoretically correct, this won't be faster in general since N! grows fast and...

View Article


Answer by Nikita Rybak for random permutation

Not what you asked exactly, but if provided random number generator doesn't satisfy you, may be you should try something different. Generally, pseudorandom number generation can be very...

View Article

Answer by IVlad for random permutation

Generate a 32 bit integer. For each index i (maybe only up to half the number of elements in the array), if bit i % 32 is 1, swap i with n - i - 1.Of course, this might not be random enough for your...

View Article

Answer by aioobe for random permutation

Generating a random number takes long time you say? The implementation of Javas Random.nextInt is roughlyoldseed = seed;nextseed = (oldseed * multiplier + addend) & mask;return (int)(nextseed...

View Article


Answer by Aryabhatta for random permutation

Create a 1-1 mapping of each permutation to a number from 1 to n! (n factorial). Generate a random number in 1 to n!, use the mapping, get the permutation.For the mapping, perhaps this will be useful:...

View Article


random permutation

I would like to genrate a random permutation as fast as possible.The problem: The knuth shuffle which is O(n) involves generating n random numbers.Since generating random numbers is quite expensive.I...

View Article
Browsing latest articles
Browse All 10 View Live




Latest Images