[OT] Algorithm question
Ola Fosheim Grøstad via Digitalmars-d
digitalmars-d at puremagic.com
Mon May 1 04:15:28 PDT 2017
On Monday, 1 May 2017 at 11:08:56 UTC, Ola Fosheim Grøstad wrote:
> E.g. find a set of cyclic random generators and break down N
> into a sum of these cycle-sizes, then just keep track of the
> seed for each. If they are 2^N then you could use xor to get
> more randomness between runs.
>
> Also in the algorithms above you need to change the
> probabilities each time you take away one index from a group
> (you don't want to draw from an empty group).
Well, actually, just select the single cyclic generator that is
larger or equal to N, then just redraw if it returns a value >=
N. Duh! Sloppy thinking. I would think you should be able to find
some prime sized ones that will get the next index with an
insignificant number of redraws.
But permutations is the way to go if you want scientific quality.
More information about the Digitalmars-d
mailing list