├── .gitignore ├── Makefile ├── README.md ├── create_stan_lang.py ├── environment.yml ├── examples ├── demo.stan └── highlight-test.stan ├── specs_create_stan_lang.py ├── stan-functions-2_33.txt ├── stan-lang-keywords.yaml ├── stan_lang.json └── tools ├── highlightjs.py ├── make_pygments_list.py └── rstudio.py /.gitignore: -------------------------------------------------------------------------------- 1 | examples/*.hpp 2 | examples/highlight-test 3 | /__pycache__/ 4 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # 6.5 Setting Variables 2 | # https://www.gnu.org/software/make/manual/html_node/Setting.html 3 | # Variables defined with ‘=’ are recursively expanded variables. 4 | # If you’d like a variable to be set to a value only if it’s not 5 | # already set, then you can use the shorthand operator ‘?=’ instead 6 | # of ‘=’. 7 | # Variables defined with ‘:=’ or ‘::=’ are simply expanded variables. 8 | # Use the python3 that has the pyyaml library installed. 9 | # If doing conda install pyyaml, the conda python3 should be specified. 10 | # Check with which -a python3 to see the priority. 11 | # https://github.com/yaml/pyyaml/issues/291 12 | PYTHON ?= ~/miniconda3/bin/python3 13 | STAN_LANG_JSON = stan_lang.json 14 | # This file must have a version string at * to ensure auto-retrieval. 15 | FUNCTIONS_FILE := $(wildcard stan-functions-*.txt) 16 | 17 | all : json 18 | 19 | clean : clean-json 20 | 21 | 22 | json : $(STAN_LANG_JSON) 23 | 24 | clean-json : 25 | rm -rf $(STAN_LANG_JSON) 26 | 27 | 28 | # Update in any one of 29 | # create_stan_lang.py (script) 30 | # stan-lang-keywords.yaml (hardcoded in the script) 31 | # stan-functions-*.txt (argument to the script) 32 | # should invoke the recipe. 33 | # 34 | # Avoided "Automatic Variables" for readability. 35 | # http://www.gnu.org/software/make/manual/make.html#Automatic-Variables 36 | $(STAN_LANG_JSON) : create_stan_lang.py stan-lang-keywords.yaml $(FUNCTIONS_FILE) 37 | $(PYTHON) create_stan_lang.py $(STAN_LANG_JSON) 38 | 39 | # mamba and expects were installed via conda's pip. 40 | test : 41 | mamba specs_create_stan_lang.py 42 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | This is not literally the Stan Language definition, which is in the [Stan Modeling Language User's Guide and Reference Manual](http://mc-stan.org/documentation/). 2 | This repo contains `stan-lang.json`, which contains various keywords and built-in functions in Stan that I use in maintaining several editor modes and syntax highlighting defintions. 3 | In particular, this is used to generate the keyword and function lists in: 4 | 5 | - Emacs [stan-mode](https://github.com/stan-dev/stan-mode) (Current maintainer: @kaz-yos). 6 | - Atom [language-stan](https://github.com/jrnold/atom-language-stan). 7 | - [Pygments](http://pygments.org/) StanLexer. 8 | - LaTeX package [lstbayes](https://www.ctan.org/pkg/lstbayes) ([github](https://github.com/jrnold/lstbayes)). 9 | 10 | 11 | ## Updating this folder 12 | 13 | `make all` in this directory invokes the `create_stan_lang.py` Python script. This script parses the following manually maintained files to construct the `stan-lang.json` file. `make clean` will delete this file. 14 | 15 | - `stan-lang-keywords.yaml` 16 | - `stan-functions-*.txt` 17 | 18 | The `stan-functions-*.txt` file is generated by the `extract_function_sigs.py` script in the [stan docs repo](https://github.com/stan-dev/docs). For example, function signatures for Stan version 2.4.x can be generated as follows after cloning the stan-dev/docs repo. 19 | 20 | ```{sh} 21 | git clone git@github.com:stan-dev/docs.git 22 | cd docs 23 | python3 extract_function_sigs.py 24 | ``` 25 | 26 | Copy the resulting file named `stan-functions-2_24.txt` to this repo. 27 | 28 | 29 | ## References 30 | 31 | - [Stan Reference Manual, Version 2.24.0](https://mc-stan.org/docs/2_24/reference-manual/index.html) 32 | - [6 Expressions](https://mc-stan.org/docs/2_24/reference-manual/expressions.html) 33 | - [6.2 Variables](https://mc-stan.org/docs/2_24/reference-manual/variables-section.html) 34 | - [8.1 Overview of Stan’s Program Blocks](https://mc-stan.org/docs/2_24/reference-manual/overview-of-stans-program-blocks.html) 35 | - [11 Language Syntax](https://mc-stan.org/docs/2_24/reference-manual/language-syntax.html) 36 | - [13 Deprecated Features](https://mc-stan.org/docs/2_24/reference-manual/deprecated-features-appendix.html) 37 | 38 | 39 | ## Notes on Changes 40 | 41 | ### 2.28.1 (2021-11-03) 42 | - Update functions to latest and parse new `array [] int` syntax as replacement for `int[]` syntax 43 | - Add `.^` and `%/%` operators 44 | - Add support for the `complex` type 45 | 46 | ### 2.24.x (2020-08-17) 47 | - Explain function signature file generation using the extract_function_sigs.py script 48 | 49 | ### 2.22.0 (2020-02-12) 50 | 51 | - Add `offset` and `multiplier` to keywords. 52 | 53 | ### 2.19.0 (2019-07-12) 54 | 55 | - Links have been updated 56 | - data only arguments in functions such as ODE functions are handled as special cases in the Python parsing script. 57 | 58 | ### 2.10.0 59 | 60 | - `=` now used for assignment. `<-` is deprecated. 61 | - New `target` keyword for `target += expression` 62 | - Variable `lp__` is no longer supported 63 | - Indicate `log_prob()` and `target()` as special functions 64 | - Ternary operator `a ? b : c` 65 | - New ODE integrate keywords: `integrate_ode`, `integrate_ode_rk45`, `integrate_ode_bdf` which support 6 or 9 arguments. 66 | - Deprecate functions: `log_prob`, `increment_log_prob`, `binomial_log`, `multiply_log` 67 | - `y ~ foo(a, b)` is deprecated in favor of `target += foo(y | a, b)` 68 | - Distribution postfixes `_log`, `_cdf_log`, and `_ccdf_log` deprecated in favor of 69 | `_lpdf`, `_lpmf`, `_lcdf`, `_lccdf`, `_cdf`, `_ccdf`. 70 | -------------------------------------------------------------------------------- /create_stan_lang.py: -------------------------------------------------------------------------------- 1 | """Create create_stan.json.""" 2 | import csv 3 | import glob 4 | import json 5 | import re 6 | import sys 7 | 8 | # conda install pyyaml 9 | import yaml 10 | 11 | 12 | def parse_args(argtext): 13 | """Parse arguments in a function.""" 14 | argtext = re.sub("[()]", "", argtext).strip() 15 | if argtext == "": 16 | ret = [] 17 | elif argtext == "~": 18 | ret = None 19 | else: 20 | ret = [] 21 | # , separates args, but they can appear within brackets like int[,] 22 | for arg in re.split('[|,](?!\\s*])', argtext): 23 | arg = arg.strip() 24 | if arg == '...': 25 | ret.append({'type': '...', 'name': '...'}) 26 | else: 27 | # 'prefixes' could be things like 'data', 'array[]', 'data array[]', etc 28 | *prefixes, argtype, argname = arg.split(' ') 29 | prefix = ' '.join(p.strip() for p in prefixes) + (' ' if prefixes else '') 30 | ret.append({'type': prefix + argtype.strip(), 'name': argname.strip()}) 31 | return ret 32 | 33 | 34 | def parse_functions(src, data): 35 | """ 36 | Parse functions in stan-functions-*.txt. 37 | 38 | This file should be generated with stan-dev/docs/extract_function_sigs.py. 39 | """ 40 | with open(src, "r") as f: 41 | # Skip commentts 42 | # https://stackoverflow.com/questions/14158868/python-skip-comment-lines-marked-with-in-csv-dictreader 43 | reader = csv.reader(filter(lambda row: row[0] != '#', f), delimiter=';') 44 | # Skip the first non-comment row (StanFunction;Arguments;ReturnType). 45 | fundata = [row for row in reader][1:] 46 | 47 | functions = {} 48 | 49 | for row in fundata: 50 | # StanFunction; Arguments; ReturnType 51 | funname, funargs, funret = row[:3] 52 | # Ignore sampling statements 53 | # The argument string is ~ with any number of spaces around it. 54 | if bool(re.match(r'^ *~ *$', funargs)): 55 | continue 56 | else: 57 | # Ignore target += 58 | if re.match(r'target.*\+=$', funname): 59 | continue 60 | else: 61 | try: 62 | args = parse_args(funargs) 63 | except Exception as e: 64 | print( 65 | "Error parsing arguments in %s" % row, file=sys.stderr) 66 | sys.exit(1) 67 | f = { 68 | 'return': funret.lstrip(), 69 | 'args': args, 70 | } 71 | if funname in functions: 72 | functions[funname]['signatures'].append(f) 73 | else: 74 | vals = { 75 | 'signatures': [f], 76 | 'deprecated': 77 | False, 78 | 'lpdf': 79 | bool(re.match(r'.*_lpdf$', funname)), 80 | 'lpmf': 81 | bool(re.match(r'.*_lpmf$', funname)), 82 | 'lcdf': 83 | bool(re.match(r'.*_lcdf$', funname)), 84 | 'lccdf': 85 | bool(re.match(r'.*_lccdf$', funname)), 86 | 'operator': 87 | bool(re.match(r'operator', funname)), 88 | 'keyword': 89 | funname in data['keywords']['functions'] 90 | } 91 | vals['density'] = vals['lpdf'] or vals['lpmf'] 92 | if vals['density']: 93 | vals['sampling'] = re.sub(r'_lp[dm]f$', '', funname) 94 | else: 95 | vals['sampling'] = None 96 | vals['math'] = not (vals['lpdf'] or vals['lpmf'] 97 | or vals['lcdf'] or vals['lccdf']) 98 | functions[funname] = vals 99 | return functions 100 | 101 | 102 | def build(file_functions, file_keywords, dst): 103 | """Build the json file of language definitions.""" 104 | print("functions file: %s" % file_functions) 105 | with open(file_keywords, 'r') as f: 106 | data = yaml.load(f, Loader=yaml.FullLoader) 107 | functions = parse_functions(file_functions, data) 108 | version = re.search(r"-([0-9]+_[0-9]+)\.txt$", 109 | file_functions).group(1) 110 | version = version.replace("_", ".") 111 | print("Stan version: %s" % version) 112 | data['version'] = version 113 | data['functions'] = functions 114 | with open(dst, 'w') as f: 115 | json.dump(data, f, sort_keys=True, indent=2, separators=(',', ': ')) 116 | 117 | 118 | def main(): 119 | """Command line interface.""" 120 | dst = sys.argv[1] 121 | file_functions = glob.glob("stan-functions-*.txt")[0] 122 | print("Using file %s\n" % file_functions) 123 | file_keywords = 'stan-lang-keywords.yaml' 124 | build(file_functions, file_keywords, dst) 125 | 126 | 127 | if __name__ == '__main__': 128 | main() 129 | -------------------------------------------------------------------------------- /environment.yml: -------------------------------------------------------------------------------- 1 | name: stan-language-definitions 2 | channels: 3 | - defaults 4 | dependencies: 5 | - pyyaml 6 | prefix: /Users/kazuki/miniconda3/envs/stan-language-definitions 7 | 8 | -------------------------------------------------------------------------------- /examples/demo.stan: -------------------------------------------------------------------------------- 1 | // See 2 | // https://mc-stan.org/docs/2_20/stan-users-guide/stan-program-style-guide.html 3 | // https://mc-stan.org/docs/2_20/reference-manual/deprecated-features-appendix.html 4 | 5 | /* Stan highlighting example 6 | 7 | This file contains a syntatically correct (it will compile) 8 | but nonsensical Stan program that includes almost every feature of the 9 | language needed to validate syntax highlighters. 10 | 11 | */ 12 | // line comment 13 | # deprecated line comment 14 | functions { 15 | # comment 16 | # hello 17 | # ixclude is not a keyword and deprecated comment 18 | #include stuff_should_not_have_warning_face 19 | #include stuff.stan 20 | #include "morestuff.stan" 21 | #include "this_should_have_string_face.stan" 22 | #include 'moststuff.stan' 23 | #include 24 | #include atest 25 | print("hello 26 | #hello should not be a comment. It is within a string. 27 | #include should not be a preprocessor. #include is within a string. 28 | there") 29 | // declarations 30 | void oof(real x); 31 | 32 | // definitions 33 | // return types 34 | void oof(real x) { 35 | print("print ", x); #include file 36 | } 37 | /** 38 | * highlighting should happen for keywords here. 39 | * @param x A number 40 | * @return x + 1 41 | */ 42 | real foo(real x) { # Deprecated comments 43 | return x; # should not interfere 44 | } # with indentation 45 | int bar(int x) { 46 | return x; 47 | } 48 | vector baz(vector x) { 49 | return x; 50 | } 51 | row_vector qux(row_vector x) { 52 | return x; 53 | } 54 | matrix quux(matrix x) { 55 | return x; 56 | } 57 | // numbers of arguments 58 | void corge() { 59 | print("no parameters"); 60 | } 61 | void grault(int a, real b, vector c, row_vector d, matrix f) { 62 | print("many parameters"); 63 | } 64 | void garply(real a, real[] b, real[,] c, real[,,] d) { 65 | print("array arguments"); 66 | } 67 | // array return types 68 | int[] waldo(int[] x) { 69 | return x; 70 | } 71 | int[,] fred(int[,] x) { 72 | return x; 73 | } 74 | int[,,] plough(int[,,] x) { 75 | return x; 76 | } 77 | // data only function argument 78 | real plugh(data real x) { 79 | return x; 80 | } 81 | // ode function 82 | real[] ode_func(real a, real[] b, real[] c, real[] d, int[] e) { 83 | return b; 84 | } 85 | } 86 | data { 87 | // non-int variable types 88 | int x_int; 89 | real x_real; 90 | real y_real; 91 | vector[1] x_vector; 92 | ordered[1] x_ordered; 93 | positive_ordered[1] x_positive_ordered; 94 | simplex[1] x_simplex; 95 | unit_vector[1] x_unit_vector; 96 | row_vector[1] x_row_vector; 97 | matrix[1, 1] x_matrix; 98 | cholesky_factor_corr[2] x_cholesky_factor_corr; 99 | cholesky_factor_cov[2] x_cholesky_factor_cov; 100 | cholesky_factor_cov[2, 3] x_cholesky_factor_cov_2; 101 | corr_matrix[2] x_corr_matrix; 102 | cov_matrix[2] x_cov_matrix; 103 | 104 | // range constraints 105 | real alpha; 106 | real bravo; 107 | real charlie; 108 | 109 | // arrays 110 | int echo[1]; 111 | int foxtrot[1, 1]; 112 | int golf[1, 1, 1]; 113 | array[1] int echo2; 114 | array[3] row_vector new_array; 115 | 116 | complex z = 3 + 4.0i; 117 | z = 3e4i; 118 | 119 | 120 | // identifier with all valid letters 121 | real abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789; 122 | 123 | // hard pattern 124 | real charlie)> ranger; 125 | 126 | // identifier patterns 127 | real a; 128 | real a3; 129 | real a_3; 130 | real Sigma; 131 | real my_cpp_style_variable; 132 | real myCamelCaseVariable; 133 | real abcdefghijklmnojk; 134 | } 135 | transformed data { 136 | // declaration and assignment 137 | int india = 1; 138 | real romeo = 1.0; 139 | row_vector[2] victor = [1, 2]; 140 | matrix[2, 2] mike = [[1, 2], [3, 4]]; 141 | real sierra[2] = {1., 2.}; 142 | } 143 | parameters { 144 | real hotel; 145 | } 146 | transformed parameters { 147 | real juliette; 148 | juliette = hotel * 2.; 149 | } 150 | model { 151 | real x; 152 | int k; 153 | vector[2] y = [1., 1.]'; 154 | matrix[2, 2] A = [[1., 1.], [1., 1.]]; 155 | real odeout[2, 2]; 156 | real algout[2, 2]; 157 | 158 | // if else statements 159 | if (x_real < 0) x = 0.; 160 | 161 | if (x_real < 0) { 162 | x = 0.; 163 | } 164 | 165 | if (x_real < 0) x = 0.; 166 | else x = 1.; 167 | 168 | if (x_real < 0) { 169 | x = 0.; 170 | } else { 171 | x = 1.; 172 | } 173 | 174 | if (x_real < 0) x = 0.; 175 | else if (x_real > 1) x = 1.; 176 | else x = 0.5; 177 | 178 | if (x_real < 0) { 179 | x = 0.; 180 | } else if (x_real > 1) { 181 | x = 1.; 182 | } else { 183 | x = 0.5; 184 | } 185 | 186 | // for loops 187 | for (i in 1:5) { 188 | print("i = ", i); 189 | } 190 | for (i in 1:5) 191 | print("i = ", i); 192 | print("i = ", i); // This line should deindent by one level. 193 | // for (j in echo) { 194 | // print("j = ", j); 195 | // } 196 | // while loop 197 | while (1) { 198 | break; 199 | continue; 200 | } 201 | 202 | // reject statement 203 | reject("reject statment ", x_real); 204 | 205 | // print statement 206 | print("print statement ", x_real); 207 | print("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_~@#$%^&*`'-+={}[].,;: "); 208 | 209 | // increment log probability statements; 210 | target += 1.; 211 | // (deprecated versions) 212 | increment_log_prob(1.); 213 | 214 | // valid integer literals 215 | k = 0; 216 | k = 1; 217 | k = -1; 218 | k = 256; 219 | k = -127098; 220 | k = 007; 221 | 222 | // valid real literals 223 | x = 0.0; 224 | x = 1.0; 225 | x = 3.14; 226 | x = 003.14; 227 | x = -217.9387; 228 | x = 0.123; 229 | x = .123; 230 | x = 1.; 231 | x = -0.123; 232 | x = -.123; 233 | x = -1.; 234 | x = 12e34; 235 | x = 12E34; 236 | x = 12.e34; 237 | x = 12.E34; 238 | x = 12.0e34; 239 | x = 12.0E34; 240 | x = .1e34; 241 | x = .1E34; 242 | x = -12e34; 243 | x = -12E34; 244 | x = -12.e34; 245 | x = -12.E34; 246 | x = -12.0e34; 247 | x = -12.0E34; 248 | x = -.1e34; 249 | x = -.1E34; 250 | x = 12e-34; 251 | x = 12E-34; 252 | x = 12.e-34; 253 | x = 12.E-34; 254 | x = 12.0e-34; 255 | x = 12.0E-34; 256 | x = .1e-34; 257 | x = .1E-34; 258 | x = -12e-34; 259 | x = -12E-34; 260 | x = -12.e-34; 261 | x = -12.E-34; 262 | x = -12.0e-34; 263 | x = -12.0E-34; 264 | x = -.1e-34; 265 | x = -.1E-34; 266 | x = 12e+34; 267 | x = 12E+34; 268 | x = 12.e+34; 269 | x = 12.E+34; 270 | x = 12.0e+34; 271 | x = 12.0E+34; 272 | x = .1e+34; 273 | x = .1E+34; 274 | x = -12e+34; 275 | x = -12E+34; 276 | x = -12.e+34; 277 | x = -12.E+34; 278 | x = -12.0e+34; 279 | x = -12.0E+34; 280 | x = -.1e+34; 281 | x = -.1E+34; 282 | 283 | // assignment statements 284 | x = 1; 285 | x += 1.; 286 | x -= 1.; 287 | x *= 1.; 288 | x /= 1.; 289 | y .*= x_vector; 290 | y ./= x_vector; 291 | 292 | // operators 293 | x = x_real && 1; 294 | x = x_real || 1; 295 | x = x_real < 1.; 296 | x = x_real <= 1.; 297 | x = x_real > 1.; 298 | x = x_real >= 1.; 299 | x = x_real + 1.; 300 | x = x_real - 1.; 301 | x = x_real * 1.; 302 | x = x_real / 1.; 303 | x = x_real ^ 2.; 304 | x = x_real % 2; 305 | x = !x_real; 306 | x = +x_real; 307 | x = -x_real; 308 | x = x_int ? x_real : 0.; 309 | 310 | y = x_row_vector'; 311 | y = x_matrix \ x_vector; 312 | y = x_vector .* x_vector; 313 | y = x_vector ./ x_vector; 314 | 315 | // parenthized expression 316 | x = (x_real + x_real); 317 | 318 | // block statement 319 | { 320 | real z; 321 | z = 1.; 322 | } 323 | 324 | // built-in functions 325 | x = log(1.); 326 | x = exp(1.); 327 | 328 | // non-built-in function 329 | x = foo(1.); 330 | 331 | // constants and nullary functions 332 | x = machine_precision(); 333 | x = pi(); 334 | x = e(); 335 | x = sqrt2(); 336 | x = log2(); 337 | x = log10(); 338 | // special values 339 | x = not_a_number(); 340 | x = positive_infinity(); 341 | x = negative_infinity(); 342 | x = machine_precision(); 343 | // log probability 344 | x = target(); 345 | 346 | // sampling statement 347 | x_real ~ normal(0., 1.); 348 | 349 | // truncation 350 | x_real ~ normal(0., 1.) T[-1., 1.]; 351 | x_real ~ normal(0., 1.) T[, 1.]; 352 | x_real ~ normal(0., 1.) T[-1., ]; 353 | x_real ~ normal(0., 1.) T[ , ]; 354 | 355 | // transformation on lhs of sampling 356 | log(x_real) ~ normal(0., 1.); 357 | 358 | // lhs indexes 359 | y[1] = 1.; 360 | A[1, 2] = 1.; 361 | A[1][2] = 1.; 362 | 363 | // special functions 364 | odeout = integrate_ode(ode_func, {1.}, x_real, {1.}, {1.}, {1.}, {0}); 365 | odeout = integrate_ode_bdf(ode_func, {1.}, x_real, {1.}, {1.}, {1.}, {0}, 366 | x_real, x_real, x_int); 367 | odeout = integrate_ode_rk45(ode_func, {1.}, x_real, {1.}, {1.}, {1.}, {0}, 368 | x_real, x_real, x_int); 369 | // algout = algebra_solver(algebra_func, x_vector, x_vector, {1.}, {0}); 370 | 371 | // distribution functions 372 | x = normal_lpdf(0.5 | 0., 1.); 373 | x = normal_cdf(0.5, 0., 1.); 374 | x = normal_lcdf(0.5 | 0., 1.); 375 | x = normal_lccdf(0.5 | 0., 1.); 376 | x = binomial_lpmf(1 | 2, 0.5); 377 | 378 | // deprecated features 379 | foo <- 1; 380 | increment_log_prob(0.0); 381 | y_hat = integrate_ode(sho, y0, t0, ts, theta, x_r, x_i); 382 | x = get_lp(); 383 | x = multiply_log(1.0, 1.0); 384 | x = binomial_coefficient_log(1.0, 1.0); 385 | // deprecated distribution functions versions 386 | x = normal_log(0.5, 0.0, 1.0); 387 | x = normal_cdf_log(0.5, 0.0, 1.0); 388 | x = normal_ccdf_log(0.5, 0.0, 1.0); 389 | 390 | } 391 | generated quantities { 392 | real Y; 393 | // rng function 394 | Y = normal_rng(0., 1.); 395 | } 396 | -------------------------------------------------------------------------------- /examples/highlight-test.stan: -------------------------------------------------------------------------------- 1 | /* 2 | A file for testing Stan syntax highlighting. 3 | 4 | This model is nonsensical, but it will parse correctly (albeit with deprecation warnings), 5 | if the invalid sections are commented out. 6 | 7 | Note that block comments cannot be nested 8 | */ 9 | 10 | # Single line comment 11 | 12 | // Single line comment 13 | 14 | functions { 15 | // highlight include pre-processor 16 | #include "foo.stan" 17 | 18 | void f1() { 19 | print("Hello world!"); 20 | } 21 | real f2() { 22 | return 1.0; 23 | } 24 | int f3() { 25 | return 1; 26 | } 27 | vector f4() { 28 | return rep_vector(0.0, 3); 29 | } 30 | row_vector f5() { 31 | return rep_row_vector(0.0, 3); 32 | } 33 | matrix f6() { 34 | return rep_matrix(0.0, 2, 2); 35 | } 36 | real[] f7() { 37 | return rep_array(0.0, 1); 38 | } 39 | real[,] f8() { 40 | return rep_array(0.0, 1, 1); 41 | } 42 | real[,,] f9() { 43 | return rep_array(0.0, 1, 1, 1); 44 | } 45 | void f10(real alpha, int bravo, vector charlie, row_vector delta, 46 | matrix echo, real[] foxtrot, real[,] golf, real[,,] hotel) { 47 | print("Hello, world!"); 48 | } 49 | /** 50 | * Suggested syntax for commenting functions. 51 | * See Appendix "Stan Program Style Guide" 52 | * 53 | * @param a whatever 54 | * @param b whatever 55 | * @param c whatever 56 | * @return whatever 57 | */ 58 | real f11(real a, real b, real c) { 59 | return a + b + c; 60 | } 61 | // ode function 62 | real[] sho(real t, 63 | real[] y, 64 | real[] theta, 65 | real[] x_r, 66 | int[] x_i) { 67 | real dydt[2]; 68 | dydt[1] = y[2]; 69 | dydt[2] = -y[1] - theta[1] * y[2]; 70 | return dydt; 71 | } 72 | /* INVALID START 73 | cov_matrix fbad() { 74 | return diag_matrix(rep_vector(1.0, 2)); 75 | } 76 | void fbad2(cov_matrix a) { 77 | } 78 | vector sum(vector a) { 79 | return 1.0; 80 | } 81 | INVALID END */ 82 | } 83 | data { 84 | int n; 85 | real y; 86 | 87 | // valid names 88 | real abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_abc; 89 | real a; 90 | real a3; 91 | real Sigma; 92 | real my_cpp_style_variable; 93 | real myCamelCaseVariable; 94 | // invalid names 95 | /* INVALID START 96 | int a__; 97 | int 1a; 98 | int _a 99 | int _; 100 | // C++ reserved 101 | real public; 102 | // Stan reserved 103 | real var; 104 | real fvar; 105 | real STAN_MAJOR; 106 | real true; 107 | real false; 108 | INVALID END */ 109 | 110 | // all types should be highlighed 111 | int alpha; 112 | real bravo; 113 | vector[1] charlie; 114 | ordered[1] delta; 115 | positive_ordered[3] echo; 116 | simplex[1] foxtrot; 117 | row_vector[1] golf; 118 | matrix[1, 1] hotel; 119 | corr_matrix[3] india; 120 | cov_matrix[3] juliette; 121 | cholesky_factor_cov[3] kilo; 122 | cholesky_factor_corr[3] lima; 123 | 124 | // ranges; 125 | real november; 126 | real oscar; 127 | real mike; 128 | 129 | // arrays 130 | real papa[1]; 131 | real quebec[1, 1]; 132 | real romeo[1, 1, 1]; 133 | 134 | // names beginning with keywords 135 | real iffffff; 136 | real whilest; 137 | // name ending with truncation 138 | real fooT; 139 | // ode stuff 140 | int T; 141 | real y0[2]; 142 | real t0; 143 | real ts[T]; 144 | real theta[1]; 145 | real abs_tol; 146 | real rel_tol; 147 | int max_num_steps; 148 | } 149 | transformed data { 150 | real sierra; 151 | // ode stuff 152 | real x_r[0]; 153 | int x_i[0]; 154 | 155 | sierra = 1 + 1; 156 | } 157 | parameters { 158 | real tango; 159 | } 160 | transformed parameters { 161 | real uniform; 162 | uniform = 1 / tango; 163 | } 164 | model { 165 | real foo; 166 | int bar; 167 | real baz; 168 | // used in ODE 169 | real y_hat[T,2]; 170 | 171 | ## Assignment Operators 172 | foo = 1.0; 173 | foo = 0.0; 174 | 175 | // valid integer literals 176 | bar = 0; 177 | bar = 1; 178 | bar = -1; 179 | bar = 256; 180 | bar = -127098; 181 | // valid real literals 182 | foo = 0.0; 183 | foo = 1.0; 184 | foo = 3.14; 185 | foo = -217.9387; 186 | foo = 0.123; 187 | foo = .123; 188 | foo = 1.; 189 | foo = -0.123; 190 | foo = -.123; 191 | foo = -1.; 192 | foo = 12e34; 193 | foo = 12E34; 194 | foo = 12.e34; 195 | foo = 12.E34; 196 | foo = 12.0e34; 197 | foo = 12.0E34; 198 | foo = .1e34; 199 | foo = .1E34; 200 | foo = -12e34; 201 | foo = -12E34; 202 | foo = -12.e34; 203 | foo = -12.E34; 204 | foo = -12.0e34; 205 | foo = -12.0E34; 206 | foo = -.1e34; 207 | foo = -.1E34; 208 | foo = 12e-34; 209 | foo = 12E-34; 210 | foo = 12.e-34; 211 | foo = 12.E-34; 212 | foo = 12.0e-34; 213 | foo = 12.0E-34; 214 | foo = .1e-34; 215 | foo = .1E-34; 216 | foo = -12e-34; 217 | foo = -12E-34; 218 | foo = -12.e-34; 219 | foo = -12.E-34; 220 | foo = -12.0e-34; 221 | foo = -12.0E-34; 222 | foo = -.1e-34; 223 | foo = -.1E-34; 224 | 225 | // constants and nullary functions 226 | foo = machine_precision(); 227 | foo = pi(); 228 | foo = e(); 229 | foo = sqrt2(); 230 | foo = log2(); 231 | foo = log10(); 232 | // special values 233 | foo = not_a_number(); 234 | foo = positive_infinity(); 235 | foo = negative_infinity(); 236 | foo = machine_precision(); 237 | // log probability 238 | foo = target(); 239 | 240 | // functions 241 | foo = log(10); 242 | foo = exp(20); 243 | 244 | // target += 245 | target += 0.0; 246 | // bug in parser right now. uncomment when fixed. 247 | // target += normal_lpdf(y, 0.0, 1.0) 248 | y ~ normal(0.0, 1.0); 249 | 250 | // distribution functions 251 | foo = normal_lpdf(0.5 | 0.0, 1.0); 252 | foo = normal_cdf(0.5, 0.0, 1.0); 253 | foo = normal_lcdf(0.5 | 0.0, 1.0); 254 | foo = normal_lccdf(0.5 | 0.0, 1.0); 255 | 256 | // truncation 257 | alpha ~ normal(0, 1) T[-0.5, 0.5]; 258 | 259 | // highlighting non-built in functions 260 | f1(); 261 | foo = f11(foo, 0.0, 1.0); 262 | 263 | // control structures 264 | for (i in 1:10) { 265 | } 266 | while (foo < 5.0) { 267 | } 268 | if (foo > 0) { 269 | } else if (foo < 0) { 270 | } else { 271 | } 272 | 273 | // operators 274 | bar = foo || foo; 275 | bar = foo && foo; 276 | bar = foo == foo; 277 | bar = foo != foo; 278 | bar = foo < foo; 279 | bar = foo <= foo; 280 | bar = foo > foo; 281 | bar = foo >= foo; 282 | foo = foo + foo; 283 | foo = foo - foo; 284 | foo = foo * foo; 285 | foo = foo / foo; 286 | foo = bar % bar; 287 | foo = foo .* foo; 288 | foo = foo ./ foo; 289 | bar = ! foo; 290 | foo = - foo; 291 | foo = + foo; 292 | foo = foo ^ 2.0; 293 | foo = foo '; 294 | bar = foo > 1 ? 0 : 1; 295 | 296 | // ODE Functions 297 | y_hat = integrate_ode_rk45(sho, y0, t0, ts, theta, x_r, x_i, rel_tol, abs_tol, max_num_steps); 298 | y_hat = integrate_ode_rk45(sho, y0, t0, ts, theta, x_r, x_i); 299 | y_hat = integrate_ode_bdf(sho, y0, t0, ts, theta, x_r, x_i, rel_tol, abs_tol, max_num_steps); 300 | y_hat = integrate_ode_bdf(sho, y0, t0, ts, theta, x_r, x_i); 301 | 302 | // print and reject statements 303 | print("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_~@#$%^&*`'-+={}[].,;: "); 304 | // should be an error with the backslash and " and tab 305 | /* INVALID START 306 | // print("\ "); 307 | INVALID END */ 308 | print(" 309 | "); 310 | print("Hello, world!"); 311 | print(""); 312 | reject("rejected!"); 313 | 314 | // lp__ should be an error 315 | /* INVALID START 316 | lp__ = lp__ + 0.0; 317 | INVALID END */ 318 | // Deprecated features 319 | // DEPRECATED START 320 | foo <- 1; 321 | increment_log_prob(0.0); 322 | y_hat = integrate_ode(sho, y0, t0, ts, theta, x_r, x_i); 323 | foo = get_lp(); 324 | foo = multiply_log(1.0, 1.0); 325 | foo = binomial_coefficient_log(1.0, 1.0); 326 | // deprecated distribution functions versions 327 | foo = normal_log(0.5, 0.0, 1.0); 328 | foo = normal_cdf_log(0.5, 0.0, 1.0); 329 | foo = normal_ccdf_log(0.5, 0.0, 1.0); 330 | // DEPRECATED END 331 | } 332 | generated quantities { 333 | real baz; 334 | // sampling function 335 | baz = normal_rng(0.0, 1.0); 336 | } 337 | -------------------------------------------------------------------------------- /specs_create_stan_lang.py: -------------------------------------------------------------------------------- 1 | 2 | # https://github.com/nestorsalceda/mamba 3 | from mamba import description, context, it 4 | from expects import expect, equal 5 | 6 | from create_stan_lang import * 7 | 8 | with description("parse_args") as self: 9 | with it("parses empty argument correctly"): 10 | expect(parse_args("")).to(equal([])) 11 | # 12 | with it("parses ~ argument correctly regardless of spaces"): 13 | expect(parse_args("~")).to(equal(None)) 14 | expect(parse_args("~ ")).to(equal(None)) 15 | expect(parse_args("~ ")).to(equal(None)) 16 | expect(parse_args(" ~")).to(equal(None)) 17 | expect(parse_args(" ~")).to(equal(None)) 18 | expect(parse_args(" ~ ")).to(equal(None)) 19 | # 20 | with it("parses single argument into a single element list"): 21 | expect(parse_args("T x")).to(equal([{'type': 'T', 'name': 'x'}])) 22 | expect(parse_args("reals theta")).to(equal([{'type': 'reals', 'name': 'theta'}])) 23 | # 24 | with it("parses multiple arguments into a multi-element list"): 25 | expect(parse_args("T x, T y") 26 | ).to(equal([{'type': 'T', 'name': 'x'}, 27 | {'type': 'T', 'name': 'y'}])) 28 | expect(parse_args("matrix x, matrix y") 29 | ).to(equal([{'type': 'matrix', 'name': 'x'}, 30 | {'type': 'matrix', 'name': 'y'}])) 31 | -------------------------------------------------------------------------------- /stan-functions-2_33.txt: -------------------------------------------------------------------------------- 1 | # This file is semicolon delimited 2 | StanFunction; Arguments; ReturnType 3 | Phi; (T x); R 4 | Phi_approx; (T x); R 5 | abs; (T x); T 6 | abs; (complex z); real 7 | acos; (T x); R 8 | acos; (complex z); complex 9 | acosh; (T x); R 10 | acosh; (complex z); complex 11 | add_diag; (complex_matrix m, complex_real d); complex_matrix 12 | add_diag; (complex_matrix m, complex_row_vector d); complex_matrix 13 | add_diag; (complex_matrix m, complex_vector d); complex_matrix 14 | add_diag; (matrix m, real d); matrix 15 | add_diag; (matrix m, row_vector d); matrix 16 | add_diag; (matrix m, vector d); matrix 17 | algebra_solver; (function algebra_system, vector y_guess, vector theta, data array[] real x_r, array[] int x_i, data real rel_tol, data real f_tol, int max_steps); vector 18 | algebra_solver_newton; (function algebra_system, vector y_guess, vector theta, data array[] real x_r, array[] int x_i); vector 19 | algebra_solver_newton; (function algebra_system, vector y_guess, vector theta, data array[] real x_r, array[] int x_i, data real rel_tol, data real f_tol, int max_steps); vector 20 | append_array; (T x, T y); T 21 | append_col; (complex x, complex_row_vector y); complex_row_vector 22 | append_col; (complex_matrix x, complex_matrix y); complex_matrix 23 | append_col; (complex_matrix x, complex_vector y); complex_matrix 24 | append_col; (complex_row_vector x, complex y); complex_row_vector 25 | append_col; (complex_row_vector x, complex_row_vector y); complex_row_vector 26 | append_col; (complex_vector x, complex_matrix y); complex_matrix 27 | append_col; (complex_vector x, complex_vector y); complex_matrix 28 | append_col; (matrix x, matrix y); matrix 29 | append_col; (matrix x, vector y); matrix 30 | append_col; (real x, row_vector y); row_vector 31 | append_col; (row_vector x, real y); row_vector 32 | append_col; (row_vector x, row_vector y); row_vector 33 | append_col; (vector x, matrix y); matrix 34 | append_col; (vector x, vector y); matrix 35 | append_row; (complex x, complex_vector y); complex_vector 36 | append_row; (complex_matrix x, complex_matrix y); complex_matrix 37 | append_row; (complex_matrix x, complex_row_vector y); complex_matrix 38 | append_row; (complex_row_vector x, complex_matrix y); complex_matrix 39 | append_row; (complex_row_vector x, complex_row_vector y); complex_matrix 40 | append_row; (complex_vector x, complex y); complex_vector 41 | append_row; (complex_vector x, complex_vector y); complex_vector 42 | append_row; (matrix x, matrix y); matrix 43 | append_row; (matrix x, row_vector y); matrix 44 | append_row; (real x, vector y); vector 45 | append_row; (row_vector x, matrix y); matrix 46 | append_row; (row_vector x, row_vector y); matrix 47 | append_row; (vector x, real y); vector 48 | append_row; (vector x, vector y); vector 49 | arg; (complex z); real 50 | asin; (T x); R 51 | asin; (complex z); complex 52 | asinh; (T x); R 53 | asinh; (complex z); complex 54 | atan2; (real y, real x); real 55 | atan; (T x); R 56 | atan; (complex z); complex 57 | atanh; (T x); R 58 | atanh; (complex z); complex 59 | bernoulli; ~; real 60 | bernoulli_cdf; (ints y, reals theta); real 61 | bernoulli_lccdf; (ints y | reals theta); real 62 | bernoulli_lcdf; (ints y | reals theta); real 63 | bernoulli_logit; ~; real 64 | bernoulli_logit_glm; ~; real 65 | bernoulli_logit_glm_lpmf; (array[] int y | matrix x, real alpha, vector beta); real 66 | bernoulli_logit_glm_lpmf; (array[] int y | matrix x, vector alpha, vector beta); real 67 | bernoulli_logit_glm_lpmf; (array[] int y | row_vector x, real alpha, vector beta); real 68 | bernoulli_logit_glm_lpmf; (array[] int y | row_vector x, vector alpha, vector beta); real 69 | bernoulli_logit_glm_lpmf; (int y | matrix x, real alpha, vector beta); real 70 | bernoulli_logit_glm_lpmf; (int y | matrix x, vector alpha, vector beta); real 71 | bernoulli_logit_glm_lupmf; (array[] int y | matrix x, real alpha, vector beta); real 72 | bernoulli_logit_glm_lupmf; (array[] int y | matrix x, vector alpha, vector beta); real 73 | bernoulli_logit_glm_lupmf; (array[] int y | row_vector x, real alpha, vector beta); real 74 | bernoulli_logit_glm_lupmf; (array[] int y | row_vector x, vector alpha, vector beta); real 75 | bernoulli_logit_glm_lupmf; (int y | matrix x, real alpha, vector beta); real 76 | bernoulli_logit_glm_lupmf; (int y | matrix x, vector alpha, vector beta); real 77 | bernoulli_logit_glm_rng; (matrix x, vector alpha, vector beta); array[] int 78 | bernoulli_logit_glm_rng; (row_vector x, vector alpha, vector beta); array[] int 79 | bernoulli_logit_lpmf; (ints y | reals alpha); real 80 | bernoulli_logit_lupmf; (ints y | reals alpha); real 81 | bernoulli_logit_rng; (reals alpha); R 82 | bernoulli_lpmf; (ints y | reals theta); real 83 | bernoulli_lupmf; (ints y | reals theta); real 84 | bernoulli_rng; (reals theta); R 85 | bessel_first_kind; (T1 x, T2 y); R 86 | bessel_first_kind; (int v, real x); real 87 | bessel_second_kind; (T1 x, T2 y); R 88 | bessel_second_kind; (int v, real x); real 89 | beta; (T1 x, T2 y); R 90 | beta; (real alpha, real beta); real 91 | beta; ~; real 92 | beta_binomial; ~; real 93 | beta_binomial_cdf; (ints n, ints N, reals alpha, reals beta); real 94 | beta_binomial_lccdf; (ints n | ints N, reals alpha, reals beta); real 95 | beta_binomial_lcdf; (ints n | ints N, reals alpha, reals beta); real 96 | beta_binomial_lpmf; (ints n | ints N, reals alpha, reals beta); real 97 | beta_binomial_lupmf; (ints n | ints N, reals alpha, reals beta); real 98 | beta_binomial_rng; (ints N, reals alpha, reals beta); R 99 | beta_cdf; (reals theta, reals alpha, reals beta); real 100 | beta_lccdf; (reals theta | reals alpha, reals beta); real 101 | beta_lcdf; (reals theta | reals alpha, reals beta); real 102 | beta_lpdf; (reals theta | reals alpha, reals beta); real 103 | beta_lupdf; (reals theta | reals alpha, reals beta); real 104 | beta_proportion; ~; real 105 | beta_proportion_lccdf; (reals theta | reals mu, reals kappa); real 106 | beta_proportion_lcdf; (reals theta | reals mu, reals kappa); real 107 | beta_proportion_lpdf; ~; real 108 | beta_proportion_lupdf; ~; real 109 | beta_proportion_rng; (reals mu, reals kappa); R 110 | beta_rng; (reals alpha, reals beta); R 111 | binary_log_loss; (T1 x, T2 y); R 112 | binary_log_loss; (int y, real y_hat); real 113 | binomial; ~; real 114 | binomial_cdf; (ints n, ints N, reals theta); real 115 | binomial_lccdf; (ints n | ints N, reals theta); real 116 | binomial_lcdf; (ints n | ints N, reals theta); real 117 | binomial_logit; ~; real 118 | binomial_logit_lpmf; (ints n | ints N, reals alpha); real 119 | binomial_logit_lupmf; (ints n | ints N, reals alpha); real 120 | binomial_lpmf; (ints n | ints N, reals theta); real 121 | binomial_lupmf; (ints n | ints N, reals theta); real 122 | binomial_rng; (ints N, reals theta); R 123 | block; (complex_matrix x, int i, int j, int n_rows, int n_cols); complex_matrix 124 | block; (matrix x, int i, int j, int n_rows, int n_cols); matrix 125 | categorical; ~; real 126 | categorical_logit; ~; real 127 | categorical_logit_glm; ~; real 128 | categorical_logit_glm_lpmf; (array[] int y | matrix x, vector alpha, matrix beta); real 129 | categorical_logit_glm_lpmf; (array[] int y | row_vector x, vector alpha, matrix beta); real 130 | categorical_logit_glm_lpmf; (int y | matrix x, vector alpha, matrix beta); real 131 | categorical_logit_glm_lpmf; (int y | row_vector x, vector alpha, matrix beta); real 132 | categorical_logit_glm_lupmf; (array[] int y | matrix x, vector alpha, matrix beta); real 133 | categorical_logit_glm_lupmf; (array[] int y | row_vector x, vector alpha, matrix beta); real 134 | categorical_logit_glm_lupmf; (int y | matrix x, vector alpha, matrix beta); real 135 | categorical_logit_glm_lupmf; (int y | row_vector x, vector alpha, matrix beta); real 136 | categorical_logit_lpmf; (ints y | vector beta); real 137 | categorical_logit_lupmf; (ints y | vector beta); real 138 | categorical_logit_rng; (vector beta); int 139 | categorical_lpmf; (ints y | vector theta); real 140 | categorical_lupmf; (ints y | vector theta); real 141 | categorical_rng; (vector theta); int 142 | cauchy; ~; real 143 | cauchy_cdf; (reals y, reals mu, reals sigma); real 144 | cauchy_lccdf; (reals y | reals mu, reals sigma); real 145 | cauchy_lcdf; (reals y | reals mu, reals sigma); real 146 | cauchy_lpdf; (reals y | reals mu, reals sigma); real 147 | cauchy_lupdf; (reals y | reals mu, reals sigma); real 148 | cauchy_rng; (reals mu, reals sigma); R 149 | cbrt; (T x); R 150 | ceil; (T x); R 151 | chi_square; ~; real 152 | chi_square_cdf; (reals y, reals nu); real 153 | chi_square_lccdf; (reals y | reals nu); real 154 | chi_square_lcdf; (reals y | reals nu); real 155 | chi_square_lpdf; (reals y | reals nu); real 156 | chi_square_lupdf; (reals y | reals nu); real 157 | chi_square_rng; (reals nu); R 158 | chol2inv; (matrix L); matrix 159 | cholesky_decompose; (matrix A); matrix 160 | choose; (T1 x, T2 y); R 161 | choose; (int x, int y); int 162 | col; (complex_matrix x, int n); complex_vector 163 | col; (matrix x, int n); vector 164 | cols; (complex_matrix x); int 165 | cols; (complex_row_vector x); int 166 | cols; (complex_vector x); int 167 | cols; (matrix x); int 168 | cols; (row_vector x); int 169 | cols; (vector x); int 170 | columns_dot_product; (complex_matrix x, complex_matrix y); complex_row_vector 171 | columns_dot_product; (complex_row_vector x, complex_row_vector y); complex_row_vector 172 | columns_dot_product; (complex_vector x, complex_vector y); complex_row_vector 173 | columns_dot_product; (matrix x, matrix y); row_vector 174 | columns_dot_product; (row_vector x, row_vector y); row_vector 175 | columns_dot_product; (vector x, vector y); row_vector 176 | columns_dot_self; (complex_matrix x); complex_row_vector 177 | columns_dot_self; (complex_row_vector x); complex_row_vector 178 | columns_dot_self; (complex_vector x); complex_row_vector 179 | columns_dot_self; (matrix x); row_vector 180 | columns_dot_self; (row_vector x); row_vector 181 | columns_dot_self; (vector x); row_vector 182 | complex_schur_decompose; (complex_matrix A); tuple(complex_matrix, complex_matrix) 183 | complex_schur_decompose; (matrix A); tuple(complex_matrix, complex_matrix) 184 | complex_schur_decompose_t; (complex_matrix A); complex_matrix 185 | complex_schur_decompose_t; (matrix A); complex_matrix 186 | complex_schur_decompose_u; (complex_matrix A); complex_matrix 187 | complex_schur_decompose_u; (matrix A); complex_matrix 188 | conj; (Z z); Z 189 | conj; (complex z); complex 190 | cos; (T x); R 191 | cos; (complex z); complex 192 | cosh; (T x); R 193 | cosh; (complex z); complex 194 | cov_exp_quad; (array[] real x, real alpha, real rho); matrix 195 | cov_exp_quad; (array[] real x1, array[] real x2, real alpha, real rho); matrix 196 | cov_exp_quad; (row_vectors x, real alpha, real rho); matrix 197 | cov_exp_quad; (row_vectors x1, row_vectors x2, real alpha, real rho); matrix 198 | cov_exp_quad; (vectors x, real alpha, real rho); matrix 199 | cov_exp_quad; (vectors x1, vectors x2, real alpha, real rho); matrix 200 | crossprod; (matrix x); matrix 201 | csr_extract; (matrix a); tuple(vector, array[] int, array[] int) 202 | csr_extract_u; (matrix a); array[] int 203 | csr_extract_v; (matrix a); array[] int 204 | csr_extract_w; (matrix a); vector 205 | csr_matrix_times_vector; (int m, int n, vector w, array[] int v, array[] int u, vector b); vector 206 | csr_to_dense_matrix; (int m, int n, vector w, array[] int v, array[] int u); matrix 207 | cumulative_sum; (array[] complex x); array[] complex 208 | cumulative_sum; (array[] int x); array[] int 209 | cumulative_sum; (array[] real x); array[] real 210 | cumulative_sum; (complex_row_vector rv); complex_row_vector 211 | cumulative_sum; (complex_vector v); complex_vector 212 | cumulative_sum; (row_vector rv); row_vector 213 | cumulative_sum; (vector v); vector 214 | dae; (function residual, vector initial_state, vector initial_state_derivative, data real initial_time, data array[] real times, ...); array[] vector 215 | dae_tol; (function residual, vector initial_state, vector initial_state_derivative, data real initial_time, data array[] real times, data real rel_tol, data real abs_tol, int max_num_steps, ...); array[] vector 216 | determinant; (matrix A); real 217 | diag_matrix; (complex_vector x); complex_matrix 218 | diag_matrix; (vector x); matrix 219 | diag_post_multiply; (complex_matrix m, complex_row_vector v); complex_matrix 220 | diag_post_multiply; (complex_matrix m, complex_vector v); complex_matrix 221 | diag_post_multiply; (matrix m, row_vector rv); matrix 222 | diag_post_multiply; (matrix m, vector v); matrix 223 | diag_pre_multiply; (complex_row_vector v, complex_matrix m); complex_matrix 224 | diag_pre_multiply; (complex_vector v, complex_matrix m); complex_matrix 225 | diag_pre_multiply; (row_vector rv, matrix m); matrix 226 | diag_pre_multiply; (vector v, matrix m); matrix 227 | diagonal; (complex_matrix x); complex_vector 228 | diagonal; (matrix x); vector 229 | digamma; (T x); R 230 | dims; (T x); array[] int 231 | dirichlet; ~; real 232 | dirichlet_lpdf; (vectors theta | vectors alpha); real 233 | dirichlet_lupdf; (vectors theta | vectors alpha); real 234 | dirichlet_rng; (vector alpha); vector 235 | discrete_range; ~; real 236 | discrete_range_cdf; (ints y, ints l, ints u); real 237 | discrete_range_lccdf; (ints y | ints l, ints u); real 238 | discrete_range_lcdf; (ints y | ints l, ints u); real 239 | discrete_range_lpmf; (ints y | ints l, ints u); real 240 | discrete_range_lupmf; (ints y | ints l, ints u); real 241 | discrete_range_rng; (ints l, ints u); int 242 | distance; (row_vector x, row_vector y); real 243 | distance; (row_vector x, vector y); real 244 | distance; (vector x, row_vector y); real 245 | distance; (vector x, vector y); real 246 | dot_product; (complex_row_vector x, complex_row_vector y); complex 247 | dot_product; (complex_row_vector x, complex_vector y); complex 248 | dot_product; (complex_vector x, complex_row_vector y); complex 249 | dot_product; (complex_vector x, complex_vector y); complex 250 | dot_product; (row_vector x, row_vector y); real 251 | dot_product; (row_vector x, vector y); real 252 | dot_product; (vector x, row_vector y); real 253 | dot_product; (vector x, vector y); real 254 | dot_self; (complex_row_vector x); complex 255 | dot_self; (complex_vector x); complex 256 | dot_self; (row_vector x); real 257 | dot_self; (vector x); real 258 | double_exponential; ~; real 259 | double_exponential_cdf; (reals y, reals mu, reals sigma); real 260 | double_exponential_lccdf; (reals y | reals mu, reals sigma); real 261 | double_exponential_lcdf; (reals y | reals mu, reals sigma); real 262 | double_exponential_lpdf; (reals y | reals mu, reals sigma); real 263 | double_exponential_lupdf; (reals y | reals mu, reals sigma); real 264 | double_exponential_rng; (reals mu, reals sigma); R 265 | e; (); real 266 | eigendecompose; (complex_matrix A); tuple(complex_matrix, complex_vector) 267 | eigendecompose; (matrix A); tuple(complex_matrix, complex_vector) 268 | eigendecompose_sym; (complex_matrix A); tuple(complex_matrix, complex_vector) 269 | eigendecompose_sym; (matrix A); tuple(matrix, vector) 270 | eigenvalues; (complex_matrix A); complex_vector 271 | eigenvalues; (matrix A); complex_vector 272 | eigenvalues_sym; (complex_matrix A); complex_vector 273 | eigenvalues_sym; (matrix A); vector 274 | eigenvectors; (complex_matrix A); complex_matrix 275 | eigenvectors; (matrix A); complex_matrix 276 | eigenvectors_sym; (complex_matrix A); complex_matrix 277 | eigenvectors_sym; (matrix A); matrix 278 | erf; (T x); R 279 | erfc; (T x); R 280 | exp2; (T x); R 281 | exp; (T x); R 282 | exp; (complex z); complex 283 | exp_mod_normal; ~; real 284 | exp_mod_normal_cdf; (reals y, reals mu, reals sigma, reals lambda); real 285 | exp_mod_normal_lccdf; (reals y | reals mu, reals sigma, reals lambda); real 286 | exp_mod_normal_lcdf; (reals y | reals mu, reals sigma, reals lambda); real 287 | exp_mod_normal_lpdf; (reals y | reals mu, reals sigma, reals lambda); real 288 | exp_mod_normal_lupdf; (reals y | reals mu, reals sigma, reals lambda); real 289 | exp_mod_normal_rng; (reals mu, reals sigma, reals lambda); R 290 | expm1; (T x); R 291 | exponential; ~; real 292 | exponential_cdf; (reals y, reals beta); real 293 | exponential_lccdf; (reals y | reals beta); real 294 | exponential_lcdf; (reals y | reals beta); real 295 | exponential_lpdf; (reals y | reals beta); real 296 | exponential_lupdf; (reals y | reals beta); real 297 | exponential_rng; (reals beta); R 298 | falling_factorial; (T1 x, T2 y); R 299 | falling_factorial; (real x, real n); real 300 | fdim; (T1 x, T2 y); R 301 | fdim; (real x, real y); real 302 | fft2; (complex_matrix m); complex_matrix 303 | fft; (complex_vector v); complex_vector 304 | floor; (T x); R 305 | fma; (real x, real y, real z); real 306 | fmax; (T1 x, T2 y); R 307 | fmax; (real x, real y); real 308 | fmin; (T1 x, T2 y); R 309 | fmin; (real x, real y); real 310 | fmod; (T1 x, T2 y); R 311 | fmod; (real x, real y); real 312 | frechet; ~; real 313 | frechet_cdf; (reals y, reals alpha, reals sigma); real 314 | frechet_lccdf; (reals y | reals alpha, reals sigma); real 315 | frechet_lcdf; (reals y | reals alpha, reals sigma); real 316 | frechet_lpdf; (reals y | reals alpha, reals sigma); real 317 | frechet_lupdf; (reals y | reals alpha, reals sigma); real 318 | frechet_rng; (reals alpha, reals sigma); R 319 | gamma; ~; real 320 | gamma_cdf; (reals y, reals alpha, reals beta); real 321 | gamma_lccdf; (reals y | reals alpha, reals beta); real 322 | gamma_lcdf; (reals y | reals alpha, reals beta); real 323 | gamma_lpdf; (reals y | reals alpha, reals beta); real 324 | gamma_lupdf; (reals y | reals alpha, reals beta); real 325 | gamma_p; (T1 x, T2 y); R 326 | gamma_p; (real a, real z); real 327 | gamma_q; (T1 x, T2 y); R 328 | gamma_q; (real a, real z); real 329 | gamma_rng; (reals alpha, reals beta); R 330 | gaussian_dlm_obs; ~; real 331 | gaussian_dlm_obs_lpdf; (matrix y | matrix F, matrix G, matrix V, matrix W, vector m0, matrix C0); real 332 | gaussian_dlm_obs_lpdf; (matrix y | matrix F, matrix G, vector V, matrix W, vector m0, matrix C0); real 333 | gaussian_dlm_obs_lupdf; (matrix y | matrix F, matrix G, matrix V, matrix W, vector m0, matrix C0); real 334 | gaussian_dlm_obs_lupdf; (matrix y | matrix F, matrix G, vector V, matrix W, vector m0, matrix C0); real 335 | generalized_inverse; (matrix A); matrix 336 | get_imag; (T x); T 337 | get_imag; (complex z); real 338 | get_real; (T x); T 339 | get_real; (complex z); real 340 | gumbel; ~; real 341 | gumbel_cdf; (reals y, reals mu, reals beta); real 342 | gumbel_lccdf; (reals y | reals mu, reals beta); real 343 | gumbel_lcdf; (reals y | reals mu, reals beta); real 344 | gumbel_lpdf; (reals y | reals mu, reals beta); real 345 | gumbel_lupdf; (reals y | reals mu, reals beta); real 346 | gumbel_rng; (reals mu, reals beta); R 347 | head; (array[] T sv, int n); array[] T 348 | head; (complex_row_vector rv, int n); complex_row_vector 349 | head; (complex_vector v, int n); complex_vector 350 | head; (row_vector rv, int n); row_vector 351 | head; (vector v, int n); vector 352 | hmm_hidden_state_prob; (matrix log_omega, matrix Gamma, vector rho); matrix 353 | hmm_latent_rng; (matrix log_omega, matrix Gamma, vector rho); array[] int 354 | hmm_marginal; (matrix log_omega, matrix Gamma, vector rho); real 355 | hypergeometric; ~; real 356 | hypergeometric_lpmf; (int n | int N, int a, int b); real 357 | hypergeometric_lupmf; (int n | int N, int a, int b); real 358 | hypergeometric_rng; (int N, int a, int2 b); int 359 | hypot; (T1 x, T2 y); R 360 | hypot; (real x, real y); real 361 | identity_matrix; (int k); matrix 362 | inc_beta; (real alpha, real beta, real x); real 363 | int_step; (int x); int 364 | int_step; (real x); int 365 | integrate_1d; (function integrand, real a, real b, array[] real theta, array[] real x_r, array[] int x_i), real relative_tolerance); real 366 | integrate_1d; (function integrand, real a, real b, array[] real theta, array[] real x_r, array[] int x_i); real 367 | 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); array[,] real 368 | 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); array[,] real 369 | 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); array[,] real 370 | 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); array[,] real 371 | 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); array[,] real 372 | 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); array[,] real 373 | 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); array[,] real 374 | inv; (T x); R 375 | inv_Phi; (T x); R 376 | inv_chi_square; ~; real 377 | inv_chi_square_cdf; (reals y, reals nu); real 378 | inv_chi_square_lccdf; (reals y | reals nu); real 379 | inv_chi_square_lcdf; (reals y | reals nu); real 380 | inv_chi_square_lpdf; (reals y | reals nu); real 381 | inv_chi_square_lupdf; (reals y | reals nu); real 382 | inv_chi_square_rng; (reals nu); R 383 | inv_cloglog; (T x); R 384 | inv_erfc; (T x); R 385 | inv_fft2; (complex_matrix m); complex_matrix 386 | inv_fft; (complex_vector u); complex_vector 387 | inv_gamma; ~; real 388 | inv_gamma_cdf; (reals y, reals alpha, reals beta); real 389 | inv_gamma_lccdf; (reals y | reals alpha, reals beta); real 390 | inv_gamma_lcdf; (reals y | reals alpha, reals beta); real 391 | inv_gamma_lpdf; (reals y | reals alpha, reals beta); real 392 | inv_gamma_lupdf; (reals y | reals alpha, reals beta); real 393 | inv_gamma_rng; (reals alpha, reals beta); R 394 | inv_inc_beta; (real alpha, real beta, real p); real 395 | inv_logit; (T x); R 396 | inv_sqrt; (T x); R 397 | inv_square; (T x); R 398 | inv_wishart; ~; real 399 | inv_wishart_cholesky_lpdf; (matrix L_W | real nu, matrix L_S); real 400 | inv_wishart_cholesky_lupdf; (matrix L_W | real nu, matrix L_S); real 401 | inv_wishart_cholesky_rng; (real nu, matrix L_S); matrix 402 | inv_wishart_lpdf; (matrix W | real nu, matrix Sigma); real 403 | inv_wishart_lupdf; (matrix W | real nu, matrix Sigma); real 404 | inv_wishart_rng; (real nu, matrix Sigma); matrix 405 | inverse; (matrix A); matrix 406 | inverse_spd; (matrix A); matrix 407 | is_inf; (real x); int 408 | is_nan; (real x); int 409 | lambert_w0; (reals x); R 410 | lambert_wm1; (T x); R 411 | lbeta; (T1 x, T2 y); R 412 | lbeta; (real alpha, real beta); real 413 | lchoose; (T1 x, T2 y); R 414 | lchoose; (real x, real y); real 415 | ldexp; (T1 x, T2 y); R 416 | ldexp; (real x, int y); real 417 | lgamma; (T x); R 418 | linspaced_array; (int n, data real lower, data real upper); array[] real 419 | linspaced_int_array; (int n, int lower, int upper); array[] real 420 | linspaced_row_vector; (int n, data real lower, data real upper); row_vector 421 | linspaced_vector; (int n, data real lower, data real upper); vector 422 | lkj_corr; ~; real 423 | lkj_corr_cholesky; ~; real 424 | lkj_corr_cholesky_lpdf; (matrix L | real eta); real 425 | lkj_corr_cholesky_lupdf; (matrix L | real eta); real 426 | lkj_corr_cholesky_rng; (int K, real eta); matrix 427 | lkj_corr_lpdf; (matrix y | real eta); real 428 | lkj_corr_lupdf; (matrix y | real eta); real 429 | lkj_corr_rng; (int K, real eta); matrix 430 | lmgamma; (T1 x, T2 y); R 431 | lmgamma; (int n, real x); real 432 | lmultiply; (T1 x, T2 y); R 433 | lmultiply; (real x, real y); real 434 | log10; (); real 435 | log10; (T x); R 436 | log10; (complex z); complex 437 | log1m; (T x); R 438 | log1m_exp; (T x); R 439 | log1m_inv_logit; (T x); R 440 | log1p; (T x); R 441 | log1p_exp; (T x); R 442 | log2; (); real 443 | log2; (T x); R 444 | log; (T x); R 445 | log; (complex z); complex 446 | log_determinant; (matrix A); real 447 | log_diff_exp; (T1 x, T2 y); R 448 | log_diff_exp; (real x, real y); real 449 | log_falling_factorial; (real x, real n); real 450 | log_inv_logit; (T x); R 451 | log_inv_logit_diff; (T1 x, T2 y); R 452 | log_mix; (T1 theta, T2 lp1, T3 lp2); R 453 | log_mix; (real theta, real lp1, real lp2); real 454 | log_modified_bessel_first_kind; (T1 x, T2 y); R 455 | log_modified_bessel_first_kind; (real v, real z); real 456 | log_rising_factorial; (T1 x, T2 y); R 457 | log_rising_factorial; (real x, real n); real 458 | log_softmax; (vector x); vector 459 | log_sum_exp; (T1 x, T2 y); R 460 | log_sum_exp; (array[] real x); real 461 | log_sum_exp; (matrix x); real 462 | log_sum_exp; (row_vector x); real 463 | log_sum_exp; (vector x); real 464 | logistic; ~; real 465 | logistic_cdf; (reals y, reals mu, reals sigma); real 466 | logistic_lccdf; (reals y | reals mu, reals sigma); real 467 | logistic_lcdf; (reals y | reals mu, reals sigma); real 468 | logistic_lpdf; (reals y | reals mu, reals sigma); real 469 | logistic_lupdf; (reals y | reals mu, reals sigma); real 470 | logistic_rng; (reals mu, reals sigma); R 471 | logit; (T x); R 472 | loglogistic; ~; real 473 | loglogistic_cdf; (reals y, reals alpha, reals beta); real 474 | loglogistic_lpdf; (reals y | reals alpha, reals beta); real 475 | loglogistic_rng; (reals mu, reals sigma); R 476 | lognormal; ~; real 477 | lognormal_cdf; (reals y, reals mu, reals sigma); real 478 | lognormal_lccdf; (reals y | reals mu, reals sigma); real 479 | lognormal_lcdf; (reals y | reals mu, reals sigma); real 480 | lognormal_lpdf; (reals y | reals mu, reals sigma); real 481 | lognormal_lupdf; (reals y | reals mu, reals sigma); real 482 | lognormal_rng; (reals mu, reals sigma); R 483 | machine_precision; (); real 484 | map_rect; (F f, vector phi, array[] vector theta, data array[,] real x_r, data array[,] int x_i); vector 485 | matrix_exp; (matrix A); matrix 486 | matrix_exp_multiply; (matrix A, matrix B); matrix 487 | matrix_power; (matrix A, int B); matrix 488 | max; (array[] int x); int 489 | max; (array[] real x); real 490 | max; (int x, int y); int 491 | max; (matrix x); real 492 | max; (row_vector x); real 493 | max; (vector x); real 494 | mdivide_left_spd; (matrix A, matrix B); vector 495 | mdivide_left_spd; (matrix A, vector b); matrix 496 | mdivide_left_tri_low; (matrix A, matrix B); matrix 497 | mdivide_left_tri_low; (matrix A, vector b); vector 498 | mdivide_right_spd; (matrix B, matrix A); matrix 499 | mdivide_right_spd; (row_vector b, matrix A); row_vector 500 | mdivide_right_tri_low; (matrix B, matrix A); matrix 501 | mdivide_right_tri_low; (row_vector b, matrix A); row_vector 502 | mean; (array[] real x); real 503 | mean; (matrix x); real 504 | mean; (row_vector x); real 505 | mean; (vector x); real 506 | min; (array[] int x); int 507 | min; (array[] real x); real 508 | min; (int x, int y); int 509 | min; (matrix x); real 510 | min; (row_vector x); real 511 | min; (vector x); real 512 | modified_bessel_first_kind; (T1 x, T2 y); R 513 | modified_bessel_first_kind; (int v, real z); real 514 | modified_bessel_second_kind; (T1 x, T2 y); R 515 | modified_bessel_second_kind; (int v, real z); real 516 | multi_gp; ~; real 517 | multi_gp_cholesky; ~; real 518 | multi_gp_cholesky_lpdf; (matrix y | matrix L, vector w); real 519 | multi_gp_cholesky_lupdf; (matrix y | matrix L, vector w); real 520 | multi_gp_lpdf; (matrix y | matrix Sigma, vector w); real 521 | multi_gp_lupdf; (matrix y | matrix Sigma, vector w); real 522 | multi_normal; ~; real 523 | multi_normal_cholesky; ~; real 524 | multi_normal_cholesky_lpdf; (row_vectors y | row_vectors mu, matrix L); real 525 | multi_normal_cholesky_lpdf; (row_vectors y | vectors mu, matrix L); real 526 | multi_normal_cholesky_lpdf; (vectors y | row_vectors mu, matrix L); real 527 | multi_normal_cholesky_lpdf; (vectors y | vectors mu, matrix L); real 528 | multi_normal_cholesky_lupdf; (row_vectors y | row_vectors mu, matrix L); real 529 | multi_normal_cholesky_lupdf; (row_vectors y | vectors mu, matrix L); real 530 | multi_normal_cholesky_lupdf; (vectors y | row_vectors mu, matrix L); real 531 | multi_normal_cholesky_lupdf; (vectors y | vectors mu, matrix L); real 532 | multi_normal_cholesky_rng; (row_vector mu, matrix L); vector 533 | multi_normal_cholesky_rng; (row_vectors mu, matrix L); vectors 534 | multi_normal_cholesky_rng; (vector mu, matrix L); vector 535 | multi_normal_cholesky_rng; (vectors mu, matrix L); vectors 536 | multi_normal_lpdf; (row_vectors y | row_vectors mu, matrix Sigma); real 537 | multi_normal_lpdf; (row_vectors y | vectors mu, matrix Sigma); real 538 | multi_normal_lpdf; (vectors y | row_vectors mu, matrix Sigma); real 539 | multi_normal_lpdf; (vectors y | vectors mu, matrix Sigma); real 540 | multi_normal_lupdf; (row_vectors y | row_vectors mu, matrix Sigma); real 541 | multi_normal_lupdf; (row_vectors y | vectors mu, matrix Sigma); real 542 | multi_normal_lupdf; (vectors y | row_vectors mu, matrix Sigma); real 543 | multi_normal_lupdf; (vectors y | vectors mu, matrix Sigma); real 544 | multi_normal_prec; ~; real 545 | multi_normal_prec_lpdf; (row_vectors y | row_vectors mu, matrix Omega); real 546 | multi_normal_prec_lpdf; (row_vectors y | vectors mu, matrix Omega); real 547 | multi_normal_prec_lpdf; (vectors y | row_vectors mu, matrix Omega); real 548 | multi_normal_prec_lpdf; (vectors y | vectors mu, matrix Omega); real 549 | multi_normal_prec_lupdf; (row_vectors y | row_vectors mu, matrix Omega); real 550 | multi_normal_prec_lupdf; (row_vectors y | vectors mu, matrix Omega); real 551 | multi_normal_prec_lupdf; (vectors y | row_vectors mu, matrix Omega); real 552 | multi_normal_prec_lupdf; (vectors y | vectors mu, matrix Omega); real 553 | multi_normal_rng; (row_vector mu, matrix Sigma); vector 554 | multi_normal_rng; (row_vectors mu, matrix Sigma); vectors 555 | multi_normal_rng; (vector mu, matrix Sigma); vector 556 | multi_normal_rng; (vectors mu, matrix Sigma); vectors 557 | multi_student_cholesky_t_rng; (real nu, vector mu, matrix L); vector 558 | multi_student_t; ~; real 559 | multi_student_t_cholesky; ~; real 560 | multi_student_t_cholesky_lpdf; (vectors y | real nu, vectors mu, matrix L); real 561 | multi_student_t_cholesky_lupdf; (vectors y | real nu, vectors mu, matrix L); real 562 | multi_student_t_cholesky_rng; (real nu, array[] row_vector mu, matrix L); array[] vector 563 | multi_student_t_cholesky_rng; (real nu, array[] vector mu, matrix L); array[] vector 564 | multi_student_t_lpdf; (row_vectors y | real nu, row_vectors mu, matrix Sigma); real 565 | multi_student_t_lpdf; (row_vectors y | real nu, vectors mu, matrix Sigma); real 566 | multi_student_t_lpdf; (vectors y | real nu, row_vectors mu, matrix Sigma); real 567 | multi_student_t_lpdf; (vectors y | real nu, vectors mu, matrix Sigma); real 568 | multi_student_t_lupdf; (row_vectors y | real nu, row_vectors mu, matrix Sigma); real 569 | multi_student_t_lupdf; (row_vectors y | real nu, vectors mu, matrix Sigma); real 570 | multi_student_t_lupdf; (vectors y | real nu, row_vectors mu, matrix Sigma); real 571 | multi_student_t_lupdf; (vectors y | real nu, vectors mu, matrix Sigma); real 572 | multi_student_t_rng; (real nu, row_vector mu, matrix Sigma); vector 573 | multi_student_t_rng; (real nu, row_vectors mu, matrix Sigma); vectors 574 | multi_student_t_rng; (real nu, vector mu, matrix Sigma); vector 575 | multi_student_t_rng; (real nu, vectors mu, matrix Sigma); vectors 576 | multinomial; ~; real 577 | multinomial_logit; ~; real 578 | multinomial_logit_lpmf; (array[] int y | vector gamma); real 579 | multinomial_logit_lupmf; (array[] int y | vector gamma); real 580 | multinomial_logit_rng; (vector gamma, int N); array[] int 581 | multinomial_lpmf; (array[] int y | vector theta); real 582 | multinomial_lupmf; (array[] int y | vector theta); real 583 | multinomial_rng; (vector theta, int N); array[] int 584 | multiply_lower_tri_self_transpose; (matrix x); matrix 585 | neg_binomial; ~; real 586 | neg_binomial_2; ~; real 587 | neg_binomial_2_cdf; (ints n, reals mu, reals phi); real 588 | neg_binomial_2_lccdf; (ints n | reals mu, reals phi); real 589 | neg_binomial_2_lcdf; (ints n | reals mu, reals phi); real 590 | neg_binomial_2_log; ~; real 591 | neg_binomial_2_log_glm; ~; real 592 | neg_binomial_2_log_glm_lpmf; (array[] int y | matrix x, real alpha, vector beta, real phi); real 593 | neg_binomial_2_log_glm_lpmf; (array[] int y | matrix x, vector alpha, vector beta, real phi); real 594 | neg_binomial_2_log_glm_lpmf; (array[] int y | row_vector x, real alpha, vector beta, real phi); real 595 | neg_binomial_2_log_glm_lpmf; (array[] int y | row_vector x, vector alpha, vector beta, real phi); real 596 | neg_binomial_2_log_glm_lpmf; (int y | matrix x, real alpha, vector beta, real phi); real 597 | neg_binomial_2_log_glm_lpmf; (int y | matrix x, vector alpha, vector beta, real phi); real 598 | neg_binomial_2_log_glm_lupmf; (array[] int y | matrix x, real alpha, vector beta, real phi); real 599 | neg_binomial_2_log_glm_lupmf; (array[] int y | matrix x, vector alpha, vector beta, real phi); real 600 | neg_binomial_2_log_glm_lupmf; (array[] int y | row_vector x, real alpha, vector beta, real phi); real 601 | neg_binomial_2_log_glm_lupmf; (array[] int y | row_vector x, vector alpha, vector beta, real phi); real 602 | neg_binomial_2_log_glm_lupmf; (int y | matrix x, real alpha, vector beta, real phi); real 603 | neg_binomial_2_log_glm_lupmf; (int y | matrix x, vector alpha, vector beta, real phi); real 604 | neg_binomial_2_log_lpmf; (ints n | reals eta, reals phi); real 605 | neg_binomial_2_log_lupmf; (ints n | reals eta, reals phi); real 606 | neg_binomial_2_log_rng; (reals eta, reals phi); R 607 | neg_binomial_2_lpmf; (ints n | reals mu, reals phi); real 608 | neg_binomial_2_lupmf; (ints n | reals mu, reals phi); real 609 | neg_binomial_2_rng; (reals mu, reals phi); R 610 | neg_binomial_cdf; (ints n, reals alpha, reals beta); real 611 | neg_binomial_lccdf; (ints n | reals alpha, reals beta); real 612 | neg_binomial_lcdf; (ints n | reals alpha, reals beta); real 613 | neg_binomial_lpmf; (ints n | reals alpha, reals beta); real 614 | neg_binomial_lupmf; (ints n | reals alpha, reals beta); real 615 | neg_binomial_rng; (reals alpha, reals beta); R 616 | negative_infinity; (); real 617 | norm1; (array[] real x); real 618 | norm1; (row_vector x); real 619 | norm1; (vector x); real 620 | norm2; (array[] real x); real 621 | norm2; (row_vector x); real 622 | norm2; (vector x); real 623 | norm; (complex z); real 624 | normal; ~; real 625 | normal_cdf; (reals y, reals mu, reals sigma); real 626 | normal_id_glm; ~; real 627 | normal_id_glm_lpdf; (real y | matrix x, real alpha, vector beta, real sigma); real 628 | normal_id_glm_lpdf; (real y | matrix x, real alpha, vector beta, vector sigma); real 629 | normal_id_glm_lpdf; (real y | matrix x, vector alpha, vector beta, real sigma); real 630 | normal_id_glm_lpdf; (real y | matrix x, vector alpha, vector beta, vector sigma); real 631 | normal_id_glm_lpdf; (vector y | matrix x, real alpha, vector beta, real sigma); real 632 | normal_id_glm_lpdf; (vector y | matrix x, real alpha, vector beta, vector sigma); real 633 | normal_id_glm_lpdf; (vector y | matrix x, vector alpha, vector beta, real sigma); real 634 | normal_id_glm_lpdf; (vector y | matrix x, vector alpha, vector beta, vector sigma); real 635 | normal_id_glm_lpdf; (vector y | row_vector x, real alpha, vector beta, real sigma); real 636 | normal_id_glm_lpdf; (vector y | row_vector x, vector alpha, vector beta, real sigma); real 637 | normal_id_glm_lupdf; (real y | matrix x, real alpha, vector beta, real sigma); real 638 | normal_id_glm_lupdf; (real y | matrix x, real alpha, vector beta, vector sigma); real 639 | normal_id_glm_lupdf; (real y | matrix x, vector alpha, vector beta, real sigma); real 640 | normal_id_glm_lupdf; (real y | matrix x, vector alpha, vector beta, vector sigma); real 641 | normal_id_glm_lupdf; (vector y | matrix x, real alpha, vector beta, real sigma); real 642 | normal_id_glm_lupdf; (vector y | matrix x, real alpha, vector beta, vector sigma); real 643 | normal_id_glm_lupdf; (vector y | matrix x, vector alpha, vector beta, real sigma); real 644 | normal_id_glm_lupdf; (vector y | matrix x, vector alpha, vector beta, vector sigma); real 645 | normal_id_glm_lupdf; (vector y | row_vector x, real alpha, vector beta, real sigma); real 646 | normal_id_glm_lupdf; (vector y | row_vector x, vector alpha, vector beta, real sigma); real 647 | normal_lccdf; (reals y | reals mu, reals sigma); real 648 | normal_lcdf; (reals y | reals mu, reals sigma); real 649 | normal_lpdf; (reals y | reals mu, reals sigma); real 650 | normal_lupdf; (reals y | reals mu, reals sigma); real 651 | normal_rng; (reals mu, reals sigma); R 652 | not_a_number; (); real 653 | num_elements; (array[] T x); int 654 | num_elements; (complex_matrix x); int 655 | num_elements; (complex_row_vector x); int 656 | num_elements; (complex_vector x); int 657 | num_elements; (matrix x); int 658 | num_elements; (row_vector x); int 659 | num_elements; (vector x); int 660 | ode_adams; (function ode, vector initial_state, real initial_time, array[] real times, ...); array[] vector 661 | ode_adams_tol; (function ode, vector initial_state, real initial_time, array[] real times, data real rel_tol, data real abs_tol, int max_num_steps, ...); array[] vector 662 | ode_adjoint_tol_ctl; (function ode, vector initial_state, real initial_time, array[] real times, data real rel_tol_forward, data vector abs_tol_forward, data real rel_tol_backward, data vector abs_tol_backward, data real rel_tol_quadrature, data real abs_tol_qudrature, int max_num_steps, int num_steps_between_checkpoints, int interpolation_polynomial, int solver_forward, int solver_backward,...); array[] vector 663 | ode_bdf; (function ode, vector initial_state, real initial_time, array[] real times, ...); array[] vector 664 | ode_bdf_tol; (function ode, vector initial_state, real initial_time, array[] real times, data real rel_tol, data real abs_tol, int max_num_steps, ...); array[] vector 665 | ode_ckrk; (function ode, vector initial_state, real initial_time, array[] real times, ...); array[] vector 666 | ode_ckrk_tol; (function ode, vector initial_state, real initial_time, array[] real times, data real rel_tol, data real abs_tol, int max_num_steps, ...); array[] vector 667 | ode_rk45; (function ode, vector initial_state, real initial_time, array[] real times, ...); array[] vector 668 | ode_rk45_tol; (function ode, vector initial_state, real initial_time, array[] real times, data real rel_tol, data real abs_tol, int max_num_steps, ...); array[] vector 669 | one_hot_array; (int n, int k); array[] real 670 | one_hot_int_array; (int n, int k); array[] int 671 | one_hot_row_vector; (int n, int k); row_vector 672 | one_hot_vector; (int K, int k); vector 673 | ones_array; (int n); array[] real 674 | ones_int_array; (int n); array[] int 675 | ones_row_vector; (int n); row_vector 676 | ones_vector; (int n); vector 677 | operator!; (int x); int 678 | operator!; (real x); int 679 | operator!=; (complex x, complex y); int 680 | operator!=; (int x, int y); int 681 | operator!=; (real x, real y); int 682 | operator%/%; (int x, int y); int 683 | operator%; (int x, int y); int 684 | operator&&; (int x, int y); int 685 | operator&&; (real x, real y); int 686 | operator'; (complex_matrix x); complex_matrix 687 | operator'; (complex_row_vector x); complex_vector 688 | operator'; (complex_vector x); complex_row_vector 689 | operator'; (matrix x); matrix 690 | operator'; (row_vector x); vector 691 | operator'; (vector x); row_vector 692 | operator*; (complex x, complex y); complex 693 | operator*; (complex x, complex_matrix y); complex_matrix 694 | operator*; (complex x, complex_row_vector y); complex_row_vector 695 | operator*; (complex x, complex_vector y); complex_vector 696 | operator*; (complex_matrix x, complex y); complex_matrix 697 | operator*; (complex_matrix x, complex_matrix y); complex_matrix 698 | operator*; (complex_matrix x, complex_vector y); complex_vector 699 | operator*; (complex_row_vector x, complex y); complex_row_vector 700 | operator*; (complex_row_vector x, complex_matrix y); complex_row_vector 701 | operator*; (complex_row_vector x, complex_vector y); complex 702 | operator*; (complex_vector x, complex y); complex_vector 703 | operator*; (complex_vector x, complex_row_vector y); complex_matrix 704 | operator*; (int x, int y); int 705 | operator*; (matrix x, matrix y); matrix 706 | operator*; (matrix x, real y); matrix 707 | operator*; (matrix x, vector y); vector 708 | operator*; (real x, matrix y); matrix 709 | operator*; (real x, real y); real 710 | operator*; (real x, row_vector y); row_vector 711 | operator*; (real x, vector y); vector 712 | operator*; (row_vector x, matrix y); row_vector 713 | operator*; (row_vector x, real y); row_vector 714 | operator*; (row_vector x, vector y); real 715 | operator*; (vector x, real y); vector 716 | operator*; (vector x, row_vector y); matrix 717 | operator*=; (T x, U y); void 718 | operator*=; (complex x, complex y); void 719 | operator+; (complex x, complex y); complex 720 | operator+; (complex x, complex_matrix y); complex_matrix 721 | operator+; (complex x, complex_row_vector y); complex_row_vector 722 | operator+; (complex x, complex_vector y); complex_vector 723 | operator+; (complex z); complex 724 | operator+; (complex_matrix x, complex y); complex_matrix 725 | operator+; (complex_matrix x, complex_matrix y); complex_matrix 726 | operator+; (complex_row_vector x, complex y); complex_row_vector 727 | operator+; (complex_row_vector x, complex_row_vector y); complex_row_vector 728 | operator+; (complex_vector x, complex y); complex_vector 729 | operator+; (complex_vector x, complex_vector y); complex_vector 730 | operator+; (int x); int 731 | operator+; (int x, int y); int 732 | operator+; (matrix x, matrix y); matrix 733 | operator+; (matrix x, real y); matrix 734 | operator+; (real x); real 735 | operator+; (real x, matrix y); matrix 736 | operator+; (real x, real y); real 737 | operator+; (real x, row_vector y); row_vector 738 | operator+; (real x, vector y); vector 739 | operator+; (row_vector x, real y); row_vector 740 | operator+; (row_vector x, row_vector y); row_vector 741 | operator+; (vector x, real y); vector 742 | operator+; (vector x, vector y); vector 743 | operator+=; (T x, U y); void 744 | operator+=; (complex x, complex y); void 745 | operator-; (T x); T 746 | operator-; (complex x, complex y); complex 747 | operator-; (complex x, complex_matrix y); complex_matrix 748 | operator-; (complex x, complex_row_vector y); complex_row_vector 749 | operator-; (complex x, complex_vector y); complex_vector 750 | operator-; (complex z); complex 751 | operator-; (complex_matrix x); complex_matrix 752 | operator-; (complex_matrix x, complex y); complex_matrix 753 | operator-; (complex_matrix x, complex_matrix y); complex_matrix 754 | operator-; (complex_row_vector x); complex_row_vector 755 | operator-; (complex_row_vector x, complex y); complex_row_vector 756 | operator-; (complex_row_vector x, complex_row_vector y); complex_row_vector 757 | operator-; (complex_vector x); complex_vector 758 | operator-; (complex_vector x, complex y); complex_vector 759 | operator-; (complex_vector x, complex_vector y); complex_vector 760 | operator-; (int x); int 761 | operator-; (int x, int y); int 762 | operator-; (matrix x); matrix 763 | operator-; (matrix x, matrix y); matrix 764 | operator-; (matrix x, real y); matrix 765 | operator-; (real x); real 766 | operator-; (real x, matrix y); matrix 767 | operator-; (real x, real y); real 768 | operator-; (real x, row_vector y); row_vector 769 | operator-; (real x, vector y); vector 770 | operator-; (row_vector x); row_vector 771 | operator-; (row_vector x, real y); row_vector 772 | operator-; (row_vector x, row_vector y); row_vector 773 | operator-; (vector x); vector 774 | operator-; (vector x, real y); vector 775 | operator-; (vector x, vector y); vector 776 | operator-=; (T x, U y); void 777 | operator-=; (complex x, complex y); void 778 | operator.*; (complex_matrix x, complex_matrix y); complex_matrix 779 | operator.*; (complex_row_vector x, complex_row_vector y); complex_row_vector 780 | operator.*; (complex_vector x, complex_vector y); complex_vector 781 | operator.*; (matrix x, matrix y); matrix 782 | operator.*; (row_vector x, row_vector y); row_vector 783 | operator.*; (vector x, vector y); vector 784 | operator.*=; (T x, U y); void 785 | operator./; (complex x, complex_matrix y); complex_matrix 786 | operator./; (complex x, complex_row_vector y); complex_row_vector 787 | operator./; (complex x, complex_vector y); complex_vector 788 | operator./; (complex_matrix x, complex y); complex_matrix 789 | operator./; (complex_matrix x, complex_matrix y); complex_matrix 790 | operator./; (complex_row_vector x, complex y); complex_row_vector 791 | operator./; (complex_row_vector x, complex_row_vector y); complex_row_vector 792 | operator./; (complex_vector x, complex y); complex_vector 793 | operator./; (complex_vector x, complex_vector y); complex_vector 794 | operator./; (matrix x, matrix y); matrix 795 | operator./; (matrix x, real y); matrix 796 | operator./; (real x, matrix y); matrix 797 | operator./; (real x, row_vector y); row_vector 798 | operator./; (real x, vector y); vector 799 | operator./; (row_vector x, real y); row_vector 800 | operator./; (row_vector x, row_vector y); row_vector 801 | operator./; (vector x, real y); vector 802 | operator./; (vector x, vector y); vector 803 | operator./=; (T x, U y); void 804 | operator.^; ( complex_matrix x, complex y); complex_matrix 805 | operator.^; ( complex_matrix x, complex_matrix y); complex_matrix 806 | operator.^; (complex x, complex_matrix y); complex_matrix 807 | operator.^; (complex x, complex_row_vector y); complex_row_vector 808 | operator.^; (complex x, complex_vector y); complex_vector 809 | operator.^; (complex_row_vector x, complex y); complex_row_vector 810 | operator.^; (complex_row_vector x, complex_row_vector y); complex_row_vector 811 | operator.^; (complex_vector x, complex y); complex_vector 812 | operator.^; (complex_vector x, complex_vector y); complex_vector 813 | operator.^; (matrix x, matrix y); matrix 814 | operator.^; (matrix x, real y); matrix 815 | operator.^; (real x, matrix y); matrix 816 | operator.^; (real x, row_vector y); row_vector 817 | operator.^; (real x, vector y); vector 818 | operator.^; (row_vector x, real y); row_vector 819 | operator.^; (row_vector x, row_vector y); row_vector 820 | operator.^; (vector x, real y); vector 821 | operator.^; (vector x, vector y); vector 822 | operator/; (complex x, complex y); complex 823 | operator/; (complex_matrix B, complex_matrix A); complex_matrix 824 | operator/; (complex_matrix x, complex y); complex_matrix 825 | operator/; (complex_row_vector b, complex_matrix A); complex_row_vector 826 | operator/; (complex_row_vector x, complex y); complex_row_vector 827 | operator/; (complex_vector x, complex y); complex_vector 828 | operator/; (int x, int y); int 829 | operator/; (matrix B, matrix A); matrix 830 | operator/; (matrix x, real y); matrix 831 | operator/; (real x, real y); real 832 | operator/; (row_vector b, matrix A); row_vector 833 | operator/; (row_vector x, real y); row_vector 834 | operator/; (vector x, real y); vector 835 | operator/=; (T x, U y); void 836 | operator/=; (complex x, complex y); void 837 | operator<; (int x, int y); int 838 | operator<; (real x, real y); int 839 | operator<=; (int x, int y); int 840 | operator<=; (real x, real y); int 841 | operator=; (complex x, complex y); void 842 | operator==; (complex x, complex y); int 843 | operator==; (int x, int y); int 844 | operator==; (real x, real y); int 845 | operator>; (int x, int y); int 846 | operator>; (real x, real y); int 847 | operator>=; (int x, int y); int 848 | operator>=; (real x, real y); int 849 | operator\; (matrix A, matrix B); matrix 850 | operator\; (matrix A, vector b); vector 851 | operator^; (complex x, complex y); complex 852 | operator^; (real x, real y); real 853 | operator||; (int x, int y); int 854 | operator||; (real x, real y); int 855 | ordered_logistic; ~; real 856 | ordered_logistic_glm_lpmf; (array[] int y | matrix x, vector beta, vector c); real 857 | ordered_logistic_glm_lpmf; (array[] int y | row_vector x, vector beta, vector c); real 858 | ordered_logistic_glm_lpmf; (int y | matrix x, vector beta, vector c); real 859 | ordered_logistic_glm_lpmf; (int y | row_vector x, vector beta, vector c); real 860 | ordered_logistic_glm_lupmf; (array[] int y | matrix x, vector beta, vector c); real 861 | ordered_logistic_glm_lupmf; (array[] int y | row_vector x, vector beta, vector c); real 862 | ordered_logistic_glm_lupmf; (int y | matrix x, vector beta, vector c); real 863 | ordered_logistic_glm_lupmf; (int y | row_vector x, vector beta, vector c); real 864 | ordered_logistic_lpmf; (ints k | vector eta, vectors c); real 865 | ordered_logistic_lupmf; (ints k | vector eta, vectors c); real 866 | ordered_logistic_rng; (real eta, vector c); int 867 | ordered_probit; ~; real 868 | ordered_probit_lpmf; (ints k | real eta, vectors c); real 869 | ordered_probit_lpmf; (ints k | vector eta, vectors c); real 870 | ordered_probit_lupmf; (ints k | real eta, vectors c); real 871 | ordered_probit_lupmf; (ints k | vector eta, vectors c); real 872 | ordered_probit_rng; (real eta, vector c); int 873 | owens_t; (T1 x, T2 y); R 874 | owens_t; (real h, real a); real 875 | pareto; ~; real 876 | pareto_cdf; (reals y, reals y_min, reals alpha); real 877 | pareto_lccdf; (reals y | reals y_min, reals alpha); real 878 | pareto_lcdf; (reals y | reals y_min, reals alpha); real 879 | pareto_lpdf; (reals y | reals y_min, reals alpha); real 880 | pareto_lupdf; (reals y | reals y_min, reals alpha); real 881 | pareto_rng; (reals y_min, reals alpha); R 882 | pareto_type_2; ~; real 883 | pareto_type_2_cdf; (reals y, reals mu, reals lambda, reals alpha); real 884 | pareto_type_2_lccdf; (reals y | reals mu, reals lambda, reals alpha); real 885 | pareto_type_2_lcdf; (reals y | reals mu, reals lambda, reals alpha); real 886 | pareto_type_2_lpdf; (reals y | reals mu, reals lambda, reals alpha); real 887 | pareto_type_2_lupdf; (reals y | reals mu, reals lambda, reals alpha); real 888 | pareto_type_2_rng; (reals mu, reals lambda, reals alpha); R 889 | pi; (); real 890 | poisson; ~; real 891 | poisson_cdf; (ints n, reals lambda); real 892 | poisson_lccdf; (ints n | reals lambda); real 893 | poisson_lcdf; (ints n | reals lambda); real 894 | poisson_log; ~; real 895 | poisson_log_glm; ~; real 896 | poisson_log_glm_lpmf; (array[] int y | matrix x, real alpha, vector beta); real 897 | poisson_log_glm_lpmf; (array[] int y | matrix x, vector alpha, vector beta); real 898 | poisson_log_glm_lpmf; (array[] int y | row_vector x, real alpha, vector beta); real 899 | poisson_log_glm_lpmf; (array[] int y | row_vector x, vector alpha, vector beta); real 900 | poisson_log_glm_lpmf; (int y | matrix x, real alpha, vector beta); real 901 | poisson_log_glm_lpmf; (int y | matrix x, vector alpha, vector beta); real 902 | poisson_log_glm_lupmf; (array[] int y | matrix x, real alpha, vector beta); real 903 | poisson_log_glm_lupmf; (array[] int y | matrix x, vector alpha, vector beta); real 904 | poisson_log_glm_lupmf; (array[] int y | row_vector x, real alpha, vector beta); real 905 | poisson_log_glm_lupmf; (array[] int y | row_vector x, vector alpha, vector beta); real 906 | poisson_log_glm_lupmf; (int y | matrix x, real alpha, vector beta); real 907 | poisson_log_glm_lupmf; (int y | matrix x, vector alpha, vector beta); real 908 | poisson_log_lpmf; (ints n | reals alpha); real 909 | poisson_log_lupmf; (ints n | reals alpha); real 910 | poisson_log_rng; (reals alpha); R 911 | poisson_lpmf; (ints n | reals lambda); real 912 | poisson_lupmf; (ints n | reals lambda); real 913 | poisson_rng; (reals lambda); R 914 | polar; (real r, real theta); complex 915 | positive_infinity; (); real 916 | pow; (T1 x, T2 y); R 917 | pow; (T1 x, T2 y); Z 918 | pow; (complex x, complex y); complex 919 | pow; (real x, real y); real 920 | print; (T1 x1,..., TN xN); void 921 | prod; (array[] int x); real 922 | prod; (array[] real x); real 923 | prod; (complex_matrix x); complex 924 | prod; (complex_row_vector x); complex 925 | prod; (complex_vector x); complex 926 | prod; (matrix x); real 927 | prod; (row_vector x); real 928 | prod; (vector x); real 929 | proj; (complex z); complex 930 | qr; (matrix A); tuple(matrix, matrix) 931 | qr_Q; (matrix A); matrix 932 | qr_R; (matrix A); matrix 933 | qr_thin; (matrix A); tuple(matrix, matrix) 934 | qr_thin_Q; (matrix A); matrix 935 | qr_thin_R; (matrix A); matrix 936 | quad_form; (matrix A, matrix B); matrix 937 | quad_form; (matrix A, vector B); real 938 | quad_form_diag; (matrix m, row_vector rv); matrix 939 | quad_form_diag; (matrix m, vector v); matrix 940 | quad_form_sym; (matrix A, matrix B); matrix 941 | quad_form_sym; (matrix A, vector B); real 942 | quantile; (data array[] real x, data array[] real p); array[] real 943 | quantile; (data array[] real x, data real p); real 944 | quantile; (data row_vector x, data array[] real p); array[] real 945 | quantile; (data row_vector x, data real p); real 946 | quantile; (data vector x, data array[] real p); array[] real 947 | quantile; (data vector x, data real p); real 948 | rank; (array[] int v, int s); int 949 | rank; (array[] real v, int s); int 950 | rank; (row_vector v, int s); int 951 | rank; (vector v, int s); int 952 | rayleigh; ~; real 953 | rayleigh_cdf; (real y, real sigma); real 954 | rayleigh_lccdf; (real y | real sigma); real 955 | rayleigh_lcdf; (real y | real sigma); real 956 | rayleigh_lpdf; (reals y | reals sigma); real 957 | rayleigh_lupdf; (reals y | reals sigma); real 958 | rayleigh_rng; (reals sigma); R 959 | reduce_sum; (F f, array[] T x, int grainsize, T1 s1, T2 s2, ...); real 960 | reject; (T1 x1,..., TN xN); void 961 | rep_array; (T x, int k, int m, int n); array[,,] T 962 | rep_array; (T x, int m, int n); array[,] T 963 | rep_array; (T x, int n); array[] T 964 | rep_matrix; (complex z, int m, int n); complex_matrix 965 | rep_matrix; (complex_row_vector rv, int m); complex_matrix 966 | rep_matrix; (complex_vector v, int n); complex_matrix 967 | rep_matrix; (real x, int m, int n); matrix 968 | rep_matrix; (row_vector rv, int m); matrix 969 | rep_matrix; (vector v, int n); matrix 970 | rep_row_vector; (complex z, int n); complex_row_vector 971 | rep_row_vector; (real x, int n); row_vector 972 | rep_vector; (complex z, int m); complex_vector 973 | rep_vector; (real x, int m); vector 974 | reverse; (array[] T v); array[] T 975 | reverse; (complex_row_vector v); complex_row_vector 976 | reverse; (complex_vector v); complex_vector 977 | reverse; (row_vector v); row_vector 978 | reverse; (vector v); vector 979 | rising_factorial; (T1 x, T2 y); R 980 | rising_factorial; (real x, int n); real 981 | round; (T x); R 982 | row; (complex_matrix x, int m); complex_row_vector 983 | row; (matrix x, int m); row_vector 984 | rows; (complex_matrix x); int 985 | rows; (complex_row_vector x); int 986 | rows; (complex_vector x); int 987 | rows; (matrix x); int 988 | rows; (row_vector x); int 989 | rows; (vector x); int 990 | rows_dot_product; (complex_matrix x, complex_matrix y); complex_vector 991 | rows_dot_product; (complex_row_vector x, complex_row_vector y); complex_vector 992 | rows_dot_product; (complex_vector x, complex_vector y); complex_vector 993 | rows_dot_product; (matrix x, matrix y); vector 994 | rows_dot_product; (row_vector x, row_vector y); vector 995 | rows_dot_product; (vector x, vector y); vector 996 | rows_dot_self; (complex_matrix x); complex_vector 997 | rows_dot_self; (complex_row_vector x); complex_vector 998 | rows_dot_self; (complex_vector x); complex_vector 999 | rows_dot_self; (matrix x); vector 1000 | rows_dot_self; (row_vector x); vector 1001 | rows_dot_self; (vector x); vector 1002 | scale_matrix_exp_multiply; (real t, matrix A, matrix B); matrix 1003 | scaled_inv_chi_square; ~; real 1004 | scaled_inv_chi_square_cdf; (reals y, reals nu, reals sigma); real 1005 | scaled_inv_chi_square_lccdf; (reals y | reals nu, reals sigma); real 1006 | scaled_inv_chi_square_lcdf; (reals y | reals nu, reals sigma); real 1007 | scaled_inv_chi_square_lpdf; (reals y | reals nu, reals sigma); real 1008 | scaled_inv_chi_square_lupdf; (reals y | reals nu, reals sigma); real 1009 | scaled_inv_chi_square_rng; (reals nu, reals sigma); R 1010 | sd; (array[] real x); real 1011 | sd; (matrix x); real 1012 | sd; (row_vector x); real 1013 | sd; (vector x); real 1014 | segment; (array[] T sv, int i, int n); array[] T 1015 | segment; (complex_row_vector rv, int i, int n); complex_row_vector 1016 | segment; (complex_vector v, int i, int n); complex_vector 1017 | segment; (row_vector rv, int i, int n); row_vector 1018 | segment; (vector v, int i, int n); vector 1019 | sin; (T x); R 1020 | sin; (complex z); complex 1021 | singular_values; (complex_matrix A); vector 1022 | singular_values; (matrix A); vector 1023 | sinh; (T x); R 1024 | sinh; (complex z); complex 1025 | size; (array[] T x); int 1026 | size; (complex_row_vector x); int 1027 | size; (complex_vector x); int 1028 | size; (int x); int 1029 | size; (matrix x); int 1030 | size; (real x); int 1031 | size; (row_vector x); int 1032 | size; (vector x); int 1033 | skew_double_exponential; ~; real 1034 | skew_double_exponential_cdf; (reals y, reals mu, reals sigma, reals tau); real 1035 | skew_double_exponential_lccdf; (reals y | reals mu, reals sigma, reals tau); real 1036 | skew_double_exponential_lcdf; (reals y | reals mu, reals sigma, reals tau); real 1037 | skew_double_exponential_lpdf; (reals y | reals mu, reals sigma, reals tau); real 1038 | skew_double_exponential_lupdf; (reals y | reals mu, reals sigma, reals tau); real 1039 | skew_double_exponential_rng; (reals mu, reals sigma); R 1040 | skew_normal; ~; real 1041 | skew_normal_cdf; (reals y, reals xi, reals omega, reals alpha); real 1042 | skew_normal_lccdf; (reals y | reals xi, reals omega, reals alpha); real 1043 | skew_normal_lcdf; (reals y | reals xi, reals omega, reals alpha); real 1044 | skew_normal_lpdf; (reals y | reals xi, reals omega, reals alpha); real 1045 | skew_normal_lupdf; (reals y | reals xi, reals omega, reals alpha); real 1046 | skew_normal_rng; (reals xi, reals omega, real alpha); R 1047 | softmax; (vector x); vector 1048 | sort_asc; (array[] int v); array[] int 1049 | sort_asc; (array[] real v); array[] real 1050 | sort_asc; (row_vector v); row_vector 1051 | sort_asc; (vector v); vector 1052 | sort_desc; (array[] int v); array[] int 1053 | sort_desc; (array[] real v); array[] real 1054 | sort_desc; (row_vector v); row_vector 1055 | sort_desc; (vector v); vector 1056 | sort_indices_asc; (array[] int v); array[] int 1057 | sort_indices_asc; (array[] real v); array[] int 1058 | sort_indices_asc; (row_vector v); array[] int 1059 | sort_indices_asc; (vector v); array[] int 1060 | sort_indices_desc; (array[] int v); array[] int 1061 | sort_indices_desc; (array[] real v); array[] int 1062 | sort_indices_desc; (row_vector v); array[] int 1063 | sort_indices_desc; (vector v); array[] int 1064 | sqrt2; (); real 1065 | sqrt; (T x); R 1066 | sqrt; (complex x); complex 1067 | square; (T x); R 1068 | squared_distance; (row_vector x, row_vector y); real 1069 | squared_distance; (row_vector x, vector y); real 1070 | squared_distance; (vector x, row_vector y); real 1071 | squared_distance; (vector x, vector y); real 1072 | std_normal; ~; real 1073 | std_normal_cdf; (reals y); real 1074 | std_normal_lccdf; (reals y); real 1075 | std_normal_lcdf; (reals y); real 1076 | std_normal_log_qf; (T x); R 1077 | std_normal_lpdf; (reals y); real 1078 | std_normal_lupdf; (reals y); real 1079 | std_normal_qf; (T x); R 1080 | std_normal_rng; (); real 1081 | step; (real x); real 1082 | student_t; ~; real 1083 | student_t_cdf; (reals y, reals nu, reals mu, reals sigma); real 1084 | student_t_lccdf; (reals y | reals nu, reals mu, reals sigma); real 1085 | student_t_lcdf; (reals y | reals nu, reals mu, reals sigma); real 1086 | student_t_lpdf; (reals y | reals nu, reals mu, reals sigma); real 1087 | student_t_lupdf; (reals y | reals nu, reals mu, reals sigma); real 1088 | student_t_rng; (reals nu, reals mu, reals sigma); R 1089 | sub_col; (complex_matrix x, int i, int j, int n_rows); complex_vector 1090 | sub_col; (matrix x, int i, int j, int n_rows); vector 1091 | sub_row; (complex_matrix x, int i, int j, int n_cols); complex_row_vector 1092 | sub_row; (matrix x, int i, int j, int n_cols); row_vector 1093 | sum; (array[] complex x); complex 1094 | sum; (array[] int x); int 1095 | sum; (array[] real x); real 1096 | sum; (complex_matrix x); complex 1097 | sum; (complex_row_vector x); complex 1098 | sum; (complex_vector x); complex 1099 | sum; (matrix x); real 1100 | sum; (row_vector x); real 1101 | sum; (vector x); real 1102 | svd; (complex_matrix A); tuple(complex_matrix, vector, complex_matrix) 1103 | svd; (matrix A); tuple(matrix, vector, matrix) 1104 | svd_U; (complex_matrix A); complex_matrix 1105 | svd_U; (matrix A); matrix 1106 | svd_V; (complex_matrix A); complex_matrix 1107 | svd_V; (matrix A); matrix 1108 | symmetrize_from_lower_tri; (complex_matrix A); complex_matrix 1109 | symmetrize_from_lower_tri; (matrix A); matrix 1110 | tail; (array[] T sv, int n); array[] T 1111 | tail; (complex_row_vector rv, int n); complex_row_vector 1112 | tail; (complex_vector v, int n); complex_vector 1113 | tail; (row_vector rv, int n); row_vector 1114 | tail; (vector v, int n); vector 1115 | tan; (T x); R 1116 | tan; (complex z); complex 1117 | tanh; (T x); R 1118 | tanh; (complex z); complex 1119 | target; (); real 1120 | tcrossprod; (matrix x); matrix 1121 | tgamma; (T x); R 1122 | to_array_1d; (array[...] complex a); array[] complex 1123 | to_array_1d; (array[...] int a); array[] int 1124 | to_array_1d; (array[...] real a); array[] real 1125 | to_array_1d; (complex_matrix m); array[] complex 1126 | to_array_1d; (complex_row_vector v); array[] complex 1127 | to_array_1d; (complex_vector v); array[] real 1128 | to_array_1d; (matrix m); array[] real 1129 | to_array_1d; (row_vector v); array[] real 1130 | to_array_1d; (vector v); array[] real 1131 | to_array_2d; (complex_matrix m); array[,] real 1132 | to_array_2d; (matrix m); array[,] real 1133 | to_complex; (); complex 1134 | to_complex; (T1 re, T2 im); Z 1135 | to_complex; (real re); complex 1136 | to_complex; (real re, real im); complex 1137 | to_int; (data real x); int 1138 | to_matrix; (array[,] complex a ); complex_matrix 1139 | to_matrix; (array[,] int a); matrix 1140 | to_matrix; (array[,] real a); matrix 1141 | to_matrix; (array[] complex a, int m, int n); complex_matrix 1142 | to_matrix; (array[] complex a, int m, int n, int col_major); complex_matrix 1143 | to_matrix; (array[] complex_row_vector vs); complex_matrix 1144 | to_matrix; (array[] int a, int m, int n); matrix 1145 | to_matrix; (array[] int a, int m, int n, int col_major); matrix 1146 | to_matrix; (array[] real a, int m, int n); matrix 1147 | to_matrix; (array[] real a, int m, int n, int col_major); matrix 1148 | to_matrix; (array[] row_vector vs); matrix 1149 | to_matrix; (complex_matrix A, int m, int n, int col_major); complex_matrix 1150 | to_matrix; (complex_matrix M, int m, int n); complex_matrix 1151 | to_matrix; (complex_matrix m); complex_matrix 1152 | to_matrix; (complex_row_vector v); complex_matrix 1153 | to_matrix; (complex_row_vector v, int m, int n); complex_matrix 1154 | to_matrix; (complex_row_vector v, int m, int n, int col_major); complex_matrix 1155 | to_matrix; (complex_vector v); complex_matrix 1156 | to_matrix; (complex_vector v, int m, int n); complex_matrix 1157 | to_matrix; (complex_vector v, int m, int n, int col_major); complex_matrix 1158 | to_matrix; (matrix A, int m, int n, int col_major); matrix 1159 | to_matrix; (matrix M, int m, int n); matrix 1160 | to_matrix; (matrix m); matrix 1161 | to_matrix; (row_vector v); matrix 1162 | to_matrix; (row_vector v, int m, int n); matrix 1163 | to_matrix; (row_vector v, int m, int n, int col_major); matrix 1164 | to_matrix; (vector v); matrix 1165 | to_matrix; (vector v, int m, int n); matrix 1166 | to_matrix; (vector v, int m, int n, int col_major); matrix 1167 | to_row_vector; (array[] complex a); complex_row_vector 1168 | to_row_vector; (array[] int a); row_vector 1169 | to_row_vector; (array[] real a); row_vector 1170 | to_row_vector; (complex_matrix m); complex_row_vector 1171 | to_row_vector; (complex_row_vector v); complex_row_vector 1172 | to_row_vector; (complex_vector v); complex_row_vector 1173 | to_row_vector; (matrix m); row_vector 1174 | to_row_vector; (row_vector v); row_vector 1175 | to_row_vector; (vector v); row_vector 1176 | to_vector; (array[] complex a); complex_vector 1177 | to_vector; (array[] int a); vector 1178 | to_vector; (array[] real a); vector 1179 | to_vector; (complex_matrix m); complex_vector 1180 | to_vector; (complex_row_vector v); complex_vector 1181 | to_vector; (complex_vector v); complex_vector 1182 | to_vector; (matrix m); vector 1183 | to_vector; (row_vector v); vector 1184 | to_vector; (vector v); vector 1185 | trace; (complex_matrix A); complex 1186 | trace; (matrix A); real 1187 | trace_gen_quad_form; (matrix D,matrix A, matrix B); real 1188 | trace_quad_form; (matrix A, matrix B); real 1189 | trigamma; (T x); R 1190 | trunc; (T x); R 1191 | uniform; ~; real 1192 | uniform_cdf; (reals y, reals alpha, reals beta); real 1193 | uniform_lccdf; (reals y | reals alpha, reals beta); real 1194 | uniform_lcdf; (reals y | reals alpha, reals beta); real 1195 | uniform_lpdf; (reals y | reals alpha, reals beta); real 1196 | uniform_lupdf; (reals y | reals alpha, reals beta); real 1197 | uniform_rng; (reals alpha, reals beta); R 1198 | uniform_simplex; (int n); vector 1199 | variance; (array[] real x); real 1200 | variance; (matrix x); real 1201 | variance; (row_vector x); real 1202 | variance; (vector x); real 1203 | von_mises; ~; real 1204 | von_mises_cdf; (reals y | reals mu, reals kappa); real 1205 | von_mises_lccdf; (reals y | reals mu, reals kappa); real 1206 | von_mises_lcdf; (reals y | reals mu, reals kappa); real 1207 | von_mises_lpdf; (reals y | reals mu, reals kappa); real 1208 | von_mises_lupdf; (reals y | reals mu, reals kappa); real 1209 | von_mises_rng; (reals mu, reals kappa); R 1210 | weibull; ~; real 1211 | weibull_cdf; (reals y, reals alpha, reals sigma); real 1212 | weibull_lccdf; (reals y | reals alpha, reals sigma); real 1213 | weibull_lcdf; (reals y | reals alpha, reals sigma); real 1214 | weibull_lpdf; (reals y | reals alpha, reals sigma); real 1215 | weibull_lupdf; (reals y | reals alpha, reals sigma); real 1216 | weibull_rng; (reals alpha, reals sigma); R 1217 | wiener; ~; real 1218 | wiener_lpdf; (reals y | reals alpha, reals tau, reals beta, reals delta); real 1219 | wiener_lupdf; (reals y | reals alpha, reals tau, reals beta, reals delta); real 1220 | wishart; ~; real 1221 | wishart_cholesky_lpdf; (matrix L_W | real nu, matrix L_S); real 1222 | wishart_cholesky_lupdf; (matrix L_W | real nu, matrix L_S); real 1223 | wishart_cholesky_rng; (real nu, matrix L_S); matrix 1224 | wishart_lpdf; (matrix W | real nu, matrix Sigma); real 1225 | wishart_lupdf; (matrix W | real nu, matrix Sigma); real 1226 | wishart_rng; (real nu, matrix Sigma); matrix 1227 | zeros_array; (int n); array[] real 1228 | zeros_int_array; (int n); array[] int 1229 | zeros_row_vector; (int n); row_vector 1230 | zeros_row_vector; (int n); vector 1231 | -------------------------------------------------------------------------------- /stan-lang-keywords.yaml: -------------------------------------------------------------------------------- 1 | # These come from the sections of the Stan Reference Manual 2 | # - Ch. 6: Expressions (https://mc-stan.org/docs/reference-manual/expressions.html) 3 | # - Ch. 11: Language Syntax (https://mc-stan.org/docs//reference-manual/language-syntax.html) 4 | 5 | types: 6 | basic: # https://mc-stan.org/docs//reference-manual/type-inference.html 7 | - "int" 8 | - "real" 9 | - "complex" 10 | - "vector" 11 | - "row_vector" 12 | - "matrix" 13 | - "complex_vector" 14 | - "complex_row_vector" 15 | - "complex_matrix" 16 | - "array" 17 | - "tuple" 18 | variable: # https://mc-stan.org/docs/reference-manual/type-inference.html (Primitive Type Table) 19 | - "int" 20 | - "real" 21 | - "complex" 22 | - "matrix" 23 | - "cov_matrix" 24 | - "corr_matrix" 25 | - "cholesky_factor_cov" 26 | - "cholesky_factor_corr" 27 | - "vector" 28 | - "simplex" 29 | - "unit_vector" 30 | - "ordered" 31 | - "positive_ordered" 32 | - "row_vector" 33 | - "complex_vector" 34 | - "complex_row_vector" 35 | - "complex_matrix" 36 | - "array" 37 | - "tuple" 38 | return: # https://mc-stan.org/docs/stan-users-guide/basic-functions-section.html (Type Declarations for Functions) 39 | - "int" 40 | - "real" 41 | - "complex" 42 | - "vector" 43 | - "row_vector" 44 | - "matrix" 45 | - "complex_vector" 46 | - "complex_row_vector" 47 | - "complex_matrix" 48 | - "void" 49 | - "array" 50 | - "tuple" 51 | 52 | blocks: # https://mc-stan.org/docs/2_24/reference-manual/overview-of-stans-program-blocks.html 53 | - "functions" 54 | - "data" 55 | - "transformed data" 56 | - "parameters" 57 | - "transformed parameters" 58 | - "model" 59 | - "generated quantities" 60 | 61 | keywords: 62 | control: # https://mc-stan.org/docs/2_24/reference-manual/variables-section.html (Reserved Words from Stan Language) 63 | - "for" 64 | - "in" 65 | - "while" 66 | - "repeat" 67 | - "until" 68 | - "if" 69 | - "then" 70 | - "else" 71 | - "continue" 72 | - "break" 73 | other: 74 | - "return" 75 | - "target" 76 | functions: 77 | - "print" 78 | - "reject" 79 | range_constraints: 80 | - "lower" 81 | - "upper" 82 | - "offset" 83 | - "multiplier" 84 | 85 | special_variables : [] 86 | 87 | deprecated: # https://mc-stan.org/docs/2_24/reference-manual/deprecated-features-appendix.html 88 | - "increment_log_prob" 89 | - "get_lp" 90 | - "multiply_log" 91 | - "lkj_cov" 92 | - "if_else" 93 | - "integrate_ode" 94 | - "binomial_coefficient_log" 95 | - "fabs" 96 | # - '[A-Za-z0-9][A-Za-z0-9_]*_log' # Specifically handled via exact function names. 97 | constants: 98 | - pi 99 | - e 100 | - sqrt2 101 | - log2 102 | - log10 103 | - not_a_number 104 | - positive_infinity 105 | - negative_infinity 106 | - epsilon 107 | - negative_epsilon 108 | # Not really constants, but close enough. 109 | 110 | reserved: 111 | cpp: [] # no cpp-specific reserved words any more 112 | 113 | stan: # https://mc-stan.org/docs/2_24/reference-manual/variables-section.html 114 | - "lp__" 115 | - for 116 | - in 117 | - while 118 | - repeat 119 | - until 120 | - if 121 | - then 122 | - else 123 | - "true" 124 | - "false" 125 | - struct 126 | - typedef 127 | - export 128 | - auto 129 | - extern 130 | - var 131 | - static 132 | - print 133 | - reject 134 | - profile 135 | - get_lp 136 | - increment_log_prob 137 | - target 138 | 139 | operators: 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 | assignment: 165 | - ".*=" 166 | - "./=" 167 | - "*=" 168 | - "/=" 169 | - "+=" 170 | - "-=" 171 | - "=" 172 | -------------------------------------------------------------------------------- /tools/highlightjs.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | """ 3 | Create the file _stan_builtins.py used in the `pygments` package from `stan_lang.json`. 4 | """ 5 | import json 6 | import sys 7 | import textwrap 8 | 9 | def tostr(x): 10 | out = '[' + ', '.join(f"'{i}'" for i in x) + ']' 11 | return '\n'.join(textwrap.wrap(out, 80)) 12 | 13 | def read_json(filename): 14 | with open(filename, "r") as f: 15 | data = json.load(f) 16 | 17 | functions = sorted([k for k, v in data['functions'].items() 18 | if not v['operator']]) 19 | distributions = sorted([v['sampling'] 20 | for k, v in data['functions'].items() 21 | if v['sampling']]) 22 | return { 23 | 'distributions': distributions, 24 | 'functions': functions, 25 | } 26 | 27 | def create_code(data): 28 | print("const FUNCTIONS = {};".format(tostr(data['functions']))) 29 | print("const DISRIBUTIONS = {};".format(tostr(data['distributions']))) 30 | 31 | if __name__ == '__main__': 32 | data = read_json(sys.argv[1]) 33 | create_code(data) 34 | -------------------------------------------------------------------------------- /tools/make_pygments_list.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | """ 3 | Create the file _stan_builtins.py used in the `pygments` package from `stan_lang.json`. 4 | """ 5 | import json 6 | import re 7 | import sys 8 | from datetime import date 9 | 10 | import jinja2 11 | 12 | _TEMPLATE = """# -*- coding: utf-8 -*- 13 | \"\"\" 14 | pygments.lexers._stan_builtins 15 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 16 | 17 | This file contains the names of functions for Stan used by 18 | ``pygments.lexers.math.StanLexer. This is for Stan language version {{version}}. 19 | 20 | :copyright: Copyright 2006-{{year}} by the Pygments team, see AUTHORS. 21 | :license: BSD, see LICENSE for details. 22 | \"\"\" 23 | 24 | KEYWORDS = ( 25 | {%- for kw in keywords|sort %} 26 | '{{ kw }}', 27 | {%- endfor %} 28 | ) 29 | 30 | TYPES = ( 31 | {%- for type in types|sort %} 32 | '{{ type }}', 33 | {%- endfor %} 34 | ) 35 | 36 | FUNCTIONS = ( 37 | {%- for fxn in functions|sort %} 38 | '{{ fxn }}', 39 | {%- endfor %} 40 | ) 41 | 42 | DISTRIBUTIONS = ( 43 | {%- for dist in distributions|sort %} 44 | '{{ dist }}', 45 | {%- endfor %} 46 | ) 47 | 48 | RESERVED = ( 49 | {%- for res in reserved|sort %} 50 | '{{ res }}', 51 | {%- endfor %} 52 | ) 53 | """ 54 | 55 | def tostr(x): 56 | return [str(y) for y in x] 57 | 58 | def read_json(filename): 59 | with open(filename, "r") as f: 60 | data = json.load(f) 61 | 62 | keywords = set() 63 | for k in data['keywords']: 64 | if k == "range_constraints": 65 | continue 66 | for x in data['keywords'][k]: 67 | # handle target separately 68 | if x == "target": 69 | continue 70 | keywords.add(x) 71 | keywords = sorted(list(keywords)) 72 | 73 | reserved = set() 74 | for k in data['reserved']: 75 | for x in data['reserved'][k]: 76 | reserved.add(x) 77 | reserved = sorted(list(reserved)) 78 | 79 | types = set() 80 | for k in data['types']: 81 | for x in data['types'][k]: 82 | types.add(x) 83 | types = sorted(list(types)) 84 | 85 | functions = sorted([k for k, v in data['functions'].items() if not v['operator']]) 86 | distributions = sorted([v['sampling'] for k, v in data['functions'].items() 87 | if v['sampling']]) 88 | return { 89 | 'distributions': distributions, 90 | 'functions': functions, 91 | 'keywords': keywords, 92 | 'reserved': reserved, 93 | 'types': types, 94 | 'version': data['version'], 95 | 'year': date.today().year, 96 | } 97 | 98 | def create_code(data): 99 | template = jinja2.Template(_TEMPLATE) 100 | print(template.render(data)) 101 | 102 | if __name__ == '__main__': 103 | data = read_json(sys.argv[1]) 104 | create_code(data) 105 | -------------------------------------------------------------------------------- /tools/rstudio.py: -------------------------------------------------------------------------------- 1 | """Create regexes to match functions used in rstudio stan-mode.""" 2 | import json 3 | import sys 4 | 5 | 6 | _TEMPLATE = r""" 7 | var functionList = "\\b({functions})\\b"; 8 | 9 | var distributionList = "(~)(\\s*)({distributions})\\b"; 10 | 11 | var deprecatedFunctionList = "\\b({deprecated_functions})\\b"; 12 | 13 | var reservedWords = "\\b({reserved})\\b"; 14 | """ 15 | 16 | 17 | def clean_list(x): 18 | """Clean a list of documents.""" 19 | return '|'.join(sorted(list(set(x)))) 20 | 21 | def read_json(filename): 22 | """Read and process json file of stan language dafinitions.""" 23 | with open(filename, "r") as f: 24 | data = json.load(f) 25 | functions = [ 26 | k for k, v in data['functions'].items() 27 | if not (v['operator'] or v['deprecated'] or v['keyword']) 28 | ] 29 | deprecated_functions = [ 30 | k for k, v in data['functions'].items() 31 | if not v['operator'] and v['deprecated'] 32 | ] 33 | distributions = [ 34 | v['sampling'] for k, v in data['functions'].items() 35 | if v['sampling'] and not v['deprecated'] 36 | ] 37 | reserved = data['reserved']['cpp'] + data['reserved']['stan'] 38 | return { 39 | 'functions': clean_list(functions), 40 | 'distributions': clean_list(distributions), 41 | 'deprecated_functions': clean_list(deprecated_functions), 42 | 'reserved': clean_list(reserved) 43 | } 44 | 45 | 46 | def main(): 47 | """Command line interface.""" 48 | data = read_json(sys.argv[1]) 49 | print(_TEMPLATE.format(**data)) 50 | 51 | 52 | if __name__ == '__main__': 53 | main() 54 | --------------------------------------------------------------------------------