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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.