1 /***************************************************************************** 2 * * 3 * UNURAN -- Universal Non-Uniform Random number generator * 4 * * 5 ***************************************************************************** 6 * * 7 * FILE: tabl_struct.h * 8 * * 9 * PURPOSE: * 10 * declares structures for method TABL * 11 * (Ahren's TABLe method: piecewise constant hat) * 12 * * 13 ***************************************************************************** 14 * * 15 * Copyright (c) 2000-2006 Wolfgang Hoermann and Josef Leydold * 16 * Department of Statistics and Mathematics, WU Wien, Austria * 17 * * 18 * This program is free software; you can redistribute it and/or modify * 19 * it under the terms of the GNU General Public License as published by * 20 * the Free Software Foundation; either version 2 of the License, or * 21 * (at your option) any later version. * 22 * * 23 * This program is distributed in the hope that it will be useful, * 24 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 26 * GNU General Public License for more details. * 27 * * 28 * You should have received a copy of the GNU General Public License * 29 * along with this program; if not, write to the * 30 * Free Software Foundation, Inc., * 31 * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA * 32 * * 33 *****************************************************************************/ 34 35 /*---------------------------------------------------------------------------*/ 36 /* Information for constructing the generator */ 37 38 struct unur_tabl_par { 39 40 const double *slopes; /* slopes <a_i,b_i>, i.e.\ f(a_i) >= f(b_i) */ 41 int n_slopes; /* number of slopes */ 42 double bleft; /* left border of the domain */ 43 double bright; /* right border of the domain */ 44 45 int max_ivs; /* maximum number of intervals */ 46 double max_ratio; /* limit for ratio r_n = A(squeeze) / A(hat) */ 47 48 const double *cpoints; /* pointer to array of points for constr. slopes */ 49 int n_cpoints; /* number of points for constructing slopes */ 50 int n_stp; /* number of points for hat for start */ 51 double area_fract; /* parameter for equal area rule */ 52 double darsfactor; /* factor for (derandomized) ARS */ 53 54 double guide_factor; /* relative size of guide table */ 55 }; 56 57 /*---------------------------------------------------------------------------*/ 58 /* storing information about generator */ 59 60 struct unur_tabl_interval { 61 62 double xmax; /* maximum of pdf in interval */ 63 double fmax; /* maximal value of pdf in interval */ 64 double xmin; /* minimum of pdf in interval */ 65 double fmin; /* minimal value of pdf in interval */ 66 67 double Ahat; /* area of total bar (below hat) */ 68 double Asqueeze; /* area of bar below squeeze */ 69 double Acum; /* cumulated area of bars */ 70 71 struct unur_tabl_interval *next; /* pointer to next element in list */ 72 73 #ifdef UNUR_COOKIES 74 unsigned cookie; /* magic cookie */ 75 #endif 76 }; 77 78 /*---------------------------------------------------------------------------*/ 79 /* The generator object */ 80 81 struct unur_tabl_gen { 82 double Atotal; /* total area below hat */ 83 double Asqueeze; /* area of squeeze polygon */ 84 85 double bleft; /* left boundary of domain */ 86 double bright; /* right boundary of domain */ 87 88 struct unur_tabl_interval **guide; /* pointer to guide table */ 89 int guide_size; /* size of guide table */ 90 double guide_factor; /* relative size of guide table */ 91 92 double Umin, Umax; /* bounds for iid random variable in respect to 93 the given (truncated) domain of the distr.*/ 94 95 struct unur_tabl_interval *iv; /* pointer to linked list of intervals */ 96 int n_ivs; /* number of intervals */ 97 int max_ivs; /* maximum number of intervals */ 98 double max_ratio; /* limit for ratio r_n = A(squeeze) / A(hat) */ 99 100 double darsfactor; /* factor for (derandomized) ARS */ 101 #ifdef UNUR_ENABLE_INFO 102 int max_ivs_info; /* maximum number of intervals (as given) */ 103 #endif 104 }; 105 106 /*---------------------------------------------------------------------------*/ 107