All Downloads are FREE. Search and download functionalities are using the official Maven repository.

sim.util.distribution.Hyperbolic Maven / Gradle / Ivy

Go to download

MASON is a fast discrete-event multiagent simulation library core in Java, designed to be the foundation for large custom-purpose Java simulations, and also to provide more than enough functionality for many lightweight simulation needs. MASON contains both a model library and an optional suite of visualization tools in 2D and 3D.

The newest version!
/*
  Copyright � 1999 CERN - European Organization for Nuclear Research.
  Permission to use, copy, modify, distribute and sell this software and its documentation for any purpose 
  is hereby granted without fee, provided that the above copyright notice appear in all copies and 
  that both that copyright notice and this permission notice appear in supporting documentation. 
  CERN makes no representations about the suitability of this software for any purpose. 
  It is provided "as is" without expressed or implied warranty.
*/
package sim.util.distribution;
import ec.util.MersenneTwisterFast;

/**
 * Hyperbolic distribution. 
 * 

* Valid parameter ranges: alpha > 0 and beta > 0. *

* Instance methods operate on a user supplied uniform random number generator; they are unsynchronized. *

* Static methods operate on a default uniform random number generator; they are synchronized. *

* Implementation: *

Method: Non-Universal Rejection. * High performance implementation. *
This is a port of hyplc.c from the C-RAND / WIN-RAND library. * C-RAND's implementation, in turn, is based upon *

* L. Devroye (1986): Non-Uniform Random Variate Generation, Springer Verlag, New York. * * @author [email protected] * @version 1.0, 09/24/99 */ public class Hyperbolic extends AbstractContinousDistribution { private static final long serialVersionUID = 1; protected double alpha; protected double beta; // cached values shared for generateHyperbolic(...) protected double a_setup = 0.0, b_setup = -1.0; protected double x, u, v, e; protected double hr, hl, s, pm, pr, samb, pmr, mpa_1, mmb_1; /** * Constructs a Beta distribution. */ public Hyperbolic(double alpha, double beta, MersenneTwisterFast randomGenerator) { setRandomGenerator(randomGenerator); setState(alpha,beta); } /** * Returns a random number from the distribution. */ public double nextDouble() { return nextDouble(alpha, beta); } /** * Returns a hyperbolic distributed random number; bypasses the internal state. */ public double nextDouble(double alpha, double beta) { /****************************************************************** * * * Hyperbolic Distribution - Non-Universal Rejection * * * ****************************************************************** * * * FUNCTION : - hyplc.c samples a random number from the * * hyperbolic distribution with shape parameter a * * and b valid for a>0 and |b|





© 2015 - 2025 Weber Informatics LLC | Privacy Policy