Commit in hps-java/src/main/java/org/lcsim/hps/util on MAIN | |||
RandomGaussian.java | +32 | added 1.1 |
Simple class to generate Gaussian distributed numbers with a given mean and standard deviation
diff -N RandomGaussian.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ RandomGaussian.java 27 Aug 2012 19:01:36 -0000 1.1 @@ -0,0 +1,32 @@
+package org.lcsim.hps.util; + +//--- java ---// +import java.util.Random; + +/** + * + * @author Omar Moreno + * @version $Id: RandomGaussian.java,v 1.1 2012/08/27 19:01:36 omoreno Exp $ + */ +public class RandomGaussian { + + private static Random randNumberGenerator; + + /** + * Class shouldn't be instantiated by anyone + */ + private RandomGaussian(){ + } + + /** + * Generates a Gaussian distributed number with given mean and standard deviation + * + * @param mean : Mean of the distribution + * @param sigma : Standard deviation of the distribution + * @return Gaussian distributed number + */ + public static double getGaussian(double mean, double sigma){ + if(randNumberGenerator == null) randNumberGenerator = new Random(); + return mean + randNumberGenerator.nextGaussian()*sigma; + } +}
Use REPLY-ALL to reply to list
To unsubscribe from the LCD-CVS list, click the following link:
https://listserv.slac.stanford.edu/cgi-bin/wa?SUBED1=LCD-CVS&A=1