A point I see, and maybe Paul can comment on this, is that RngPack seems to start providing its functionality at the level of

public double raw();

and not lower down at

public int nextInt();

So, to use an interface based solely on "public int nextInt();" RngPack and other packages may require some refactoring on his part to fit into it.

I personally think that the "public int nextInt();" would be the right place to start off a generic interface because much of the other convenience methods can be built off of it rather generically, all the Service Providers need to supply is the functionality to produce ints.

But, it is probably true that implementing this method on some random generators is difficult or impossible, and this may be a big concern. Some generators may have to invert the process and as such turn the double raw values into other primitive datatypes. That is unless I'm mistaken about this issue.

-Mark



Wolfgang Hoschek wrote:

A RandomGenerator deals in producing 32 bit integers from the uniform distribution, all other stuff belongs into the area of "distributions" and convenience classes. The most minimal interface one needs is something like this (proposal):


/**
 * Interface for uniform pseudo-random number generators.
 */
public interface RandomGenerator  {

/**
* Returns a 32 bit uniformly distributed random number in the closed interval <tt>[Integer.MIN_VALUE,Integer.MAX_VALUE]</tt> (including <tt>Integer.MIN_VALUE</tt> and <tt>Integer.MAX_VALUE</tt>);
*/
public int nextInt();
}


One might want to add a few more convenience methods, although all of these (and others) can be implemented in terms of the interface above:

/**
 * Interface for uniform pseudo-random number generators.
 */
public interface RandomGenerator  {

/**
* Returns a 32 bit uniformly distributed random number in the open unit interval <code>(0.0,1.0)</code> (excluding 0.0 and 1.0).
*/
public double raw();


/**
* Returns a 64 bit uniformly distributed random number in the open unit interval <code>(0.0,1.0)</code> (excluding 0.0 and 1.0).
*/
public double nextDouble();
/**
* Returns a 32 bit uniformly distributed random number in the closed interval <tt>[Integer.MIN_VALUE,Integer.MAX_VALUE]</tt> (including <tt>Integer.MIN_VALUE</tt> and <tt>Integer.MAX_VALUE</tt>);
*/
public int nextInt();
/**
* Returns a 64 bit uniformly distributed random number in the closed interval <tt>[Long.MIN_VALUE,Long.MAX_VALUE]</tt> (including <tt>Long.MIN_VALUE</tt> and <tt>Long.MAX_VALUE</tt>).
*/
public long nextLong();


/**
* Returns a 32 bit uniformly distributed random number in the open unit interval <code>(0.0f,1.0f)</code> (excluding 0.0f and 1.0f).
*/
public float nextFloat();
}



If Paul agrees, perhaps we can all settle on such an interface (or similar). Further, RngPack with BSD license could get back into colt again.


Wolfgang.


-- Mark Diggory Software Developer Harvard MIT Data Center http://osprey.hmdc.harvard.edu

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to