Friday, July 22, 2011

Random Number Generation with RCaller 2.0

Java has two standard libraries for generating random numbers. The java.lang.Math class has a random method with is used for generating uniform distributed random numbers. The second one is the java.util.Random class which has got several functions for generating random numbers. We can draw random numbers from several distribution using the probability integral transform. But R has many internal functions for random number generation from several probability distributions including the gamma, the binomial, the normal etc.


RCaller has a wrapper class, under the package statistics, for generating random number for those distributions. The class statistics. RandomNumberGenerator has these functions:


public double[] randomNormal(int n, double mean, double standardDeviation)
public double[] randomLogNormal(int n, double logmean, double logStandardDeviation) 
public double[] randomUniform(int n, double min, double max) 
public double[] randomBeta(int n, double shape1, double shape2)
public double[] randomCauchy(int n, double location, double scale) 
public double[] randomT(int n, int df) 
public double[] randomChisqyare(int n, int df)
public double[] randomF(int n, int df1, int df2)
public double[] randomPoisson(int n, double lambda) 
public double[] randomBinom(int n, int size, double p)
public double[] randomNegativeBinom(int n, int size, double p)
public double[] randomMultinomial(int n, int size, double p)
public double[] randomGeometric(int n, double p) 
public double[] randomWeibull(int n, double shape, double scale) throws 
public double[] randomHyperGeometric(int amount, int n, int m, int k) 
public double[] randomExponential(int n, double theta) throws Exception 
public double[] randomGamma(int n, double shape, double rate, double scale) 


One can see the usage of class in the Test5 class in the source of RCaller 2.0.
http://code.google.com/p/rcaller/source/browse/RCaller/src/test/Test5.java

No comments:

Post a Comment

Thanks