/* * gen_beta.h generating beta-distributed random numbers * Copyright (C) 2000 Kevin Karplus * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; * version 2.1 of the License. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * See http://www.gnu.org/copyleft/lesser.html for the license details, * or write to the Free Software Foundation, Inc., 59 Temple Place, Suite * 330, Boston, MA 02111-1307 USA */ /* This is a header file for a random number generator * that generates numbers according to a Beta(aa,bb) distribution. * * Kevin Karplus 3 November 2000 * * The functions here are made to look as much like a C++ class as * is possible in ANSI C. */ #ifndef GENBETAH #define GENBETAH 1 class gen_beta { private: double a,b; /* the parameters of the beta distribution */ /* The remaining fields are precomputed values that can * save some computation when many numbers are drawn from the * same distribution. */ double min_ab, max_ab; /* min(a,b) and max(a,b) */ double sum_ab; /* a+b */ double param[3]; /* various precomputed parameters, * different for each generation method */ public: gen_beta(double aa=1.0, double bb=1.0) { initialize(aa,bb); } void initialize(double aa, double bb); double generate(void) const; }; // CHANGE LOG: // Wed Jul 20 15:25:20 PDT 2005 Kevin Karplus // Changed from C to C++ #endif