Hi,
I am experimenting with the PrimeSearch code-bit and I have modified it so that the a, b, and c integers used in the constructor are "really pseudo-random". (I have simply added a CRandom member, randomized it in every call to the constructor and get a, b, and c by assigning them to random.random(13) + 1 (or 7, or 5, respectively)).
Problem is now, that for a set of 10 numbers, I often get the sequence:
10, 9, 8, 7, 6, 5, 4, 3, 2, 1
another favorite (albeit less frequently) seems to be:
2, 3, 4, 5, 6, 7, 8, 9, 10, 1
Is this rather "unshuffled" ordering a problem of the algorithm itself? Could my modifications have lead to the problem (I checked CRandom: those numbers _are_ pseudo random)? What can I do to further enhance entropy?
Thanks for any help!
Philipp
P.s.: Oh and: FANTASTIC book!! I think, I'll buy another copy, so that I can read it twice (and I'm going to tell all my friends --- wait... What friends, hmmm.... ---- Just kidding! Great book!)
P.p.s.: And another thing (I am usually typing faster than I think---that often kills me...): Mr. Mike, you are saying "why use -1 as bad flag when you can have something as elegant as an Optional class?" (or something to that effect) and then you are using -1 as return value if PrimeSearch::GetNext fails?!?! -- Talk about inconsistencies... [irony]And I am sure I am the first to notice and you have never heard of that before...[/irony]
I am experimenting with the PrimeSearch code-bit and I have modified it so that the a, b, and c integers used in the constructor are "really pseudo-random". (I have simply added a CRandom member, randomized it in every call to the constructor and get a, b, and c by assigning them to random.random(13) + 1 (or 7, or 5, respectively)).
Problem is now, that for a set of 10 numbers, I often get the sequence:
10, 9, 8, 7, 6, 5, 4, 3, 2, 1
another favorite (albeit less frequently) seems to be:
2, 3, 4, 5, 6, 7, 8, 9, 10, 1
Is this rather "unshuffled" ordering a problem of the algorithm itself? Could my modifications have lead to the problem (I checked CRandom: those numbers _are_ pseudo random)? What can I do to further enhance entropy?
Thanks for any help!
Philipp
P.s.: Oh and: FANTASTIC book!! I think, I'll buy another copy, so that I can read it twice (and I'm going to tell all my friends --- wait... What friends, hmmm.... ---- Just kidding! Great book!)
P.p.s.: And another thing (I am usually typing faster than I think---that often kills me...): Mr. Mike, you are saying "why use -1 as bad flag when you can have something as elegant as an Optional class?" (or something to that effect) and then you are using -1 as return value if PrimeSearch::GetNext fails?!?! -- Talk about inconsistencies... [irony]And I am sure I am the first to notice and you have never heard of that before...[/irony]
The post was edited 2 times, last by Beren77 ().