Skip to content

Commit 0cafbbd

Browse files
authored
Merge pull request #132 from stan-dev/bugfix/issue_48_3
Added relative tolerance documentation back (Issue #48)
2 parents 8476db1 + c4175ec commit 0cafbbd

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

src/functions-reference/higher-order_functions.Rmd

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -330,11 +330,15 @@ integrator separates parameter values, `theta`, from data values, `x_r`.
330330
### Call to the 1D Integrator
331331

332332
<!-- vector; integrate_1d; (function integrand, real a, real b, real[] theta, real[] x_r, int[] x_i); -->
333+
\index{{\tt \bfseries integrate\_1d }!{\tt (function integrand, real a, real b, real[] theta, real[] x\_r, int[] x\_i): vector}|hyperpage}
334+
335+
`vector` **`integrate_1d`** `(function integrand, real a, real b, real[] theta, real[] x_r, int[] x_i)`<br>\newline
336+
Integrates the integrand from a to b.
333337

334338
<!-- vector; integrate_1d; (function integrand, real a, real b, real[] theta, real[] x_r, int[] x_i), real relative_tolerance); -->
335339
\index{{\tt \bfseries integrate\_1d }!{\tt (function integrand, real a, real b, real[] theta, real[] x\_r, int[] x\_i, real relative\_tolerance): vector}|hyperpage}
336340

337-
`vector` **`integrate\_1d`** `(function integrand, real a, real b, real[] theta, real[] x_r, int[] x_i, real relative_tolerance)`<br>\newline
341+
`vector` **`integrate_1d`** `(function integrand, real a, real b, real[] theta, real[] x_r, int[] x_i, real relative_tolerance)`<br>\newline
338342
Integrates the integrand from a to b with the given relative tolerance.
339343

340344

@@ -355,8 +359,10 @@ The arguments represent
355359
* *`theta`*: parameters only, type `real[]`,
356360
* *`x_r`*: real data only, type `real[]`,
357361
* *`x_i`*: integer data only, type `int[]`.
358-
* *`relative_tolerance`*: relative tolerance for the 1d integrator (recommended default of 1e-8), type `real`, data only.
359362

363+
A `relative_tolerance` argument can optionally be provided for more control over the algorithm:
364+
365+
* *`relative_tolerance`*: relative tolerance for the 1d integrator, type `real`, data only.
360366

361367
#### Return value
362368

src/stan-users-guide/one-dimensional-integrals.Rmd

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ model {
8585
target += log(integrate_1d(normal_density,
8686
left_limit,
8787
positive_infinity(),
88-
{ mu, sigma }, x_r, x_i, 1e-8));
88+
{ mu, sigma }, x_r, x_i));
8989
}
9090
```
9191

@@ -120,9 +120,11 @@ $$
120120
\frac{{|I_{n + 1} - I_n|}}{{|I|_{n + 1}}} < \text{relative tolerance}
121121
$$
122122

123-
Following the Boost library recommendations, a sensible value for the
124-
`relative_tolerance` parameter is the square root of the machine epsilon
125-
of double precision floating point numbers (around `1e-8`).
123+
The `relative_tolerance` parameter can be optionally specified as the
124+
last argument to `integrate_1d`. By default, `integrate_1d` follows the
125+
Boost library recommendation of setting `relative_tolerance` to the square
126+
root of the machine epsilon of double precision floating point numbers
127+
(about `1e-8`).
126128

127129
### Zero-crossing Integrals {#zero-crossing}
128130

0 commit comments

Comments
 (0)