I have this programming assignment due today (midnight) in my Graduate level Algorithms class. (*I'm NOT looking for advice on the assignment*). I've been able to choose my language all year and, of course, I choose Perl.
I'm producing thousands of largish random integers, by way of calling int(rand(10**12)) thousands of times, to use as test data (as per the assignment).
The assignment is testing various hueristics for the Number Partition problem; basically take a list of numbers and find the best way to break the list into two new lists, each having approximately the same sum (it's NP-Complete).
My problem is that I get a lot of answers for the difference between the two sums that are either 0, 1, (ok so far) or "related to" the value 30,517,579. When I say "related to" I mean that the values are like +/- 10 away from this value when I use the "good" algorithms or close to a multiple of this when I use the bad algorithms (+/- some multiple of 10).
I noticed that 30,517,579 / 10**12 ~= 2**15. Of course, 2**15 is a signed-2-byte-sized integer, which is very suspicious.
I'm running ActivePerl on WinXP, so I feel as if I should blame one or both of them (leaning towards WinXP).
Does anyone have any insight on this? And/Or can anyone point me in the direction of a random number generator that is:
1). As fast (or faster) as rand (i.e. TrulyRandom no good)
2). Can return 10**12-sized values (i.e. not Math::Random)
3). Is Perl and Windows compatible (i.e. no time to fiddle with C or Unix/Linux at this point)
4). Not likely to return foolish data like above
Good luck, right? I'm going to mention the fact that I've consulted experts about this in my write-up.
thanks.
In reply to Rand Wackiness! by SleepyJay
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |