1 /*****************************************************************************
2  *                                                                           *
3  *          UNURAN -- Universal Non-Uniform Random number generator          *
4  *                                                                           *
5  *****************************************************************************
6  *                                                                           *
7  *   FILE: hrb.h                                                             *
8  *                                                                           *
9  *   PURPOSE:                                                                *
10  *         function prototypes for method HRB                                *
11  *         (Hazard Rate Bounded)                                             *
12  *                                                                           *
13  *   USAGE:                                                                  *
14  *         only included in unuran.h                                         *
15  *                                                                           *
16  *****************************************************************************
17  *                                                                           *
18  *   Copyright (c) 2000-2006 Wolfgang Hoermann and Josef Leydold             *
19  *   Department of Statistics and Mathematics, WU Wien, Austria              *
20  *                                                                           *
21  *   This program is free software; you can redistribute it and/or modify    *
22  *   it under the terms of the GNU General Public License as published by    *
23  *   the Free Software Foundation; either version 2 of the License, or       *
24  *   (at your option) any later version.                                     *
25  *                                                                           *
26  *   This program is distributed in the hope that it will be useful,         *
27  *   but WITHOUT ANY WARRANTY; without even the implied warranty of          *
28  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the           *
29  *   GNU General Public License for more details.                            *
30  *                                                                           *
31  *   You should have received a copy of the GNU General Public License       *
32  *   along with this program; if not, write to the                           *
33  *   Free Software Foundation, Inc.,                                         *
34  *   59 Temple Place, Suite 330, Boston, MA 02111-1307, USA                  *
35  *                                                                           *
36  *****************************************************************************/
37 
38 /*
39    =METHOD  HRB   Hazard Rate Bounded
40 
41    =UP  Methods_for_CONT
42 
43    =REQUIRED bounded hazard rate
44 
45    =OPTIONAL upper bound for hazard rate
46 
47    =SPEED Set-up: fast, Sampling: slow
48 
49    =REINIT supported
50 
51    =REF  [HLD04: Sect.9.1.4, Alg.9.4]
52 
53    =DESCRIPTION
54       Generates random variate with given hazard rate which must be
55       bounded from above. It uses the thinning method with a constant
56       dominating hazard function.
57 
58    =HOWTOUSE
59       HRB requires a hazard function for a continuous distribution
60       together with an upper bound. The latter has to be set using the
61       unur_hrb_set_upperbound() call. If no such upper bound is given
62       it is assumed that the upper bound can be achieved by evaluating
63       the hazard rate at the left hand boundary of the domain of the
64       distribution. Notice, however, that for decreasing hazard rate
65       the method HRD (@pxref{HRD,,Hazard Rate Decreasing}) is much
66       faster and thus the prefered method.
67 
68       It is important to note that the domain of the distribution can
69       be set via a unur_distr_cont_set_domain() call.
70       However, the left border must not be negative. Otherwise it is
71       set to @code{0}. This is also the default if no domain is
72       given at all. For computational reasons the right border is
73       always set to @code{UNUR_INFINITY} independently of the given
74       domain. Thus for domains bounded from right the function for
75       computing the hazard rate should return @code{UNUR_INFINITY}
76       right of this domain.
77 
78       For distributions with increasing hazard rate method HRI
79       (@pxref{HRI,,Hazard Rate Increasing}) is required.
80 
81       It is possible to change the parameters and the domain of the chosen
82       distribution and run unur_reinit() to reinitialize the generator object.
83       Notice, that the upper bound given by the unur_hrb_set_upperbound() call
84       cannot be changed and must be valid for the changed distribution.
85    =END
86 */
87 
88 /*---------------------------------------------------------------------------*/
89 /* Routines for user interface                                               */
90 
91 /* =ROUTINES */
92 
93 UNUR_PAR *unur_hrb_new( const UNUR_DISTR *distribution );
94 /*
95    Get default parameters for generator.
96 */
97 
98 /*...........................................................................*/
99 
100 int unur_hrb_set_upperbound( UNUR_PAR *parameters, double upperbound );
101 /*
102    Set upper bound for hazard rate. If this call is not used it is
103    assumed that the the maximum of the hazard rate is achieved at the
104    left hand boundary of the domain of the distribution.
105 */
106 
107 int unur_hrb_set_verify( UNUR_PAR *parameters, int verify );
108 /* */
109 
110 int unur_hrb_chg_verify( UNUR_GEN *generator, int verify );
111 /*
112    Turn verifying of algorithm while sampling on/off.
113    If the hazard rate is not bounded by the given bound, then
114    @code{unur_errno} is set to @code{UNUR_ERR_GEN_CONDITION}.
115 
116    Default is FALSE.
117 */
118 
119 /* =END */
120 /*---------------------------------------------------------------------------*/
121