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

cern.jet.random.tdouble.Hyperbolic Maven / Gradle / Ivy

Go to download

Parallel Colt is a multithreaded version of Colt - a library for high performance scientific computing in Java. It contains efficient algorithms for data analysis, linear algebra, multi-dimensional arrays, Fourier transforms, statistics and histogramming.

The newest version!
/*
Copyright (C) 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 cern.jet.random.tdouble;

import cern.jet.random.tdouble.engine.DoubleRandomEngine;

/**
 * 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 AbstractContinousDoubleDistribution { /** * */ private static final long serialVersionUID = 1L; 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; // The uniform random number generated shared by all static methods. protected static Hyperbolic shared = new Hyperbolic(10.0, 10.0, makeDefaultGenerator()); /** * Constructs a Beta distribution. */ public Hyperbolic(double alpha, double beta, DoubleRandomEngine 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|static * methods. * * @param randomGenerator * the new uniform random number generator to be shared. */ private static void xstaticSetRandomGenerator(DoubleRandomEngine randomGenerator) { synchronized (shared) { shared.setRandomGenerator(randomGenerator); } } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy