Stan functions
Verification
Comparisons with R
- CmdStanR methods
- Posterior summaries
- LOO and PSIS
- Moment matching
- Model methods
- Stan functions
- Figures
- rvars and inits
- Metadata
On this page
Comparisons with other interfaces
Scope
Return values of exposed user-defined Stan functions: real, vector, matrix, array, integer, complex, RNG, and density functions. Identical arguments and seeds.
References
- Reference
- cmdstanr 0.99.0 (commit 0a54123) expose_functions(), compiled with Rcpp 1.1.2 and RcppEigen 0.3.4.0.2
- Versions
- PHP 8.5.10, CmdStan 2.40.0, R 4.6.1, cmdstanr 0.99.0 (commit 0a54123), Rcpp 1.1.2, RcppEigen 0.3.4.0.2
Data
- Inputs
- The functions block of tests/fixtures/native.stan, with the arguments shown in each case.
Method
CmdStanPHP and CmdStanR each compile the functions block of tests/fixtures/native.stan and call every function with the same arguments.
- Check
- Comparison with a reference implementation
- Recorded
- 2026-11-02, PHP 8.5.10, macOS 27.0.1 (arm64), commit 4ec6712
Tolerances
|x − r| ≤ 1e-15
Applies to: Real, vector, matrix, array, and complex results
|x − r| ≤ 1e-14
Applies to: RNG and density results
exact equality
Applies to: Integer results
x: package value; r: reference value. Absolute error: |x − r|. Relative error: |x − r| / max(|r|, 1). Max errors are over the values a row compares.
Results
9 comparisons: 9 pass, 0 fail, 0 skipped.
| Case | Quantity | Criterion | Values | Max abs. error | Max rel. error | Status |
|---|---|---|---|---|---|---|
| add(1.5, 2) | real | |x − r| ≤ 1e-15 | 1 | 0 | 0 | pass |
| scale([1, 2, 3], 2.0) | vector | |x − r| ≤ 1e-15 | 3 | 0 | 0 | pass |
| outer([1, 2], [3, 4, 5]) | matrix | |x − r| ≤ 1e-15 | 6 | 0 | 0 | pass |
| twice([1.5, -2]) | array | |x − r| ≤ 1e-15 | 2 | 0 | 0 | pass |
| pairs(3) | integer array | exact equality | 6 | pass | ||
| cmul([1, 2], [3, -1]) | complex | |x − r| ≤ 1e-15 | 2 | 0 | 0 | pass |
| draw_rng(0.5), seed 42 | RNG draw | |x − r| ≤ 1e-14 | 1 | 1.1e-16 | 1.1e-16 | pass |
| shifted_lpdf(0.3, 1.0) | log density | |x − r| ≤ 1e-14 | 1 | 2.9e-15 | 2.5e-15 | pass |
| counts_lpmf(2, 1.5) | log mass | |x − r| ≤ 1e-14 | 1 | 3.3e-15 | 2.4e-15 | pass |
Reproduction
php verification/compatibility/run.php
- Raw record
- site/verifications/stan-functions.json
- Full results
- verification/compatibility/results.json