-
-
Notifications
You must be signed in to change notification settings - Fork 128
Expand file tree
/
Copy pathdeprecated_functions.Rmd
More file actions
275 lines (182 loc) · 13.4 KB
/
deprecated_functions.Rmd
File metadata and controls
275 lines (182 loc) · 13.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
# Deprecated Functions
This appendix lists currently deprecated functionality along with how to
replace it.
Starting in Stan 2.29, deprecated functions with drop in replacements (such as
the renaming of `get_lp` or `multiply_log`) will be removed 3 versions later
e.g., functions deprecated in Stan 2.20 will be removed in Stan 2.23 and placed
in [Removed Functions]. The Stan compiler can
[automatically update](https://mc-stan.org/docs/stan-users-guide/stanc-pretty-printing.html)
these on the behalf of the user.
## `multiply_log` and `binomial_coefficient_log` functions
*Deprecated*: Currently two non-conforming functions ending in suffix
`_log`.
*Replacement*: Replace `multiply_log(...)` with `lmultiply(...)`.
Replace `binomial_coefficient_log(...)` with `lchoose(...)`.
*Scheduled Removal*: Stan 2.32
## `get_lp()` function
*Deprecated*: The built-in no-argument function `get_lp()` is deprecated.
*Replacement*: Use the no-argument function `target()` instead.
*Scheduled Removal*: Stan 2.32
## `abs(real x)` function
*Deprecated*: Use of the `abs` function with real-valued arguments
is deprecated; use functions `fabs` instead.
## Integer division with `operator/`
*Deprecated*: Using `/` with two integer arguments is interpreted as integer
floor division, such that
$$ 1 / 2 = 0 $$
This is deprecated due to its confusion with real-valued division, where
$$ 1.0 / 2.0 = 0.5 $$
*Replacement*: Use the integer division operator `operator%/%` instead.
## integrate_ode_rk45, integrate_ode_adams, integrate_ode_bdf ODE Integrators {#functions-old-ode-solver}
These ODE integrator functions have been replaced by those described in:
```{r results='asis', echo=FALSE}
if (knitr::is_html_output()) {
cat(' * <a href="functions-ode-solver.html">Ordinary Differential Equation (ODE) Solvers</a>\n')
}
```
### Specifying an ordinary differential equation as a function
A system of ODEs is specified as an ordinary function in Stan within
the functions block. The ODE system function must have this function
signature:
```stan
array[] real ode(real time, array[] real state, array[] real theta,
array[] real x_r, array[] int x_i);
```
The ODE system function should return the derivative of the state with
respect to time at the time provided. The length of the returned real
array must match the length of the state input into the function.
The arguments to this function are:
* *`time`*, the time to evaluate the ODE system
* *`state`*, the state of the ODE system at the time specified
* *`theta`*, parameter values used to evaluate the ODE system
* *`x_r`*, data values used to evaluate the ODE system
* *`x_i`*, integer data values used to evaluate the ODE system.
The ODE system function separates parameter values, *`theta`*, from
data values, *`x_r`*, for efficiency in computing the gradients of the
ODE.
### Non-stiff solver
<!-- array[,] real; integrate_ode_rk45; (function ode, array[] real initial_state, real initial_time, array[] real times, array[] real theta, array[] real x_r, array[] int x_i); -->
\index{{\tt \bfseries integrate\_ode\_rk45 }!{\tt (function ode, array[] real initial\_state, real initial\_time, array[] real times, array[] real theta, array[] real x\_r, array[] int x\_i): array[,] real}|hyperpage}
`array[,] real` **`integrate_ode_rk45`**`(function ode, array[] real initial_state, real initial_time, array[] real times, array[] real theta, array[] real x_r, array[] int x_i)`<br>\newline
Solves the ODE system for the times provided using the Dormand-Prince
algorithm, a 4th/5th order Runge-Kutta method.
`r since("2.10, deprecated in 2.24")`
<!-- array[,] real; integrate_ode_rk45; (function ode, array[] real initial_state, real initial_time, array[] real times, array[] real theta, array[] real x_r, array[] int x_i, real rel_tol, real abs_tol, int max_num_steps); -->
\index{{\tt \bfseries integrate\_ode\_rk45 }!{\tt (function ode, array[] real initial\_state, real initial\_time, array[] real times, array[] real theta, array[] real x\_r, array[] int x\_i, real rel\_tol, real abs\_tol, int max\_num\_steps): array[,] real}|hyperpage}
`array[,] real` **`integrate_ode_rk45`**`(function ode, array[] real initial_state, real initial_time, array[] real times, array[] real theta, array[] real x_r, array[] int x_i, real rel_tol, real abs_tol, int max_num_steps)`<br>\newline
Solves the ODE system for the times provided using the Dormand-Prince
algorithm, a 4th/5th order Runge-Kutta method with additional control
parameters for the solver.
`r since("2.10, deprecated in 2.24")`
<!-- array[,] real; integrate_ode; (function ode, array[] real initial_state, real initial_time, array[] real times, array[] real theta, array[] real x_r, array[] int x_i); -->
\index{{\tt \bfseries integrate\_ode }!{\tt (function ode, array[] real initial\_state, real initial\_time, array[] real times, array[] real theta, array[] real x\_r, array[] int x\_i): array[,] real}|hyperpage}
`array[,] real` **`integrate_ode`**`(function ode, array[] real initial_state, real initial_time, array[] real times, array[] real theta, array[] real x_r, array[] int x_i)`<br>\newline
Solves the ODE system for the times provided using the Dormand-Prince
algorithm, a 4th/5th order Runge-Kutta method.
`r since("2.10, deprecated in 2.24")`
<!-- array[,] real; integrate_ode_adams; (function ode, array[] real initial_state, real initial_time, array[] real times, array[] real theta, array[] real x_r, array[] int x_i); -->
\index{{\tt \bfseries integrate\_ode\_adams }!{\tt (function ode, array[] real initial\_state, real initial\_time, array[] real times, array[] real theta, data array[] real x\_r, data array[] int x\_i): array[,] real}|hyperpage}
`array[,] real` **`integrate_ode_adams`**`(function ode, array[] real initial_state, real initial_time, array[] real times, array[] real theta, data array[] real x_r, data array[] int x_i)`<br>\newline
Solves the ODE system for the times provided using the Adams-Moulton method.
`r since("2.23, deprecated in 2.24")`
<!-- array[,] real; integrate_ode_adams; (function ode, array[] real initial_state, real initial_time, array[] real times, array[] real theta, array[] real x_r, array[] int x_i, real rel_tol, real abs_tol, int max_num_steps); -->
\index{{\tt \bfseries integrate\_ode\_adams }!{\tt (function ode, array[] real initial\_state, real initial\_time, array[] real times, array[] real theta, data array[] real x\_r, data array[] int x\_i, data real rel\_tol, data real abs\_tol, data int max\_num\_steps): array[,] real}|hyperpage}
`array[,] real` **`integrate_ode_adams`**`(function ode, array[] real initial_state, real initial_time, array[] real times, array[] real theta, data array[] real x_r, data array[] int x_i, data real rel_tol, data real abs_tol, data int max_num_steps)`<br>\newline
Solves the ODE system for the times provided using the Adams-Moulton
method with additional control parameters for the solver.
`r since("2.23, deprecated in 2.24")`
### Stiff solver
<!-- array[,] real; integrate_ode_bdf; (function ode, array[] real initial_state, real initial_time, array[] real times, array[] real theta, array[] real x_r, array[] int x_i); -->
\index{{\tt \bfseries integrate\_ode\_bdf }!{\tt (function ode, array[] real initial\_state, real initial\_time, array[] real times, array[] real theta, data array[] real x\_r, data array[] int x\_i): array[,] real}|hyperpage}
`array[,] real` **`integrate_ode_bdf`**`(function ode, array[] real initial_state, real initial_time, array[] real times, array[] real theta, data array[] real x_r, data array[] int x_i)`<br>\newline
Solves the ODE system for the times provided using the backward differentiation
formula (BDF) method.
`r since("2.10, deprecated in 2.24")`
<!-- array[,] real; integrate_ode_bdf; (function ode, array[] real initial_state, real initial_time, array[] real times, array[] real theta, array[] real x_r, array[] int x_i, real rel_tol, real abs_tol, int max_num_steps); -->
\index{{\tt \bfseries integrate\_ode\_bdf }!{\tt (function ode, array[] real initial\_state, real initial\_time, array[] real times, array[] real theta, data array[] real x\_r, data array[] int x\_i, data real rel\_tol, data real abs\_tol, data int max\_num\_steps): array[,] real}|hyperpage}
`array[,] real` **`integrate_ode_bdf`**`(function ode, array[] real initial_state, real initial_time, array[] real times, array[] real theta, data array[] real x_r, data array[] int x_i, data real rel_tol, data real abs_tol, data int max_num_steps)`<br>\newline
Solves the ODE system for the times provided using the backward differentiation
formula (BDF) method with additional control parameters for the solver.
`r since("2.10, deprecated in 2.24")`
### Arguments to the ODE solvers
The arguments to the ODE solvers in both the stiff and non-stiff cases
are as follows.
* *`ode`*: function literal referring to a function specifying the
system of differential equations with signature:
```
(real, array[] real, array[] real, data array[] real, data array[] int):array[] real
```
The arguments represent (1) time, (2) system state, (3) parameters,
(4) real data, and (5) integer data, and the return value contains the
derivatives with respect to time of the state,
* *`initial_state`*: initial state, type `array[] real`,
* *`initial_time`*: initial time, type `int` or `real`,
* *`times`*: solution times, type `array[] real`,
* *`theta`*: parameters, type `array[] real`,
* `data` *`x_r`*: real data, type `array[] real`, data only, and
* `data` *`x_i`*: integer data, type `array[] int`, data only.
For more fine-grained control of the ODE solvers, these parameters can
also be provided:
* `data` *`rel_tol`*: relative tolerance for the ODE solver, type
`real`, data only,
* `data` *`abs_tol`*: absolute tolerance for the ODE solver, type
`real`, data only, and
* `data` *`max_num_steps`*: maximum number of steps to take in the
ODE solver, type `int`, data only.
#### Return values
The return value for the ODE solvers is an array of type `array[,] real`,
with values consisting of solutions at the specified times.
#### Sizes and parallel arrays
The sizes must match, and in particular, the following groups are of
the same size:
* state variables passed into the system function, derivatives
returned by the system function, initial state passed into the
solver, and rows of the return value of the solver,
* solution times and number of rows of the return value of the
solver,
* parameters, real data and integer data passed to the solver will
be passed to the system function
## Exponentiated quadratic covariance functions {#cov_exp_quad}
These covariance functions have been replaced by those described in:
```{r results='asis', echo=FALSE}
if (knitr::is_html_output()) {
cat(' * <a href="gaussian-process-covariance-functions.html">Gaussian Process Covariance Functions</a>\n')
}
```
With magnitude $\alpha$ and length scale $l$, the exponentiated quadratic kernel is:
$$
k(x_i, x_j) = \alpha^2 \exp \left(-\dfrac{1}{2\rho^2} \sum_{d=1}^D (x_{i,d} - x_{j,d})^2 \right)
$$
<!-- matrix; cov_exp_quad; (row_vectors x, real alpha, real rho); -->
\index{{\tt \bfseries cov\_exp\_quad }!{\tt (row\_vectors x, real alpha, real rho): matrix}|hyperpage}
`matrix` **`cov_exp_quad`**`(row_vectors x, real alpha, real rho)`<br>\newline
The covariance matrix with an exponentiated quadratic kernel of x.
`r since("2.16, deprecated since 2.20, scheduled for removal in 2.32")`
<!-- matrix; cov_exp_quad; (vectors x, real alpha, real rho); -->
\index{{\tt \bfseries cov\_exp\_quad }!{\tt (vectors x, real alpha, real rho): matrix}|hyperpage}
`matrix` **`cov_exp_quad`**`(vectors x, real alpha, real rho)`<br>\newline
The covariance matrix with an exponentiated quadratic kernel of x.
`r since("2.16, deprecated since 2.20, scheduled for removal in 2.32")`
<!-- matrix; cov_exp_quad; (array[] real x, real alpha, real rho); -->
\index{{\tt \bfseries cov\_exp\_quad }!{\tt (array[] real x, real alpha, real rho): matrix}|hyperpage}
`matrix` **`cov_exp_quad`**`(array[] real x, real alpha, real rho)`<br>\newline
The covariance matrix with an exponentiated quadratic kernel of x.
`r since("2.16, deprecated since 2.20, scheduled for removal in 2.32")`
<!-- matrix; cov_exp_quad; (row_vectors x1, row_vectors x2, real alpha, real rho); -->
\index{{\tt \bfseries cov\_exp\_quad }!{\tt (row\_vectors x1, row\_vectors x2, real alpha, real rho): matrix}|hyperpage}
`matrix` **`cov_exp_quad`**`(row_vectors x1, row_vectors x2, real alpha, real rho)`<br>\newline
The covariance matrix with an exponentiated quadratic kernel of x1 and
x2.
`r since("2.18, deprecated since 2.20, scheduled for removal in 2.32")`
<!-- matrix; cov_exp_quad; (vectors x1, vectors x2, real alpha, real rho); -->
\index{{\tt \bfseries cov\_exp\_quad }!{\tt (vectors x1, vectors x2, real alpha, real rho): matrix}|hyperpage}
`matrix` **`cov_exp_quad`**`(vectors x1, vectors x2, real alpha, real rho)`<br>\newline
The covariance matrix with an exponentiated quadratic kernel of x1 and
x2.
`r since("2.18, deprecated since 2.20, scheduled for removal in 2.32")`
<!-- matrix; cov_exp_quad; (array[] real x1, array[] real x2, real alpha, real rho); -->
\index{{\tt \bfseries cov\_exp\_quad }!{\tt (array[] real x1, array[] real x2, real alpha, real rho): matrix}|hyperpage}
`matrix` **`cov_exp_quad`**`(array[] real x1, array[] real x2, real alpha, real rho)`<br>\newline
The covariance matrix with an exponentiated quadratic kernel of x1 and
x2.
`r since("2.18, deprecated since 2.20, scheduled for removal in 2.32")`