Portfolio Code | Clement Colmerauer
Repositories
Site
Rabbit simulation
Code
Commits
Branches
Tags
Search
Tree:
a20104a
Branches
Tags
master
Rabbit simulation
build
colt
doc
api
cern
jet
random
sampling
RandomSampler.html
initial commit
Clement COLMERAUER
commited
a20104a
at 2024-09-09 10:17:52
RandomSampler.html
Blame
History
Raw
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <!--NewPage--> <HTML> <HEAD> <!-- Generated by javadoc (build 1.4.2_05) on Thu Sep 09 20:36:13 PDT 2004 --> <TITLE> RandomSampler (Colt 1.2.0 - API Specification) </TITLE> <META NAME="keywords" CONTENT="cern.jet.random.sampling.RandomSampler class"> <LINK REL ="stylesheet" TYPE="text/css" HREF="../../../../stylesheet.css" TITLE="Style"> <SCRIPT type="text/javascript"> function windowTitle() { parent.document.title="RandomSampler (Colt 1.2.0 - API Specification)"; } </SCRIPT> </HEAD> <BODY BGCOLOR="white" onload="windowTitle();"> <!-- ========= START OF TOP NAVBAR ======= --> <A NAME="navbar_top"><!-- --></A> <A HREF="#skip-navbar_top" title="Skip navigation links"></A> <TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY=""> <TR> <TD COLSPAN=3 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A NAME="navbar_top_firstrow"><!-- --></A> <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY=""> <TR ALIGN="center" VALIGN="top"> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD> <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="class-use/RandomSampler.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../index-files/index-1.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD> </TR> </TABLE> </TD> <TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM> <b>Colt 1.2.0</b></EM> </TD> </TR> <TR> <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> PREV CLASS <A HREF="../../../../cern/jet/random/sampling/RandomSamplingAssistant.html" title="class in cern.jet.random.sampling"><B>NEXT CLASS</B></A></FONT></TD> <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../../../index.html" target="_top"><B>FRAMES</B></A> <A HREF="RandomSampler.html" target="_top"><B>NO FRAMES</B></A> <SCRIPT type="text/javascript"> <!-- if(window==top) { document.writeln('<A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A>'); } //--> </SCRIPT> <NOSCRIPT> <A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A> </NOSCRIPT> </FONT></TD> </TR> <TR> <TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> SUMMARY: NESTED | <A HREF="#fields_inherited_from_class_cern.colt.PersistentObject">FIELD</A> | <A HREF="#constructor_summary">CONSTR</A> | <A HREF="#method_summary">METHOD</A></FONT></TD> <TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> DETAIL: FIELD | <A HREF="#constructor_detail">CONSTR</A> | <A HREF="#method_detail">METHOD</A></FONT></TD> </TR> </TABLE> <A NAME="skip-navbar_top"></A> <!-- ========= END OF TOP NAVBAR ========= --> <HR> <!-- ======== START OF CLASS DATA ======== --> <H2> <FONT SIZE="-1"> cern.jet.random.sampling</FONT> <BR> Class RandomSampler</H2> <PRE> <A HREF="http://java.sun.com/j2se/1.4/docs/api/java/lang/Object.html" title="class or interface in java.lang">java.lang.Object</A> <IMG SRC="../../../../resources/inherit.gif" ALT="extended by"><A HREF="../../../../cern/colt/PersistentObject.html" title="class in cern.colt">cern.colt.PersistentObject</A> <IMG SRC="../../../../resources/inherit.gif" ALT="extended by"><B>cern.jet.random.sampling.RandomSampler</B> </PRE> <DL> <DT><B>All Implemented Interfaces:</B> <DD><A HREF="http://java.sun.com/j2se/1.4/docs/api/java/lang/Cloneable.html" title="class or interface in java.lang">Cloneable</A>, <A HREF="http://java.sun.com/j2se/1.4/docs/api/java/io/Serializable.html" title="class or interface in java.io">Serializable</A></DD> </DL> <HR> <DL> <DT>public class <B>RandomSampler</B><DT>extends <A HREF="../../../../cern/colt/PersistentObject.html" title="class in cern.colt">PersistentObject</A></DL> <P> Space and time efficiently computes a sorted <i>Simple Random Sample Without Replacement (SRSWOR)</i>, that is, a sorted set of <tt>n</tt> random numbers from an interval of <tt>N</tt> numbers; Example: Computing <tt>n=3</tt> random numbers from the interval <tt>[1,50]</tt> may yield the sorted random set <tt>(7,13,47)</tt>. Since we are talking about a set (sampling without replacement), no element will occur more than once. Each number from the <tt>N</tt> numbers has the same probability to be included in the <tt>n</tt> chosen numbers. <p><b>Problem:</b> This class solves problems including the following: <i> Suppose we have a file containing 10^12 objects. We would like to take a truly random subset of 10^6 objects and do something with it, for example, compute the sum over some instance field, or whatever. How do we choose the subset? In particular, how do we avoid multiple equal elements? How do we do this quick and without consuming excessive memory? How do we avoid slowly jumping back and forth within the file? </i> <p><b>Sorted Simple Random Sample Without Replacement (SRSWOR):</b> What are the exact semantics of this class? What is a SRSWOR? In which sense exactly is a returned set "random"? It is random in the sense, that each number from the <tt>N</tt> numbers has the same probability to be included in the <tt>n</tt> chosen numbers. For those who think in implementations rather than abstract interfaces: <i>Suppose, we have an empty list. We pick a random number between 1 and 10^12 and add it to the list only if it was not already picked before, i.e. if it is not already contained in the list. We then do the same thing again and again until we have eventually collected 10^6 distinct numbers. Now we sort the set ascending and return it.</i> <dt>It is exactly in this sense that this class returns "random" sets. <b>Note, however, that the implementation of this class uses a technique orders of magnitudes better (both in time and space) than the one outlined above.</b> <p><b>Performance:</b> Space requirements are zero. Running time is <tt>O(n)</tt> on average, <tt>O(N)</tt> in the worst case. <h2 align=center>Performance (200Mhz Pentium Pro, JDK 1.2, NT)</h2> <center> <table border="1"> <tr> <td align="center" width="20%">n</td> <td align="center" width="20%">N</td> <td align="center" width="20%">Speed [seconds]</td> </tr> <tr> <td align="center" width="20%">10<sup>3</sup></td> <td align="center" width="20%">1.2*10<sup>3</sup></td> <td align="center" width="20">0.0014</td> </tr> <tr> <td align="center" width="20%">10<sup>3</sup></td> <td align="center" width="20%">10<sup>7</sup></td> <td align="center" width="20">0.006</td> </tr> <tr> <td align="center" width="20%">10<sup>5</sup></td> <td align="center" width="20%">10<sup>7</sup></td> <td align="center" width="20">0.7</td> </tr> <tr> <td align="center" width="20%">9.0*10<sup>6</sup></td> <td align="center" width="20%">10<sup>7</sup></td> <td align="center" width="20">8.5</td> </tr> <tr> <td align="center" width="20%">9.9*10<sup>6</sup></td> <td align="center" width="20%">10<sup>7</sup></td> <td align="center" width="20">2.0 (samples more than 95%)</td> </tr> <tr> <td align="center" width="20%">10<sup>4</sup></td> <td align="center" width="20%">10<sup>12</sup></td> <td align="center" width="20">0.07</td> </tr> <tr> <td align="center" width="20%">10<sup>7</sup></td> <td align="center" width="20%">10<sup>12</sup></td> <td align="center" width="20">60</td> </tr> </table> </center> <p><b>Scalability:</b> This random sampler is designed to be scalable. In iterator style, it is able to compute and deliver sorted random sets stepwise in units called <i>blocks</i>. Example: Computing <tt>n=9</tt> random numbers from the interval <tt>[1,50]</tt> in 3 blocks may yield the blocks <tt>(7,13,14), (27,37,42), (45,46,49)</tt>. (The maximum of a block is guaranteed to be less than the minimum of its successor block. Every block is sorted ascending. No element will ever occur twice, both within a block and among blocks.) A block can be computed and retrieved with method <tt>nextBlock</tt>. Successive calls to method <tt>nextBlock</tt> will deliver as many random numbers as required. <p>Computing and retrieving samples in blocks is useful if you need very many random numbers that cannot be stored in main memory at the same time. For example, if you want to compute 10^10 such numbers you can do this by computing them in blocks of, say, 500 elements each. You then need only space to keep one block of 500 elements (i.e. 4 KB). When you are finished processing the first 500 elements you call <tt>nextBlock</tt> to fill the next 500 elements into the block, process them, and so on. If you have the time and need, by using such blocks you can compute random sets up to <tt>n=10^19</tt> random numbers. <p>If you do not need the block feature, you can also directly call the static methods of this class without needing to construct a <tt>RandomSampler</tt> instance first. <p><b>Random number generation:</b> By default uses <tt>MersenneTwister</tt>, a very strong random number generator, much better than <tt>java.util.Random</tt>. You can also use other strong random number generators of Paul Houle's RngPack package. For example, <tt>Ranecu</tt>, <tt>Ranmar</tt> and <tt>Ranlux</tt> are strong well analyzed research grade pseudo-random number generators with known periods. <p><b>Implementation:</b> after J.S. Vitter, An Efficient Algorithm for Sequential Random Sampling, ACM Transactions on Mathematical Software, Vol 13, 1987. Paper available <A HREF="http://www.cs.duke.edu/~jsv"> here</A>. <P> <P> <DL> <DT><B>Version:</B></DT> <DD>1.1 05/26/99</DD> <DT><B>See Also:</B><DD><A HREF="../../../../cern/jet/random/sampling/RandomSamplingAssistant.html" title="class in cern.jet.random.sampling"><CODE>RandomSamplingAssistant</CODE></A>, <A HREF="../../../../serialized-form.html#cern.jet.random.sampling.RandomSampler">Serialized Form</A></DL> <HR> <P> <!-- ======== NESTED CLASS SUMMARY ======== --> <!-- =========== FIELD SUMMARY =========== --> <A NAME="field_summary"><!-- --></A> <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"> <TD COLSPAN=2><FONT SIZE="+2"> <B>Field Summary</B></FONT></TD> </TR> </TABLE> <A NAME="fields_inherited_from_class_cern.colt.PersistentObject"><!-- --></A> <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> <TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor"> <TD><B>Fields inherited from class cern.colt.<A HREF="../../../../cern/colt/PersistentObject.html" title="class in cern.colt">PersistentObject</A></B></TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD><CODE><A HREF="../../../../cern/colt/PersistentObject.html#serialVersionUID">serialVersionUID</A></CODE></TD> </TR> </TABLE> <!-- ======== CONSTRUCTOR SUMMARY ======== --> <A NAME="constructor_summary"><!-- --></A> <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"> <TD COLSPAN=2><FONT SIZE="+2"> <B>Constructor Summary</B></FONT></TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD><CODE><B><A HREF="../../../../cern/jet/random/sampling/RandomSampler.html#RandomSampler(long, long, long, cern.jet.random.engine.RandomEngine)">RandomSampler</A></B>(long n, long N, long low, <A HREF="../../../../cern/jet/random/engine/RandomEngine.html" title="class in cern.jet.random.engine">RandomEngine</A> randomGenerator)</CODE> <BR> Constructs a random sampler that computes and delivers sorted random sets in blocks.</TD> </TR> </TABLE> <!-- ========== METHOD SUMMARY =========== --> <A NAME="method_summary"><!-- --></A> <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"> <TD COLSPAN=2><FONT SIZE="+2"> <B>Method Summary</B></FONT></TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE> <A HREF="http://java.sun.com/j2se/1.4/docs/api/java/lang/Object.html" title="class or interface in java.lang">Object</A></CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../cern/jet/random/sampling/RandomSampler.html#clone()">clone</A></B>()</CODE> <BR> Returns a deep copy of the receiver.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>static void</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../cern/jet/random/sampling/RandomSampler.html#main(java.lang.String[])">main</A></B>(<A HREF="http://java.sun.com/j2se/1.4/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A>[] args)</CODE> <BR> Tests this class.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE> void</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../cern/jet/random/sampling/RandomSampler.html#nextBlock(int, long[], int)">nextBlock</A></B>(int count, long[] values, int fromIndex)</CODE> <BR> Computes the next <tt>count</tt> random numbers of the sorted random set specified on instance construction and fills them into <tt>values</tt>, starting at index <tt>fromIndex</tt>.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>static void</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../cern/jet/random/sampling/RandomSampler.html#sample(long, long, int, long, long[], int, cern.jet.random.engine.RandomEngine)">sample</A></B>(long n, long N, int count, long low, long[] values, int fromIndex, <A HREF="../../../../cern/jet/random/engine/RandomEngine.html" title="class in cern.jet.random.engine">RandomEngine</A> randomGenerator)</CODE> <BR> Efficiently computes a sorted random set of <tt>count</tt> elements from the interval <tt>[low,low+N-1]</tt>.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>static void</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../cern/jet/random/sampling/RandomSampler.html#test(long, long, long, int, int)">test</A></B>(long n, long N, long low, int chunkSize, int times)</CODE> <BR> Tests the methods of this class.</TD> </TR> </TABLE> <A NAME="methods_inherited_from_class_java.lang.Object"><!-- --></A> <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> <TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor"> <TD><B>Methods inherited from class java.lang.<A HREF="http://java.sun.com/j2se/1.4/docs/api/java/lang/Object.html" title="class or interface in java.lang">Object</A></B></TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD><CODE><A HREF="http://java.sun.com/j2se/1.4/docs/api/java/lang/Object.html#equals(java.lang.Object)" title="class or interface in java.lang">equals</A>, <A HREF="http://java.sun.com/j2se/1.4/docs/api/java/lang/Object.html#getClass()" title="class or interface in java.lang">getClass</A>, <A HREF="http://java.sun.com/j2se/1.4/docs/api/java/lang/Object.html#hashCode()" title="class or interface in java.lang">hashCode</A>, <A HREF="http://java.sun.com/j2se/1.4/docs/api/java/lang/Object.html#notify()" title="class or interface in java.lang">notify</A>, <A HREF="http://java.sun.com/j2se/1.4/docs/api/java/lang/Object.html#notifyAll()" title="class or interface in java.lang">notifyAll</A>, <A HREF="http://java.sun.com/j2se/1.4/docs/api/java/lang/Object.html#toString()" title="class or interface in java.lang">toString</A>, <A HREF="http://java.sun.com/j2se/1.4/docs/api/java/lang/Object.html#wait()" title="class or interface in java.lang">wait</A>, <A HREF="http://java.sun.com/j2se/1.4/docs/api/java/lang/Object.html#wait(long)" title="class or interface in java.lang">wait</A>, <A HREF="http://java.sun.com/j2se/1.4/docs/api/java/lang/Object.html#wait(long, int)" title="class or interface in java.lang">wait</A></CODE></TD> </TR> </TABLE> <P> <!-- ============ FIELD DETAIL =========== --> <!-- ========= CONSTRUCTOR DETAIL ======== --> <A NAME="constructor_detail"><!-- --></A> <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"> <TD COLSPAN=1><FONT SIZE="+2"> <B>Constructor Detail</B></FONT></TD> </TR> </TABLE> <A NAME="RandomSampler(long, long, long, cern.jet.random.engine.RandomEngine)"><!-- --></A><H3> RandomSampler</H3> <PRE> public <B>RandomSampler</B>(long n, long N, long low, <A HREF="../../../../cern/jet/random/engine/RandomEngine.html" title="class in cern.jet.random.engine">RandomEngine</A> randomGenerator)</PRE> <DL> <DD>Constructs a random sampler that computes and delivers sorted random sets in blocks. A set block can be retrieved with method <tt>nextBlock</tt>. Successive calls to method <tt>nextBlock</tt> will deliver as many random numbers as required. <P> <DT><B>Parameters:</B><DD><CODE>n</CODE> - the total number of elements to choose (must be <tt>n >= 0</tt> and <tt>n <= N</tt>).<DD><CODE>N</CODE> - the interval to choose random numbers from is <tt>[low,low+N-1]</tt>.<DD><CODE>low</CODE> - the interval to choose random numbers from is <tt>[low,low+N-1]</tt>. Hint: If <tt>low==0</tt>, then random numbers will be drawn from the interval <tt>[0,N-1]</tt>.<DD><CODE>randomGenerator</CODE> - a random number generator. Set this parameter to <tt>null</tt> to use the default random number generator.</DL> <!-- ============ METHOD DETAIL ========== --> <A NAME="method_detail"><!-- --></A> <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"> <TD COLSPAN=1><FONT SIZE="+2"> <B>Method Detail</B></FONT></TD> </TR> </TABLE> <A NAME="clone()"><!-- --></A><H3> clone</H3> <PRE> public <A HREF="http://java.sun.com/j2se/1.4/docs/api/java/lang/Object.html" title="class or interface in java.lang">Object</A> <B>clone</B>()</PRE> <DL> <DD>Returns a deep copy of the receiver. <P> <DD><DL> <DT><B>Overrides:</B><DD><CODE><A HREF="../../../../cern/colt/PersistentObject.html#clone()">clone</A></CODE> in class <CODE><A HREF="../../../../cern/colt/PersistentObject.html" title="class in cern.colt">PersistentObject</A></CODE></DL> </DD> <DD><DL> <DT><B>Returns:</B><DD>a copy of the receiver.</DL> </DD> </DL> <HR> <A NAME="main(java.lang.String[])"><!-- --></A><H3> main</H3> <PRE> public static void <B>main</B>(<A HREF="http://java.sun.com/j2se/1.4/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A>[] args)</PRE> <DL> <DD>Tests this class. <P> <DD><DL> </DL> </DD> </DL> <HR> <A NAME="nextBlock(int, long[], int)"><!-- --></A><H3> nextBlock</H3> <PRE> public void <B>nextBlock</B>(int count, long[] values, int fromIndex)</PRE> <DL> <DD>Computes the next <tt>count</tt> random numbers of the sorted random set specified on instance construction and fills them into <tt>values</tt>, starting at index <tt>fromIndex</tt>. <p>Numbers are filled into the specified array starting at index <tt>fromIndex</tt> to the right. The array is returned sorted ascending in the range filled with numbers. <P> <DD><DL> <DT><B>Parameters:</B><DD><CODE>count</CODE> - the number of elements to be filled into <tt>values</tt> by this call (must be >= 0).<DD><CODE>values</CODE> - the array into which the random numbers are to be filled; must have a length <tt>>= count+fromIndex</tt>.<DD><CODE>fromIndex</CODE> - the first index within <tt>values</tt> to be filled with numbers (inclusive).</DL> </DD> </DL> <HR> <A NAME="sample(long, long, int, long, long[], int, cern.jet.random.engine.RandomEngine)"><!-- --></A><H3> sample</H3> <PRE> public static void <B>sample</B>(long n, long N, int count, long low, long[] values, int fromIndex, <A HREF="../../../../cern/jet/random/engine/RandomEngine.html" title="class in cern.jet.random.engine">RandomEngine</A> randomGenerator)</PRE> <DL> <DD>Efficiently computes a sorted random set of <tt>count</tt> elements from the interval <tt>[low,low+N-1]</tt>. Since we are talking about a random set, no element will occur more than once. <p>Running time is <tt>O(count)</tt>, on average. Space requirements are zero. <p>Numbers are filled into the specified array starting at index <tt>fromIndex</tt> to the right. The array is returned sorted ascending in the range filled with numbers. <p><b>Random number generation:</b> By default uses <tt>MersenneTwister</tt>, a very strong random number generator, much better than <tt>java.util.Random</tt>. You can also use other strong random number generators of Paul Houle's RngPack package. For example, <tt>Ranecu</tt>, <tt>Ranmar</tt> and <tt>Ranlux</tt> are strong well analyzed research grade pseudo-random number generators with known periods. <P> <DD><DL> <DT><B>Parameters:</B><DD><CODE>n</CODE> - the total number of elements to choose (must be <tt>n >= 0</tt> and <tt>n <= N</tt>).<DD><CODE>N</CODE> - the interval to choose random numbers from is <tt>[low,low+N-1]</tt>.<DD><CODE>count</CODE> - the number of elements to be filled into <tt>values</tt> by this call (must be >= 0 and <=<tt>n</tt>). Normally, you will set <tt>count=n</tt>.<DD><CODE>low</CODE> - the interval to choose random numbers from is <tt>[low,low+N-1]</tt>. Hint: If <tt>low==0</tt>, then draws random numbers from the interval <tt>[0,N-1]</tt>.<DD><CODE>values</CODE> - the array into which the random numbers are to be filled; must have a length <tt>>= count+fromIndex</tt>.<DD><CODE>fromIndex</CODE> - the first index within <tt>values</tt> to be filled with numbers (inclusive).<DD><CODE>randomGenerator</CODE> - a random number generator. Set this parameter to <tt>null</tt> to use the default random number generator.</DL> </DD> </DL> <HR> <A NAME="test(long, long, long, int, int)"><!-- --></A><H3> test</H3> <PRE> public static void <B>test</B>(long n, long N, long low, int chunkSize, int times)</PRE> <DL> <DD>Tests the methods of this class. To do benchmarking, comment the lines printing stuff to the console. <P> <DD><DL> </DL> </DD> </DL> <!-- ========= END OF CLASS DATA ========= --> <HR> <!-- ======= START OF BOTTOM NAVBAR ====== --> <A NAME="navbar_bottom"><!-- --></A> <A HREF="#skip-navbar_bottom" title="Skip navigation links"></A> <TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY=""> <TR> <TD COLSPAN=3 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A NAME="navbar_bottom_firstrow"><!-- --></A> <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY=""> <TR ALIGN="center" VALIGN="top"> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD> <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="class-use/RandomSampler.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../index-files/index-1.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD> </TR> </TABLE> </TD> <TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM> <b>Colt 1.2.0</b></EM> </TD> </TR> <TR> <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> PREV CLASS <A HREF="../../../../cern/jet/random/sampling/RandomSamplingAssistant.html" title="class in cern.jet.random.sampling"><B>NEXT CLASS</B></A></FONT></TD> <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../../../index.html" target="_top"><B>FRAMES</B></A> <A HREF="RandomSampler.html" target="_top"><B>NO FRAMES</B></A> <SCRIPT type="text/javascript"> <!-- if(window==top) { document.writeln('<A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A>'); } //--> </SCRIPT> <NOSCRIPT> <A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A> </NOSCRIPT> </FONT></TD> </TR> <TR> <TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> SUMMARY: NESTED | <A HREF="#fields_inherited_from_class_cern.colt.PersistentObject">FIELD</A> | <A HREF="#constructor_summary">CONSTR</A> | <A HREF="#method_summary">METHOD</A></FONT></TD> <TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> DETAIL: FIELD | <A HREF="#constructor_detail">CONSTR</A> | <A HREF="#method_detail">METHOD</A></FONT></TD> </TR> </TABLE> <A NAME="skip-navbar_bottom"></A> <!-- ======== END OF BOTTOM NAVBAR ======= --> <HR> <font size=-1 >Jump to the <a target=_top href=http://dsd.lbl.gov/~hoschek/colt >Colt Homepage</a> </BODY> </HTML>