Ideas on generating seeds for random number generators?

Does anyone here have any ideas or know of any good links to articles that discuss how to generate good seeds for random number generators?
I am aware that I could always probably call SecureRandom.generateSeed as one technique.
The major problem that I have with the above is that I have no idea how any given implementation of SecureRandom works, and whether or not it is any good. (For instance, Sun seems to hide their implementation outside of the normal JDK source tree; must be in one of their semi-proprietary sun packages...)
I thought about the problem a little, and I -think- that the implementation below ought to be OK. The javadocs describe the requirements that I am looking for as well as the implementation. The only issue that still bugs me is that maybe the hash function that I use is not 1-1, and so may not guarantee uniqueness, so I would especially like feedback on that.
Here's the code fragments:
     * A seed value generating function for Random should satisfy these goals:
     * <ol>
     *  <li>be unique per each call of this method</li>
     *  <li>be different each time the JVM is run</li>
     *  <li>be uniformly spread around the range of all possible long values</li>
     * </ol>
     * This method <i>attempts</i> to satisfy all of these goals:
     * <ol>
     *  <li>
     *          an internal serial id field is incremented upon each call, so each call is guaranteed a different value;
     *          this field determines the high order bits of the result
     *  </li>
     *  <li>
     *          each call uses the result of {@link System#nanoTime System.nanoTime}
     *          to determine the low order bits of the result,
     *          which should be different each time the JVM is run (assuming that the system time is different)
     *  </li>
     *  <li>a hash algorithm is applied to the above numbers before putting them into the high and low order parts of the result</li>
     * </ol>
     * <b>Warning:</b> the uniqueness goals cannot be guaranteed because the hash algorithm, while it is of high quality,
     * is not guaranteed to be a 1-1 function (i.e. 2 different input ints might get mapped to the same output int).
     public static long makeSeed() {
          long bitsHigh = ((long) HashUtil.enhance( ++serialNumber )) << 32;
          long bitsLow = HashUtil.hash( System.nanoTime() );
          return bitsHigh | bitsLow;
     }and, in a class called HashUtil:     
     * Does various bit level manipulations of h which should thoroughly scramble its bits,
     * which enhances its hash effectiveness, before returning it.
     * This method is needed if h is initially a poor quality hash.
     * A prime example: {@link Integer#hashCode Integer.hashCode} simply returns the int value,
     * which is an extremely bad hash.     
     public static final int enhance(int h) {
// +++ the code below was taken from java.util.HashMap.hash
// is this a published known algorithm?  is there a better one?  research...
          h += ~(h << 9);
          h ^=  (h >>> 14);
          h +=  (h << 4);
          h ^=  (h >>> 10);
          return h;
     /** Returns a high quality hash for the long arg l. */
     public static final int hash(long l) {
          return enhance(
               (int) (l ^ (l >>> 32))     // the algorithm on this line is the same as that used in Long.hashCode
     }

Correct me if I'm incorrect, but doesn't SecureRandom just access hardware sources entropy? Sources like /dev/random?What do you mean by hardware sources of entropy?
What you really want is some physical source of noise, like voltage fluctuations across a diode, or Johnson noise, or certain radioactive decay processes; see, for example
     http://www.robertnz.net/true_rng.html
     http://ietfreport.isoc.org/idref/draft-eastlake-randomness2/
     this 2nd paper is terrific; see for example this section: http://ietfreport.isoc.org/idref/draft-eastlake-randomness2/#page-9
But is /dev/random equivalent to the above? Of course, this totally depends on how it is implemented; the 2nd paper cited above gives some more discussion:
     http://ietfreport.isoc.org/idref/draft-eastlake-randomness2/#page-34
I am not sure if using inputs like keyboard, mouse, and disk events is quite as secure as, say, using Johnson noise; if my skimming of that paper is correct, he concludes that you need as many different partially random sources as possible, and even then "A hardware based random source is still preferable" (p. 13). But he appears to say that you can still do pretty good with these these sources if you take care and do things like deskew them. For instance, the common linix implementation of /dev/random at least takes those events and does some sophisticated math and hashing to try to further scramble the bits, which is what I am trying to simulate with my hashing in my makeSeed method.
I don't think Java can actually do any better than the time without using JNI. But I always like to be enlightened; is there a way for the JVM to generate some quality entropy?Well, the JVM probably cannot beat some "true" hardware device like diode noise, but maybe it can be as good as /dev/random: if /dev/random is relying on partially random events like keyboard, mouse, and disk events, maybe there are similar events inside the JVM that it could tap into.
Obviously, if you have a gui, you can with java tap into the same mouse and keyboard events as /dev/random does.
Garbage collection events would probably NOT be the best candidate, since they should be somewhat deterministic. (However, note that that paper cited above gives you techniques for taking even very low entropy sources and getting good randomness out of them; you just have to be very careful and know what you are doing.)
Maybe one source of partial randomness is the thread scheduler. Imagine that have one or more threads sleep, and when they wake up put that precise time of wakeup as an input into an entropy pool similar to the /dev/random pool. Each thread would then be put back to sleep after waking up, where its sleep time would also be a random number drawn from the pool. Here, you are hoping that the precise time of thread wakeup is equivalent in its randomness to keyboard, mouse, and disk events.
I wish that I had time to pursue this...

Similar Messages

  • Support for hardware random number generators?

    Can a hardware random number generator be easy integrated into Solaris so that it is accessed via /dev/urandom or /dev/random?
    Hardware Random Number Generators such as (just googling "usb hardware random number generator")
    http://true-random.com/
    http://www.protego.se/
    http://www.araneus.fi/products-alea-eng.html
    http://www.westphal-electronic.de/zranusbe.htm
    Is it possible to have a generic framework which can work with all these devices?

    This is a forum specifically for Java, not Sun products in general. You might try one on the Solaris forums.

  • Multiple Random Number Generators

    I'm writing a program to simulate the tossing of two coins: a nickel and a dime. I want each coin to have its own independently generated set of outcomes. At the core of my logic is a call to one of two random number generators.
    http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Math.html#random() says that "...it may reduce contention for each thread to have its own pseudorandom-number generator." It also makes reference to Random.nextDouble.
    If the first call to random() creates the random number generator, and any subsequent calls to random() supply the next number in the series, what code do I use to setup multiple generators? I want each coin to have its own series.
    What is the need for nextDouble()? Should I be using nextDouble() or random() to get subsequent numbers from these generators?
    Thanks for you help.
    Jim

    Random rnd1 = new Random(7);
    Random rnd2 = new Random(17);Unfortunately, the close seed states will make for
    very closely related sequences from each.And you base that statement on what?Close seeds make for close sequences with lcprng's.
    It's less obvious for these:
    // First ten calls to nextInt()
    -1156638823
    -1149713343
    -1552468968
    -876354855
    -1077308326
    -1299783908
    41356089
    -1761252264
    1495978761
    356293784
    2107132509
    1723477387
    -441191359
    -789258487
    -1105573998
    -46827465
    -1253369595
    190636124
    -1850488227
    -672335679But that's because the generator is 48 bits.
    If you look at sequential seeds you get really bad results...
    // first 50 seeds, [0, 50), one call to nextInt
    0  -1155484576
    1  -1155869325
    2  -1154715079
    3  -1155099828
    4  -1157023572
    5  -1157408321
    6  -1156254074
    7  -1156638823
    8  -1158562568
    9  -1158947317
    10 -1157793070
    11 -1158177819
    12 -1160101563
    13 -1160486312
    14 -1159332065
    15 -1159716814
    16 -1149328594
    17 -1149713343
    18 -1148559096
    19 -1148943845
    20 -1150867590
    21 -1151252339
    22 -1150098092
    23 -1150482841
    24 -1152406585
    25 -1152791334
    26 -1151637087
    27 -1152021836
    28 -1153945581
    29 -1154330330
    30 -1153176083
    31 -1153560832
    32 -1167796541
    33 -1168181290
    34 -1167027043
    35 -1167411792
    36 -1169335537
    37 -1169720286
    38 -1168566039
    39 -1168950788
    40 -1170874532
    41 -1171259281
    42 -1170105035
    43 -1170489784
    44 -1172413528
    45 -1172798277
    46 -1171644030
    47 -1172028779
    48 -1161640559
    49 -1162025308

  • Do random number generators (RNGs) depend on sequential number generation?

    Hi,
    I know that random number generators (RNGs) are guaranteed to be random as N (the number of numbers generated) approaches infinity, but what does the specification say about throwing away the RNG after a single use?
    That is, is there a difference between generating 1000 numbers using the same generator versus generating 1000 generators and reading at one number from each?
    Is there a difference between the normal RNGs and the cryptographically-strong ones for this?
    I ask because I am wondering whether a web server needs to maintain a RNG per client session, or whether it can share a single generator across all clients, or whether it can create a new generator per HTTP request. Does any of this affect how random the resulting numbers will be (from the client point of view, as T approaches infinity)?
    Thank you,
    Gili

    ghstark wrote:
    cowwoc wrote:
    I know that random number generators (RNGs) are guaranteed to be random as N (the number of numbers generated) approaches infinityHow do you know this? it is a challenge just to come up with a formal definition for the "random" in "random number generators".
    Wasn't this covered in your [earlier thread|http://forums.sun.com/thread.jspa?threadID=5320382&messageID=10369834] ?
    You're right, but what bothered me about that thread is that the replies concluded that since there is no practical proof that SecureRandom has a problem that should be good enough. I'm looking for a code sniplet guaranteed by the specification (hence portable across implementations) to generate random numbers. No one has yet to provide such an answer.
    What's to guarantee that if I move to a different platform, vendor or even a different version of Sun's JVM that my code won't magically break? Verifying randomness isn't a trivial matter.

  • Generating N-digit random number??

    Hi All,
    I need to generate N-digit random number, anyone can help me?
    Thx in advance b4...

    import java.util.*;
    public class Try{
         public static void main(String []args){
              for(int i=0;i<100;i++){
                    System.out.println((int)(Math.random() * 10));
    }Yes I saw the casting, no problem with it, but I did used it alot to generate me number between a range of 1 - 9
    and if you want a range of 1 - 10, i just put a
    1+(int)(Math.random() * 10)

  • Help for random number generator???

    hi there can anyone how to make simple random number
    generator for slot machine , formula for chances in probability ,
    or simple random number generator for slot machine , thanks
    :)

    actualy the accurate RNG for slot machine ?? any idea?

  • How to generate a unique random number in a MySQL db

    I'm creating a volunteer and also a separate vendor application form for an airshow. The volunteer and vendor info is stored in separate tables in a MySQL db, one row per volunteer or vendor. There will be about 100 volunteers and 50 vendors. When the application is submitted it should immediately be printed by the applicant, then signed and mailed in. This past year we had problems with some people who didn't immediately print their application so I'd like to still give them the option to immediately print but also send them an e-mail with a link to their specific row in the MySQL db. I have an autoincrement field as the primary key for each table, but I think sending this key to the applicant in an e-mail would be too easy for them to guess another id and access other people's info.
    I'm thinking I should add a column to each table which would contain a unique random number and I would then send this key in the e-mail to the applicant. So, can anyone suggest a simple way to do this or suggest a better way of giving the applicant a way to access their own application and no-one elses after they have submitted their form?
    Thanks all.
    Tony Babb

    Thanks so much, that was very helpful. I added the code you suggested to create and display the random number - I called it "vollink" and that worked fine. Then I added the hidden field toward the bottom of the form - it shows at line 311 when I do a "View Source in Int Explorer and then tried adding the code to add it to the table and when I tested it failed with "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1" . The test version of the page is here www.hollisterairshow.com/volunteerapp2.php . The changes I made to add it to the table is shown below , I must be missing something blindingly obvious, if you could suggest a fix I'd really appreciate it. I did add the field to the MySQL table also.
    Thanks again
    Tony
    $editFormAction = $_SERVER['PHP_SELF'];
    if (isset($_SERVER['QUERY_STRING'])) {
      $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
    if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
      $insertSQL = sprintf("INSERT INTO volunteers (firstname, lastname, email, thursday, friday, saturday, sunday, monday, activity, talents, specialrequests, tshirt, phone, street, city, st, zip, updatedby, vollink) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, $s)",
                           GetSQLValueString($_POST['firstname'], "text"),
                           GetSQLValueString($_POST['lastname'], "text"),
                           GetSQLValueString($_POST['email'], "text"),
                           GetSQLValueString($_POST['thursday'], "text"),
                           GetSQLValueString($_POST['friday'], "text"),
                           GetSQLValueString($_POST['saturday'], "text"),
                           GetSQLValueString($_POST['sunday'], "text"),
                           GetSQLValueString($_POST['monday'], "text"),
                           GetSQLValueString($_POST['activity'], "text"),
                           GetSQLValueString($_POST['specialtalents'], "text"),
                           GetSQLValueString($_POST['specialrequests'], "text"),
                           GetSQLValueString($_POST['tshirt'], "text"),
                           GetSQLValueString($_POST['phone'], "text"),
                           GetSQLValueString($_POST['street'], "text"),
                           GetSQLValueString($_POST['city'], "text"),
                           GetSQLValueString($_POST['st'], "text"),
                           GetSQLValueString($_POST['zip'], "text"),
            GetSQLValueString($_POST['vollink'], "text"),
                           GetSQLValueString($_POST['lastname'], "text"));
      mysql_select_db($database_adminconnection, $adminconnection);
      $Result1 = mysql_query($insertSQL, $adminconnection) or die(mysql_error());

  • Plz help me with random number generators

    cane someone help me write a program that generates 2 random numbers, generates a random operation(+,-,/,*) then ask you for answer, and checks to see if the answer is right, and if not it corrects it for you.
    thank you

    when i do the cases i did the addtion as the first case, and now all i get is addition
    import javax.swing.*;
    import java.text.*;
    import java.util.*;
    public class randomnumbers
         public static void main(String[] arg)
              String input;
              int answer;
              int choice=1;
              Random rand = new Random();
              int num1 = (int) (Math.random()*9+1);
              int num2 = (int) (Math.random()*9+1);
              switch(choice)
                   case 1:System.out.println("What is "+num1+"+"+num2);break;
                   case 2:System.out.println("What is "+num1*'*'*num2);break;
                   default:System.out.println("Illegel Operation");break;          
              input=JOptionPane.showInputDialog("What is the answer?");
              answer=Integer.parseInt(input);
    }

  • RE: Random number keys

    I have a need to generate random number keys for a DB2/6000 database. I am
    expecting 10000 new entries per day to the table and due to design
    constraints need to use an eight digit key. Also for design reasons the key
    on the database is an integer attribute. I have looked at the built in
    random number generator and it only produces a 2 byte number - I need 4.
    Does anyone have a handy routine to produce larger random numbers?
    TIA
    /\/\ark /\/ichols
    "Focus on the QUESTION, not on the ANSWER."
    Lee Wei of Forte contributed a demo called RandomSort to Vol 1. of
    the FShare CDROM. This has some generation code based on the Sedgewick LC
    algorithm that you could probably adapt to your purposes. (e.g. I generated
    8-digit integer values by multiplying Lee Wei's default for MAX by 10).
    You can fiddle with the thing to change the minimum end of the range.
    Robert Sedgewick's Algorithms in C (Addison Wesley 1990) is useful to
    have for this sort of amusement.
    If you don't have access to the FShare 1 CDROM I could send you the
    pex file.
    Regards,
    Stephen Porterfield
    Longs

    There is an excellent book written by Knuth about
    Randon Numbers generator algorithms...
    "The Art of Computer Programming, Donald E. Knuth" -- Vol 2, pp 1-170
    Have a look at these other books if you want more info:
    "Monte Carlo Simulations: Hidden Errors from 'Good' Random Number
    Generators",Physical Review Letters, Alan M.
    Ferrenberg, D. P. Landau, and Y. Joanna Wong, Vol 69 No. 23, Dec 7 1992
    "Monkey Tests for Random Number Generators",Computers Mathematics
    Applications, G Marsaglia, and A Zaman, Vol 26, No
    9 1993, pp 1-10.
    A Current View of Random Number Generators", Computer Science and
    Statistics: 16th Sympossium on Interface, Elsevier,
    1985.
    Hope this helps,
    --francois
    From: Vasas, Marty
    Sent: Thursday, April 10, 1997 8:31 AM
    To: mark h. nichols; forte users
    Subject: RE: Random number keys
    16
    Let's write 2 as twoToThe16th
    If there's nothing built-in to do the job, write a method for the
    following algorithm:
    generate 2 two-byte integers, A and B, from the built-in random number
    generator.
    return A * twoToThe16th + B
    From: mark h. nichols
    Sent: Thursday, April 10, 1997 10:10 AM
    To: forte users
    Cc: vasasm; murthis
    Subject: Random number keys
    MCI Mail date/time: Thu Apr 10, 1997 7:25 am EST
    Source date/time: Thu, 10 Apr 1997 06:37:17 -0500
    I have a need to generate random number keys for a DB2/6000 database. I
    am
    expecting 10000 new entries per day to the table and due to design
    constraints need to use an eight digit key. Also for design reasons the
    key
    on the database is an integer attribute. I have looked at the built in
    random number generator and it only produces a 2 byte number - I need 4.
    Does anyone have a handy routine to produce larger random numbers?
    TIA
    /\/\ark /\/ichols
    "Focus on the QUESTION, not on the ANSWER."

  • Random number keys

    I have a need to generate random number keys for a DB2/6000 database. I am
    expecting 10000 new entries per day to the table and due to design
    constraints need to use an eight digit key. Also for design reasons the key
    on the database is an integer attribute. I have looked at the built in
    random number generator and it only produces a 2 byte number - I need 4.
    Does anyone have a handy routine to produce larger random numbers?
    TIA
    /\/\ark /\/ichols
    "Focus on the QUESTION, not on the ANSWER."

    There is an excellent book written by Knuth about
    Randon Numbers generator algorithms...
    "The Art of Computer Programming, Donald E. Knuth" -- Vol 2, pp 1-170
    Have a look at these other books if you want more info:
    "Monte Carlo Simulations: Hidden Errors from 'Good' Random Number
    Generators",Physical Review Letters, Alan M.
    Ferrenberg, D. P. Landau, and Y. Joanna Wong, Vol 69 No. 23, Dec 7 1992
    "Monkey Tests for Random Number Generators",Computers Mathematics
    Applications, G Marsaglia, and A Zaman, Vol 26, No
    9 1993, pp 1-10.
    A Current View of Random Number Generators", Computer Science and
    Statistics: 16th Sympossium on Interface, Elsevier,
    1985.
    Hope this helps,
    --francois
    From: Vasas, Marty
    Sent: Thursday, April 10, 1997 8:31 AM
    To: mark h. nichols; forte users
    Subject: RE: Random number keys
    16
    Let's write 2 as twoToThe16th
    If there's nothing built-in to do the job, write a method for the
    following algorithm:
    generate 2 two-byte integers, A and B, from the built-in random number
    generator.
    return A * twoToThe16th + B
    From: mark h. nichols
    Sent: Thursday, April 10, 1997 10:10 AM
    To: forte users
    Cc: vasasm; murthis
    Subject: Random number keys
    MCI Mail date/time: Thu Apr 10, 1997 7:25 am EST
    Source date/time: Thu, 10 Apr 1997 06:37:17 -0500
    I have a need to generate random number keys for a DB2/6000 database. I
    am
    expecting 10000 new entries per day to the table and due to design
    constraints need to use an eight digit key. Also for design reasons the
    key
    on the database is an integer attribute. I have looked at the built in
    random number generator and it only produces a 2 byte number - I need 4.
    Does anyone have a handy routine to produce larger random numbers?
    TIA
    /\/\ark /\/ichols
    "Focus on the QUESTION, not on the ANSWER."

  • What algorithm does Excel 2010 use for Pseudo Random Number Generation (MT19937?)

    Does Excel 2010+ use the Mersenne Twister (MT19937) algorithm for Pseudo Random Number Generation (PRNG), implemented by the RAND() function?
    This has been a nagging question for some time now, with "hints" that it indeed does.  However, a relatively thorough search turns up no definitive documentation.  The most direct indication is perhaps given by Guy Melard [Ref 9] where
    he tests Excel 2010's RAND() function using the Crush battery of tests in TestU01 by L'Ecuyer & Simard.  Melard references a "semi-official" indication that Microsoft did indeed implement MT19937 for the RAND() function in
    Excel 2010, but this reference no longer seems to be available. http://office.microsoft.com/enus/excel-help/about-solver-HP005198368.aspx?pid=CH010004571033.
    The other references below [Ref 1-10] document the history of the statistical suitability of the PRNG and probability distributions in various versions of Excel.  This includes the Wichmann-Hill PRNG implementations supposedly (arguably) used in
    Excel 2003 & 2007 for random number generation.  But still, we have no answer as to which PRNG algorithm is used in
    Excel 2010 (and 2013 for that matter).
    Microsoft indicates that RAND() has been improved in Excel 2010; Microsoft states, "...and the RAND function now uses a new random number algorithm." (see https://support.office.com/en-ca/article/Whats-New-Changes-made-to-Excel-functions-355d08c8-8358-4ecb-b6eb-e2e443e98aac). 
    But no details are given on the actual algorithm.  This is critical for Monte Carlo methods and many other applications.
    Any help would be much appreciated. Thanks.
    [Ref 1] B. McCullough, B. Wilson.  On the Accuracy of Statistical Procedures in Microsoft Excel 97. 
    Computational Statistics & Data Analysis. Vol. 31 No. 1, pp 27-37. July 1999.
    http://users.df.uba.ar/cobelli/LaboratoriosBasicos/excel97.pdf
    [Ref 2]L. Knüsel.  On the accuracy of the statistical distributions in Microsoft Excel 97. Computational Statistics & Data Analysis. Vol. 26 No. 3, pp 375-377. January 1998.
    http://www.sciencedirect.com/science/article/pii/S0167947397817562
    [Ref 3]B. McCullough, B. Wilson.  On the Accuracy of Statistical Procedures in Microsoft Excel 2000 and Excel XP. 
    Computational Statistics & Data Analysis. Vol.40 No. 4, pp 713-721. October 2002.
    https://www.researchgate.net/publication/222672996_On_the_accuracy_of_statistical_procedures_in_Microsoft_Excel_2000_and_Excel_XP/links/00b4951c314aac4702000000.pdf
    [Ref 4] B. McCullough, B. Wilson.  On the Accuracy of Statistical Procedures in Microsoft Excel 2003. 
    Computational Statistics & Data Analysis. Vol.49. No. 4, pp 1244-1252. June 2005.
    http://www.pucrs.br/famat/viali/tic_literatura/artigos/planilhas/msexcel.pdf
    [Ref 5] L. Knüsel. On the accuracy of statistical distributions in Microsoft Excel 2003. Computational Statistics & Data Analysis, Vol. 48, No. 3, pp 445-449. March 2005.
    http://www.sciencedirect.com/science/article/pii/S0167947304000337
    [Ref 6]B. McCullough, D.Heiser.  On the Accuracy of Statistical Procedures in Microsoft Excel 2007. 
    Computational Statistics & Data Analysis. Vol.52. No. 10, pp 4570-4578. June 2008.
    http://users.df.uba.ar/mricci/F1ByG2013/excel2007.pdf
    [Ref 7] A. Yalta. The Accuracy of Statistical Distributions in Microsoft<sup>®</sup> Excel 2007. Computational Statistics & Data Anlaysis. Vol. 52 No. 10, pp 4579 – 4586. June 2008.
    http://www.sciencedirect.com/science/article/pii/S0167947308001618
    [Ref 8] B. McCullough.  Microsoft Excel’s ‘Not The Wichmann-Hill’ Random Number Generators. Computational Statistics and Data Analysis. Vol.52. No. 10, pp 4587-4593. June 2008.
    http://www.sciencedirect.com/science/article/pii/S016794730800162X
    [Ref 9] G. Melard.  On the Accuracy of Statistical Procedures in Microsoft Excel 2010. Computational Statistics. Vol.29 No. 5, pp 1095-1128. October 2014.
    http://homepages.ulb.ac.be/~gmelard/rech/gmelard_csda23.pdf
    [Ref 10] L. Knüsel.  On the Accuracy of Statistical Distributions in Microsoft Excel 2010. Department of Statistics - University of Munich, Germany.
    http://www.csdassn.org/software_reports/excel2011.pdf

    I found the same KB article:
    https://support.microsoft.com/en-us/kb/828795
    This was introduced (according to the article) in Excel 2003. Perhaps the references in notes 2 and 3 might help.
    The article describes combining the results of 3 generators, each similar to a Multiply With Carry (MWC) generator, but with zero carry. MWC generators do very well on the Diehard battery of randomness tests (mentioned in your references), and have
    very long periods. But using zero carry makes no sense to me.
    Combining the three generators only helps if the periods of the 3 are relatively prime (despite what the article implies). Then the period of the result will be the product of the 3 periods. But without knowing the theory behind these generators, I have
    no idea what the periods would be. The formulas for MWC generators fail here.
    Richard Mueller - MVP Directory Services

  • Random Number Generator setSeed(); method???

    I've searched and can't get a good understanding of the setSeed() method. I am suppose to use the loop control variable to seed the random number generator inside the loop. I need to use the same input everytime I use the random generator. When I compile it says int cannot be dereferenced.
    for(int i = 0; i < array.length; i++)
    int randnum = generator.nextInt(100);
    randnum.setSeed(i);
    array[i] = randnum;
    If anyone can explain the setSeed() method that would be greatly appreciated. Thanks!

    badbro wrote:
    Thanks for your help, but leave the smart comments to yourself. They are not needed. Thats what this forum is for.All of Paul's comments were dead spot on, and if you listen to him and take his advice to heart, it will only help you. If they make you upset, well then that's your problem, isn't it? My advice: grow up.

  • Favorite random number generator.

    As I hope that not everyone is using the core java API for generating random ints, floats, etc., I was curious what RNG (random number generators) people are using. I am currently using the Mersenne Twister Fast, and have glanced at the RNG in the Colt API. What do you use? What is your favourite RNG?

    I also favor this crisp random number generator, which is adapted to Java from the book "Numerical Recipes in C++".
    http://www.nr.com/cpp-blurb.html
    public class Ran {
                  private int idum;
                 final static int IA = 16807;
         final static int IM = 2147483647;
         final static int IQ = 127773;
         final static int IR = 2836;
         final static int MASK = 123459876;
         final static double AM = 1.0 / (double)IM;
                Ran(){
                    this.idum = (int)(System.currentTimeMillis()%262144L);
                Ran(int n){
                    this.idum = n;
        final public double rand(){
         this.idum ^= MASK;
         int k = this.idum / IQ;
         this.idum = IA*(this.idum - k*IQ) - IR*k;
         if(this.idum < 0){this.idum += IM;}
         double ans = AM*this.idum;
         this.idum ^= MASK;
         return ans;
    }(This is a privately converted version, not published.)

  • Plot xy graph using random number generator

    How do i plot xy graph dynamically every 5 seconds with a random number generator?
    X axis : Time
    Y Axis : Random number generator

    I've done tis so far. im able to plot dynamically every 1 second.
    but the problem i am facing is The X axis display every 1 second.
    i want it to be fixed 24 hours time format, and the data will gradually plots the data on y axis against x axis every one second, without changing the scale of the x axis (24hour time format)

  • Random number in range generator plz help!

    hey hope someone can help me out, im sure its an easy one:
    var tstArray:Array = new Array(1,2,3);
    for (var a:uint=0; a<tstArray.length; a++)
    var x:Number = Math.floor((Math.random()*tstArray[a]));
    trace(x);
    tstArray.splice(a,1);
    i have this code but it doesnt do exectply what i want it to do. Im trying to generate a signle random number per click between 1 and 3 and when all numbers have been used up, remove this click listener.
    if u can help it'll be much appriciated
    thx pavel

    use:
    var fp1:farm_part1=new farm_part1();
    and any time you want to randomize an array use:
    var tstArray:Array = fp1.randomizeF([1,2,3]);
    package
    */import flash.utils.Timer;
    import flash.display.Sprite;
    import flash.events.MouseEvent;
    import flash.display.MovieClip;
    import flash.events.Event;
    import flash.events.*;
    import flash.media.Sound;
    import flash.events.TimerEvent;
    import flash.media.SoundChannel;
    import flash.media.SoundTransform;*/
    public class farm_Part1
    public function randomizeF(a:Array):Array
    {a.shuffle();
    return a;
    ///////////////////////////// change nothing below /////////////////////////////////////////
    function shuffle(a:Array)
    var p:int;
    var t:*;
    var ivar:int;
    for (ivar = a.length-1; ivar>=0; ivar--)
    p=Math.floor((ivar+1)*Math.random());
    t = a[ivar];
    a[ivar] = a[p];
    a[p] = t;
    }//randomAnimal
    }//class
    }//package

Maybe you are looking for

  • Macbook Pro Randomly Crashes w/ Most Recent Crash Report

    Hey, everyone.  Hopefully someone can help me with this one.  Within the last two months, my 15" Macbook Pro has been randomly crashing on me, normally right after a boot up.  I currently have version 10.6.8.  What may happen is that I'll be 5 minute

  • How to create a mail-only user

    In WGM I need to have several users that have access to an e-mail account only, they never should get ftp access (or even terminal SSH, telnet, etc.). So I solved this (at least I think so) by doing the following settings: (1) "Accounts" section, con

  • I have a virus, how do I get rid of it?

    I opened a website and a survey popped up. I didn't think anything of it and answered the survey. Now my Mac has a virus. Almost every webpage I open is bordered with "deal finder" ads and advertisements. How do I get rid of it?

  • Using Acrobat XI - no PDFMaker icon in Internet Explorer

    Why would the PDFMaker icon not show in Internet Explorer -- is it not compatible with 64bit?

  • NLAG and UNBW

    Hi, When we want to order non-stock items we directly create a PO for the item which we require by entering text of the material instead of giving a material number. as we know that for non-stock materials material master is not required. But when we