├── src ├── requirements.txt ├── notebooks │ ├── stan │ │ ├── normal │ │ ├── cepheid_v0 │ │ ├── cepheid_v1 │ │ ├── cepheid_v3 │ │ ├── normal.stan │ │ ├── cepheid_v0.stan │ │ ├── cepheid_v1.stan │ │ ├── cepheid_v3.stan │ │ ├── normal.hpp │ │ ├── cepheid_v0.hpp │ │ ├── cepheid_v1.hpp │ │ └── cepheid_v3.hpp │ ├── figures │ │ ├── hmc1.png │ │ ├── hmc2.png │ │ ├── hmc3.png │ │ ├── higgs.png │ │ ├── hubble.jpg │ │ ├── sim_fit.png │ │ ├── ball_drop.png │ │ ├── workflow0.png │ │ ├── workflow1.png │ │ ├── workflow2.png │ │ ├── corner_plot.png │ │ ├── simple_dag.png │ │ ├── bayes_theorem.png │ │ ├── bayes_vs_freq.png │ │ ├── cepheid_intro.png │ │ ├── science_stats.png │ │ ├── model_comparison.png │ │ ├── prior_predictive.png │ │ ├── cepheid_graph_bits.png │ │ ├── hierarchical_model.png │ │ └── posterior_predictive.png │ ├── model_comparison_part2_slides.pdf │ ├── data │ │ ├── galaxies.dat │ │ ├── milkyway_cepheids.dat │ │ ├── linear.dat │ │ └── cepheids.dat │ ├── homework_project.ipynb │ └── model_comparison_part1.ipynb ├── Makefile ├── make.bat ├── conf.py └── index.rst ├── README.md ├── .github └── workflows │ └── sphinx-pages.yml ├── Dockerfile ├── .gitignore └── LICENSE /src/requirements.txt: -------------------------------------------------------------------------------- 1 | nbsphinx 2 | sphinx-rtd-theme 3 | pygments >= 2.4.1 4 | docutils == 0.16 5 | -------------------------------------------------------------------------------- /src/notebooks/stan/normal: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cescalara/BayesianWorkflow/HEAD/src/notebooks/stan/normal -------------------------------------------------------------------------------- /src/notebooks/figures/hmc1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cescalara/BayesianWorkflow/HEAD/src/notebooks/figures/hmc1.png -------------------------------------------------------------------------------- /src/notebooks/figures/hmc2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cescalara/BayesianWorkflow/HEAD/src/notebooks/figures/hmc2.png -------------------------------------------------------------------------------- /src/notebooks/figures/hmc3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cescalara/BayesianWorkflow/HEAD/src/notebooks/figures/hmc3.png -------------------------------------------------------------------------------- /src/notebooks/stan/cepheid_v0: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cescalara/BayesianWorkflow/HEAD/src/notebooks/stan/cepheid_v0 -------------------------------------------------------------------------------- /src/notebooks/stan/cepheid_v1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cescalara/BayesianWorkflow/HEAD/src/notebooks/stan/cepheid_v1 -------------------------------------------------------------------------------- /src/notebooks/stan/cepheid_v3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cescalara/BayesianWorkflow/HEAD/src/notebooks/stan/cepheid_v3 -------------------------------------------------------------------------------- /src/notebooks/figures/higgs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cescalara/BayesianWorkflow/HEAD/src/notebooks/figures/higgs.png -------------------------------------------------------------------------------- /src/notebooks/figures/hubble.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cescalara/BayesianWorkflow/HEAD/src/notebooks/figures/hubble.jpg -------------------------------------------------------------------------------- /src/notebooks/figures/sim_fit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cescalara/BayesianWorkflow/HEAD/src/notebooks/figures/sim_fit.png -------------------------------------------------------------------------------- /src/notebooks/figures/ball_drop.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cescalara/BayesianWorkflow/HEAD/src/notebooks/figures/ball_drop.png -------------------------------------------------------------------------------- /src/notebooks/figures/workflow0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cescalara/BayesianWorkflow/HEAD/src/notebooks/figures/workflow0.png -------------------------------------------------------------------------------- /src/notebooks/figures/workflow1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cescalara/BayesianWorkflow/HEAD/src/notebooks/figures/workflow1.png -------------------------------------------------------------------------------- /src/notebooks/figures/workflow2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cescalara/BayesianWorkflow/HEAD/src/notebooks/figures/workflow2.png -------------------------------------------------------------------------------- /src/notebooks/figures/corner_plot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cescalara/BayesianWorkflow/HEAD/src/notebooks/figures/corner_plot.png -------------------------------------------------------------------------------- /src/notebooks/figures/simple_dag.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cescalara/BayesianWorkflow/HEAD/src/notebooks/figures/simple_dag.png -------------------------------------------------------------------------------- /src/notebooks/figures/bayes_theorem.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cescalara/BayesianWorkflow/HEAD/src/notebooks/figures/bayes_theorem.png -------------------------------------------------------------------------------- /src/notebooks/figures/bayes_vs_freq.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cescalara/BayesianWorkflow/HEAD/src/notebooks/figures/bayes_vs_freq.png -------------------------------------------------------------------------------- /src/notebooks/figures/cepheid_intro.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cescalara/BayesianWorkflow/HEAD/src/notebooks/figures/cepheid_intro.png -------------------------------------------------------------------------------- /src/notebooks/figures/science_stats.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cescalara/BayesianWorkflow/HEAD/src/notebooks/figures/science_stats.png -------------------------------------------------------------------------------- /src/notebooks/figures/model_comparison.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cescalara/BayesianWorkflow/HEAD/src/notebooks/figures/model_comparison.png -------------------------------------------------------------------------------- /src/notebooks/figures/prior_predictive.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cescalara/BayesianWorkflow/HEAD/src/notebooks/figures/prior_predictive.png -------------------------------------------------------------------------------- /src/notebooks/figures/cepheid_graph_bits.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cescalara/BayesianWorkflow/HEAD/src/notebooks/figures/cepheid_graph_bits.png -------------------------------------------------------------------------------- /src/notebooks/figures/hierarchical_model.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cescalara/BayesianWorkflow/HEAD/src/notebooks/figures/hierarchical_model.png -------------------------------------------------------------------------------- /src/notebooks/figures/posterior_predictive.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cescalara/BayesianWorkflow/HEAD/src/notebooks/figures/posterior_predictive.png -------------------------------------------------------------------------------- /src/notebooks/model_comparison_part2_slides.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cescalara/BayesianWorkflow/HEAD/src/notebooks/model_comparison_part2_slides.pdf -------------------------------------------------------------------------------- /src/notebooks/stan/normal.stan: -------------------------------------------------------------------------------- 1 | data{ 2 | int N; 3 | vector[N] x; 4 | } 5 | 6 | parameters { 7 | real mu; 8 | real sigma; 9 | } 10 | 11 | model { 12 | x ~ normal(mu, sigma); 13 | } 14 | -------------------------------------------------------------------------------- /src/notebooks/data/galaxies.dat: -------------------------------------------------------------------------------- 1 | # gal z 2 | 1309 0.007125 3 | 3021 0.005140 4 | 3370 0.004266 5 | 3982 0.003699 6 | 4038 0.005477 7 | 4258 0.001494 8 | 4536 0.006031 9 | 4639 0.003395 10 | 5584 0.005464 11 | -------------------------------------------------------------------------------- /src/notebooks/data/milkyway_cepheids.dat: -------------------------------------------------------------------------------- 1 | # d[kpc] m_obs P[days] 2 | 1.67 3.44 25.4 3 | 0.985 1.35 42.4 4 | 1.42 3.84 18.7 5 | 2.2 2.99 52.2 6 | 0.197 -0.385 16.2 7 | 0.585 -0.884 81 8 | 2.23 2.42 68.6 9 | 2.4 4.2 28 10 | 0.652 2.21 17.2 11 | 1.5 0.963 103 12 | -------------------------------------------------------------------------------- /src/notebooks/data/linear.dat: -------------------------------------------------------------------------------- 1 | # Row 0: x_obs, row 1: y_obs, row 2: sigma 2 | 6.99 7.11 2.98 2.05 5.22 1.51 7.33 1.63 7.94 8.46 6.51 5.13 1.27 4.67 1.27 0.61 9.25 8.42 3.70 2.26 3 | 24.94 18.67 12.23 7.68 18.25 10.70 26.73 -3.34 24.05 21.42 21.15 15.18 6.84 14.34 1.49 3.55 24.17 29.90 15.20 13.13 4 | 3.00 3.00 3.00 3.00 3.00 3.00 3.00 3.00 3.00 3.00 3.00 3.00 3.00 3.00 3.00 3.00 3.00 3.00 3.00 3.00 5 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # BayesianWorkflow 2 | 3 | [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/cescalara/BayesianWorkflow/HEAD) 4 | 5 | A course on implementing a Bayesian workflow using Stan. 6 | 7 | Please see: https://francescacapel.com/BayesianWorkflow/ 8 | 9 | Contact: Francesca Capel (f.capel@tum.de) 10 | 11 | Any feedback is welcome, feel free to open issues or pull requests. 12 | 13 | -------------------------------------------------------------------------------- /src/Makefile: -------------------------------------------------------------------------------- 1 | # Minimal makefile for Sphinx documentation 2 | # 3 | 4 | # You can set these variables from the command line, and also 5 | # from the environment for the first two. 6 | SPHINXOPTS ?= 7 | SPHINXBUILD ?= sphinx-build 8 | SOURCEDIR = . 9 | BUILDDIR = _build 10 | 11 | # Put it first so that "make" without argument is like "make help". 12 | help: 13 | @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 14 | 15 | .PHONY: help Makefile 16 | 17 | # Catch-all target: route all unknown targets to Sphinx using the new 18 | # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). 19 | %: Makefile 20 | @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 21 | -------------------------------------------------------------------------------- /.github/workflows/sphinx-pages.yml: -------------------------------------------------------------------------------- 1 | name: Pages 2 | on: 3 | push: 4 | branches: 5 | - main 6 | jobs: 7 | build: 8 | runs-on: ubuntu-latest 9 | steps: 10 | - name: Setup 11 | run: | 12 | sudo apt-get install -y pandoc 13 | pip install markupsafe==2.0.1 14 | - name: Checkout 15 | uses: actions/checkout@main 16 | with: 17 | fetch-depth: 0 # otherwise, you will failed to push refs to dest repo 18 | - name: Build and Commit 19 | uses: sphinx-notes/pages@master 20 | with: 21 | documentation_path: src 22 | - name: Push changes 23 | uses: ad-m/github-push-action@master 24 | with: 25 | github_token: ${{ secrets.GITHUB_TOKEN }} 26 | branch: gh-pages 27 | 28 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | # Use scipy notebook as base 2 | FROM jupyter/scipy-notebook:notebook-6.4.2 3 | 4 | # As root 5 | USER root 6 | 7 | # Install compiler 8 | RUN apt-get update -y && apt-get install -y build-essential 9 | 10 | # As user 11 | USER ${NB_UID} 12 | 13 | # Setup environment 14 | RUN pip install cython==0.29.24 cmdstanpy==0.9.76 jupyterthemes==0.20.0 arviz==0.11.2 ultranest==3.3.0 15 | 16 | # Install cmdstan 17 | RUN install_cmdstan 18 | 19 | # Set decent notebook theme 20 | RUN jt -t grade3 -T -N -kl 21 | 22 | # Clear entrypoint 23 | ENTRYPOINT [] 24 | 25 | # Copy over notebooks 26 | COPY src/notebooks/*.ipynb work/ 27 | COPY src/notebooks/figures work/figures 28 | COPY src/notebooks/stan work/stan 29 | COPY src/notebooks/data work/data 30 | 31 | # Set permissions 32 | USER root 33 | RUN chmod -R 777 work/ 34 | RUN chown -R ${NB_UID}:${NB_GID} work/ 35 | #USER ${NB_UID} 36 | 37 | # run from the home directory 38 | WORKDIR "${HOME}" 39 | -------------------------------------------------------------------------------- /src/make.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | pushd %~dp0 4 | 5 | REM Command file for Sphinx documentation 6 | 7 | if "%SPHINXBUILD%" == "" ( 8 | set SPHINXBUILD=sphinx-build 9 | ) 10 | set SOURCEDIR=. 11 | set BUILDDIR=_build 12 | 13 | if "%1" == "" goto help 14 | 15 | %SPHINXBUILD% >NUL 2>NUL 16 | if errorlevel 9009 ( 17 | echo. 18 | echo.The 'sphinx-build' command was not found. Make sure you have Sphinx 19 | echo.installed, then set the SPHINXBUILD environment variable to point 20 | echo.to the full path of the 'sphinx-build' executable. Alternatively you 21 | echo.may add the Sphinx directory to PATH. 22 | echo. 23 | echo.If you don't have Sphinx installed, grab it from 24 | echo.http://sphinx-doc.org/ 25 | exit /b 1 26 | ) 27 | 28 | %SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% 29 | goto end 30 | 31 | :help 32 | %SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% 33 | 34 | :end 35 | popd 36 | -------------------------------------------------------------------------------- /src/notebooks/stan/cepheid_v0.stan: -------------------------------------------------------------------------------- 1 | /** 2 | * Initial model for Cepheid variables 3 | * - Single galaxy 4 | * - Shared sigma_m 5 | **/ 6 | 7 | data { 8 | 9 | /* usual inputs */ 10 | int Nc; // number of Cepheids 11 | vector[Nc] m_obs; // obs apparent mag. 12 | real sigma_m; // mag uncertainty 13 | vector[Nc] log10P; // log10(periods/days) 14 | real z; // redshift of single galaxy 15 | 16 | /* for generated quantities */ 17 | int Ngrid; 18 | vector[Ngrid] log10P_grid; 19 | } 20 | 21 | transformed data { 22 | 23 | real dL; 24 | 25 | /* luminosity distance */ 26 | dL = (3.0e5 * z) / 70.0; // Mpc 27 | 28 | } 29 | 30 | parameters { 31 | 32 | /* parameters of the P-L relation */ 33 | real alpha; 34 | real beta; 35 | 36 | } 37 | 38 | transformed parameters { 39 | 40 | vector[Nc] M_true; 41 | vector[Nc] m_true; 42 | 43 | /* P-L relation */ 44 | M_true = alpha + beta * log10P; 45 | 46 | /* convert to m */ 47 | m_true = M_true + 5 * log10(dL) + 25; 48 | 49 | } 50 | 51 | model { 52 | 53 | /* likelihood */ 54 | m_obs ~ normal(m_true, sigma_m); 55 | 56 | } 57 | 58 | generated quantities { 59 | 60 | vector[Ngrid] line; 61 | 62 | /* generate the posterior for the P-L relation */ 63 | line = alpha + beta * log10P_grid; 64 | 65 | } 66 | -------------------------------------------------------------------------------- /src/notebooks/stan/cepheid_v1.stan: -------------------------------------------------------------------------------- 1 | /** 2 | * Initial model for Cepheid variables 3 | * - Single galaxy 4 | * - Shared sigma_m 5 | * - Weakly informative priors 6 | **/ 7 | 8 | data { 9 | 10 | /* usual inputs */ 11 | int Nc; // number of Cepheids 12 | vector[Nc] m_obs; // obs apparent mag. 13 | real sigma_m; // mag uncertainty 14 | vector[Nc] log10P; // log10(periods/days) 15 | real z; // redshift of single galaxy 16 | 17 | /* for generated quantities */ 18 | int Ngrid; 19 | vector[Ngrid] log10P_grid; 20 | } 21 | 22 | transformed data { 23 | 24 | real dL; 25 | 26 | /* luminosity distance */ 27 | dL = (3.0e5 * z) / 70.0; // Mpc 28 | 29 | } 30 | 31 | parameters { 32 | 33 | /* parameters of the P-L relation */ 34 | real alpha; 35 | real beta; 36 | 37 | } 38 | 39 | transformed parameters { 40 | 41 | vector[Nc] M_true; 42 | vector[Nc] m_true; 43 | 44 | /* P-L relation */ 45 | M_true = alpha + beta * log10P; 46 | 47 | /* convert to m */ 48 | m_true = M_true + 5 * log10(dL) + 25; 49 | 50 | } 51 | 52 | model { 53 | 54 | /* priors */ 55 | alpha ~ normal(0, 10); 56 | beta ~ normal(-5, 5); 57 | 58 | /* likelihood */ 59 | m_obs ~ normal(m_true, sigma_m); 60 | 61 | } 62 | 63 | generated quantities { 64 | 65 | vector[Ngrid] line; 66 | 67 | /* generate the posterior for the P-L relation */ 68 | line = alpha + beta * log10P_grid; 69 | 70 | } 71 | -------------------------------------------------------------------------------- /src/notebooks/stan/cepheid_v3.stan: -------------------------------------------------------------------------------- 1 | /** 2 | * Hierarchical model for Cepheid variables 3 | * - Multiple galaxies 4 | * - Shared sigma_m 5 | * - Weakly informative priors 6 | **/ 7 | 8 | data { 9 | 10 | /* usual inputs */ 11 | int Ng; // number of Galaxies 12 | int Nt; // sum(Nc_g) 13 | 14 | int gal_id[Nt]; // galaxy id for each entry [1 - 9] 15 | vector[Nt] m_obs; // obs apparent mag. 16 | real sigma_m; // mag uncertainty 17 | vector[Nt] log10P; // log10(periods/days) 18 | vector[Ng] z; // redshift of single galaxy 19 | 20 | } 21 | 22 | transformed data { 23 | 24 | vector[Ng] dL; 25 | 26 | /* luminosity distance */ 27 | dL = (3.0e5 * z) / 70.0; // Mpc 28 | 29 | } 30 | 31 | parameters { 32 | 33 | /* parameters of the parent distributions */ 34 | real mu_alpha; 35 | real tau_alpha; 36 | 37 | real mu_beta; 38 | real tau_beta; 39 | 40 | /* individual galaxy parameters */ 41 | vector[Ng] alpha; 42 | vector[Ng] beta; 43 | 44 | } 45 | 46 | transformed parameters { 47 | 48 | vector[Nt] M_true; 49 | vector[Nt] m_true; 50 | 51 | /* P-L relation */ 52 | M_true = alpha[gal_id] + beta[gal_id] .* log10P; 53 | 54 | /* convert to m */ 55 | m_true = M_true + 5 * log10(dL[gal_id]) + 25; 56 | 57 | } 58 | 59 | model { 60 | 61 | /* priors */ 62 | mu_alpha ~ normal(0, 10); 63 | mu_beta ~ normal(-5, 5); 64 | tau_alpha ~ cauchy(0, 2.5); 65 | tau_beta ~ cauchy(0, 2.5); 66 | 67 | /* connection to latent params */ 68 | alpha ~ normal(mu_alpha, tau_alpha); 69 | beta ~ normal(mu_beta, tau_beta); 70 | 71 | /* connection to data */ 72 | m_obs ~ normal(m_true, sigma_m); 73 | 74 | } 75 | 76 | -------------------------------------------------------------------------------- /src/conf.py: -------------------------------------------------------------------------------- 1 | # Configuration file for the Sphinx documentation builder. 2 | # 3 | # This file only contains a selection of the most common options. For a full 4 | # list see the documentation: 5 | # https://www.sphinx-doc.org/en/master/usage/configuration.html 6 | 7 | # -- Path setup -------------------------------------------------------------- 8 | 9 | # If extensions (or modules to document with autodoc) are in another directory, 10 | # add these directories to sys.path here. If the directory is relative to the 11 | # documentation root, use os.path.abspath to make it absolute, like shown here. 12 | # 13 | # import os 14 | # import sys 15 | # sys.path.insert(0, os.path.abspath('.')) 16 | 17 | 18 | # -- Project information ----------------------------------------------------- 19 | 20 | project = "Bayesian workflow" 21 | copyright = "2021, Francesca Capel" 22 | author = "Francesca Capel" 23 | 24 | 25 | # -- General configuration --------------------------------------------------- 26 | 27 | # Add any Sphinx extension module names here, as strings. They can be 28 | # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom 29 | # ones. 30 | extensions = ["nbsphinx", "sphinx.ext.githubpages"] 31 | 32 | # Add any paths that contain templates here, relative to this directory. 33 | templates_path = ["_templates"] 34 | 35 | # List of patterns, relative to source directory, that match files and 36 | # directories to ignore when looking for source files. 37 | # This pattern also affects html_static_path and html_extra_path. 38 | exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"] 39 | 40 | 41 | # -- Options for HTML output ------------------------------------------------- 42 | 43 | # The theme to use for HTML and HTML Help pages. See the documentation for 44 | # a list of builtin themes. 45 | # 46 | html_theme = "sphinx_rtd_theme" 47 | 48 | # Add any paths that contain custom static files (such as style sheets) here, 49 | # relative to this directory. They are copied after the builtin static files, 50 | # so a file named "default.css" will overwrite the builtin "default.css". 51 | html_static_path = ["_static"] 52 | -------------------------------------------------------------------------------- /src/notebooks/homework_project.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "id": "8f167dc1", 6 | "metadata": {}, 7 | "source": [ 8 | "## 8. Homework project\n", 9 | "\n", 10 | "
\n", 11 | "\n", 12 | "**Homework exercise (200 points):**\n", 13 | "\n", 14 | "Choose a scientific question and dataset of your own and implement a suitable Bayesian workflow to answer your question. Alternatively, you may design an experiment to answer your question, and work with simulated data. Separate your working into the following topics:\n", 15 | "\n", 16 | "* Problem statement\n", 17 | "* Model building\n", 18 | "* Model checking\n", 19 | "* Model development\n", 20 | "* Model comparison (optional)\n", 21 | "* Experiment design (optional)\n", 22 | "* Conclusions\n", 23 | "\n", 24 | "You are free to choice any topic, but a few options are also given below." 25 | ] 26 | }, 27 | { 28 | "cell_type": "markdown", 29 | "id": "a1757f51", 30 | "metadata": {}, 31 | "source": [ 32 | "**Example topics**\n", 33 | "\n", 34 | "* Studying the evolution of cosmic star formation with galaxy data: https://astrostatistics.psu.edu/datasets/COMBO17.html\n", 35 | "* Solar cycle and sun spot forecasting: https://wwwbis.sidc.be/silso/datafiles \n", 36 | "* To be continued...\n", 37 | "\n", 38 | "
\n", 39 | "\n", 40 | "If you have a question/dataset of interest but aren't sure of a dataset/question to match, then ask to discuss! Questions can be sent to f.capel@tum.de." 41 | ] 42 | }, 43 | { 44 | "cell_type": "code", 45 | "execution_count": null, 46 | "id": "a942fb8e", 47 | "metadata": {}, 48 | "outputs": [], 49 | "source": [] 50 | } 51 | ], 52 | "metadata": { 53 | "kernelspec": { 54 | "display_name": "bayesian_workflow", 55 | "language": "python", 56 | "name": "bayesian_workflow" 57 | }, 58 | "language_info": { 59 | "codemirror_mode": { 60 | "name": "ipython", 61 | "version": 3 62 | }, 63 | "file_extension": ".py", 64 | "mimetype": "text/x-python", 65 | "name": "python", 66 | "nbconvert_exporter": "python", 67 | "pygments_lexer": "ipython3", 68 | "version": "3.9.7" 69 | } 70 | }, 71 | "nbformat": 4, 72 | "nbformat_minor": 5 73 | } 74 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | share/python-wheels/ 24 | *.egg-info/ 25 | .installed.cfg 26 | *.egg 27 | MANIFEST 28 | 29 | # PyInstaller 30 | # Usually these files are written by a python script from a template 31 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 32 | *.manifest 33 | *.spec 34 | 35 | # Installer logs 36 | pip-log.txt 37 | pip-delete-this-directory.txt 38 | 39 | # Unit test / coverage reports 40 | htmlcov/ 41 | .tox/ 42 | .nox/ 43 | .coverage 44 | .coverage.* 45 | .cache 46 | nosetests.xml 47 | coverage.xml 48 | *.cover 49 | *.py,cover 50 | .hypothesis/ 51 | .pytest_cache/ 52 | cover/ 53 | 54 | # Translations 55 | *.mo 56 | *.pot 57 | 58 | # Django stuff: 59 | *.log 60 | local_settings.py 61 | db.sqlite3 62 | db.sqlite3-journal 63 | 64 | # Flask stuff: 65 | instance/ 66 | .webassets-cache 67 | 68 | # Scrapy stuff: 69 | .scrapy 70 | 71 | # Sphinx documentation 72 | src/_build/ 73 | 74 | # PyBuilder 75 | .pybuilder/ 76 | target/ 77 | 78 | # Jupyter Notebook 79 | .ipynb_checkpoints 80 | 81 | # IPython 82 | profile_default/ 83 | ipython_config.py 84 | 85 | # pyenv 86 | # For a library or package, you might want to ignore these files since the code is 87 | # intended to run in multiple environments; otherwise, check them in: 88 | # .python-version 89 | 90 | # pipenv 91 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 92 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 93 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 94 | # install all needed dependencies. 95 | #Pipfile.lock 96 | 97 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow 98 | __pypackages__/ 99 | 100 | # Celery stuff 101 | celerybeat-schedule 102 | celerybeat.pid 103 | 104 | # SageMath parsed files 105 | *.sage.py 106 | 107 | # Environments 108 | .env 109 | .venv 110 | env/ 111 | venv/ 112 | ENV/ 113 | env.bak/ 114 | venv.bak/ 115 | 116 | # Spyder project settings 117 | .spyderproject 118 | .spyproject 119 | 120 | # Rope project settings 121 | .ropeproject 122 | 123 | # mkdocs documentation 124 | /site 125 | 126 | # mypy 127 | .mypy_cache/ 128 | .dmypy.json 129 | dmypy.json 130 | 131 | # Pyre type checker 132 | .pyre/ 133 | 134 | # pytype static type analyzer 135 | .pytype/ 136 | 137 | # Cython debug symbols 138 | cython_debug/ 139 | 140 | # Sphinx documentation 141 | docs/_build/ 142 | 143 | .DS_Store -------------------------------------------------------------------------------- /src/index.rst: -------------------------------------------------------------------------------- 1 | Bayesian workflow 2 | ================= 3 | 4 | Welcome to the Bayesian workflow course. Here, you can browse and search the course notebooks. 5 | 6 | This course is part of the ORIGINS Data Science Laboratory's Block courses. Please see the `main course page `_ for more information. 7 | 8 | Installation 9 | ------------ 10 | 11 | To run the course notebooks, you have a few different options. I recommend to follow the standard install, and use docker or binder if there are problems. 12 | 13 | .. note:: 14 | The notebooks have been tested with Python 3.9 and updates may need to be made to for Python > 3.9 to work. 15 | 16 | * **Plan A - Standard install:** Fork/clone/download material from this `GitHub repository `_, everything you need is in ``src/notebooks`` 17 | 18 | * I recommend using a `virtual environment `_ if possible 19 | * Install the basics if necessary: ``pip install numpy scipy matplotlib`` 20 | * Install: ``pip install cython==0.29.24 cmdstanpy==0.9.76 arviz==0.11.2 ultranest==3.3.0`` 21 | * Run ``install_cmdstan`` (as described in the `cmdstanpy docs `_) 22 | * If using a virtual environment, set up an ipython kernel with this environment (as described `here `_) 23 | * Open a notebook using jupyter, select correct kernel and get running 24 | 25 | * **Plan B - Docker:** Fork/clone/download material from this `GitHub repository `_, everything you need is in ``src/notebooks`` 26 | 27 | * Install `docker `_ on your computer 28 | * Get a ready made docker enironment: ``docker pull cescalara/bayesian_workflow`` 29 | * Run ``docker run -p 8888:8888 -v "${PWD}":/home/jovyan/work cescalara/bayesian_workflow jupyter-notebook --allow-root`` 30 | * Open the given url ``http://127.0.0.1:8888/lab?token=....`` in your browser 31 | * The current directory will be mounted to the docker and the jupyter server has the environment needed to run the notebooks 32 | 33 | * **Plan C - Binder:** Click `here `_ to launch a working environment via binder, all notebooks are in ``work/`` 34 | 35 | * The binder may take a while to load, this is normal 36 | * Using binder you will automatically time out of sessions if you are inactive for more than 10 minutes, so save your work frequently 37 | * The changes that you make are *not persistent* - if you close and repoen a tab your changes will be lost 38 | * To work continuously, download and upload your changes between active sessions 39 | 40 | Solutions 41 | --------- 42 | 43 | Complete solutions to the notebooks can be made available upon request. Please contact f.capel@tum.de. 44 | 45 | Acknowledgements 46 | ---------------- 47 | 48 | I would like to highlight the `many resources `_ of Michael Betancourt and the `KIPAC Statistical Methods course `_ as providing inspiration for the course structure and content. 49 | 50 | 51 | .. toctree:: 52 | :maxdepth: 1 53 | :caption: Contents: 54 | 55 | notebooks/introduction.ipynb 56 | notebooks/model_building.ipynb 57 | notebooks/model_checking.ipynb 58 | notebooks/model_development.ipynb 59 | notebooks/model_comparison_part1.ipynb 60 | notebooks/example-sine-modelcomparison.ipynb 61 | notebooks/experiment_design.ipynb 62 | notebooks/homework_project.ipynb 63 | -------------------------------------------------------------------------------- /src/notebooks/model_comparison_part1.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "id": "1be47306", 6 | "metadata": {}, 7 | "source": [ 8 | "## 5. Model comparison (part I)\n", 9 | "\n", 10 | "
\n", 11 | "\n", 12 | "So far we have focussed on using a Bayesian workflow to design and develop a single model to describe our data. Much of the time, this will be enough to answer the scientific questions that we come across in our research. By using [model checking](model_checking.ipynb) to develop a model and verify that it is capable of representing the data, we are implicity using *predictive performance* to compare models, in a process of continuous model expansion. \n", 13 | "\n", 14 | "
\n", 15 | "\n", 16 | "However, there may be cases where it makes sense to compare two or more distinct models in a more discrete way. E.g. Models for the **presence or absence** of an effect, or **signal over background** models. Consider the following questions:\n", 17 | "> What signal shape best describes my data?\n", 18 | "\n", 19 | "vs. \n", 20 | "\n", 21 | "> Is there signal in my data?\n", 22 | "\n", 23 | "\"What\n", 24 | "\n", 25 | "As we will discuss further, there are several different approaches to model comparison. The right one for the job will depend largely on **what question you are trying to answer and what you know about the models that you are comparing**.\n" 26 | ] 27 | }, 28 | { 29 | "cell_type": "markdown", 30 | "id": "e73daaad", 31 | "metadata": {}, 32 | "source": [ 33 | "### The $\\mathcal{M}$-universe\n", 34 | "\n", 35 | "
\n", 36 | "\n", 37 | ">\"All models are wrong but some are useful\" - George Box\n", 38 | "\n", 39 | "To get started in our model comparison journey, we should think about the set of models that we are trying to compare. We can group these into 3 different scenarios, as summarised below.\n", 40 | "\n", 41 | "
\n", 42 | "\n", 43 | "**$\\mathcal{M}$-closed:** It is reasonable to assume that the true model is part of the set of models under consideration. You can assign prior probabilities to each model in the set.\n", 44 | "\n", 45 | "* This is the simplest case and is true of most textbook statistics problems.\n", 46 | "\n", 47 | "**$\\mathcal{M}$-open:** The data generating process is so complex, that we cannot imagine how the true model might be. In a way, there is no true model.\n", 48 | "\n", 49 | "* This is the worst-case scenario! Imagine trying to design a model to predict human behaviour, or one that is capable of generating the work of a famous author. One can look for patterns, but it doesn't make sense to try and write down the mind of a person as a model.\n", 50 | "\n", 51 | "**$\\mathcal{M}$-complete:** It is reasonable to assume that a true model exists, but it is impossible to come up with a complete list of possible candidate models. \n", 52 | "\n", 53 | "* In practice, this is the case in which we find ourselves most of the time. M-closed problems tend to be too simple to be really interesting, whereas M-open ones are too complex to even attempt with these kind of methods.\n", 54 | "\n", 55 | "In the M-complete view, it makes sense to work towards a *good enough* model that can represent our observations and anser our questions, as we have been doing so far in this workflow. However, one could also think about selecting between a finite set of models, that act as a proxy for a complete list of possible models.\n", 56 | "\n", 57 | "
\n", 58 | "\n", 59 | "It is important to note that many of the more standard and widely used methods for Bayesian model comparison that rely on the **model marginal likelihood**, $p(\\mathrm{data}|\\mathrm{model})$, and/or **model priors**, $p(\\mathrm{model})$, assume that we are in the M-closed regime. As soon as we are not sure that we are in this regime, we should be very careful about interpreting the results of such approaches, and the further away we go, the worse it gets..." 60 | ] 61 | }, 62 | { 63 | "cell_type": "markdown", 64 | "id": "171145a5", 65 | "metadata": {}, 66 | "source": [ 67 | "### Computing the model marginal likelihood\n", 68 | "\n", 69 | "
\n", 70 | "\n", 71 | "Recall Bayes' theorem\n", 72 | "\n", 73 | "$$\n", 74 | "p(\\theta| d) = \\frac{p(d|\\theta)p(\\theta)}{p(d)} = \\frac{p(\\theta | d, M)p(\\theta|M)}{p(d|M)},\n", 75 | "$$\n", 76 | "where we have expanded the expression to show the implicit conditioning on an underlying model, $M$.\n", 77 | "\n", 78 | "The model marginal likelihood, often also referred to as the *Bayesian evidence* is the term in the denominator\n", 79 | "\n", 80 | "$$\n", 81 | "p(d|M) = \\int \\mathrm{d}\\theta~p(\\theta|M) p(d | \\theta, M),\n", 82 | "$$\n", 83 | "which normalises the posterior.\n", 84 | "\n", 85 | "In our work with Stan and Hamiltonian Monte Carlo so far, we have been happily ignoring this term. We didn't need our posterior to be normalised, we just cared about it's shape for parameter estimation purposes. \n", 86 | "\n", 87 | "
\n", 88 | "\n", 89 | "So, if we are in the M-closed scenario and want to compute the marginal likelihood, it is *non-trivial* to re-use any results based on MCMC methods, although possibilities do exist...\n", 90 | "\n", 91 | "The marginal likelihood is a natural byproduct of *nested sampling* methods, which has contributed to their popularity. We will discuss the use of nested sampling further in the next section of the course." 92 | ] 93 | }, 94 | { 95 | "cell_type": "markdown", 96 | "id": "cc0aa162", 97 | "metadata": {}, 98 | "source": [ 99 | "### Model comparison as parameter estimation\n", 100 | "\n", 101 | "
\n", 102 | "\n", 103 | "If all of this has put you off model comparison, you'll be relieved to find out that a lot of model comparison problems can similarly be expressed as parameter estimation problems. Here, we will explore a simple illustrative example\n", 104 | "in Stan.\n", 105 | "\n", 106 | "
\n", 107 | "\n", 108 | "Consider a uniform background model and a normal signal model for some data, $x$:\n", 109 | "\n", 110 | "$$\n", 111 | "x \\sim \\mathcal{U}(0, 1) \n", 112 | "$$\n", 113 | "\n", 114 | "or \n", 115 | "\n", 116 | "$$\n", 117 | "x \\sim \\mathcal{N}(0.5, 0.2)\n", 118 | "$$\n", 119 | "\n", 120 | "Let's say we have $N$ independent observations, $x_i$. We do not know if these observations are from the signal or background component, and we are interested in possibly identifying a signal component. We can build a **mixture model** likelihood for our observations, such that \n", 121 | "\n", 122 | "$$\n", 123 | "p(x | f) = \\prod_{i=1}^N \\Big[ f p(x_i | \\mathrm{signal}) + (1-f) p(x_i | \\mathrm{background})\\Big],\n", 124 | "$$\n", 125 | "where $f$ is the unknown weight of the mixture model, or the fraction of data that can be associated with the signal component. As we don't know $f$ a priori, we can assume a uniform prior over it between 0 and 1. \n", 126 | "\n", 127 | "
\n", 128 | "\n", 129 | "**Exercise 1 (5 points):** Use this information to build a generative model for this simple problem. Simulate 10 observations of x, with an associated fraction of only 0.2. Histogram the resulting x observations.\n" 130 | ] 131 | }, 132 | { 133 | "cell_type": "code", 134 | "execution_count": 1, 135 | "id": "71d62fe3", 136 | "metadata": { 137 | "ExecuteTime": { 138 | "end_time": "2021-09-15T12:01:53.319298Z", 139 | "start_time": "2021-09-15T12:01:52.044220Z" 140 | } 141 | }, 142 | "outputs": [], 143 | "source": [ 144 | "import numpy as np\n", 145 | "from matplotlib import pyplot as plt\n", 146 | "from cmdstanpy import CmdStanModel\n", 147 | "import arviz as av" 148 | ] 149 | }, 150 | { 151 | "cell_type": "code", 152 | "execution_count": 2, 153 | "id": "91c2a771", 154 | "metadata": { 155 | "ExecuteTime": { 156 | "end_time": "2021-09-15T12:01:53.323387Z", 157 | "start_time": "2021-09-15T12:01:53.321104Z" 158 | } 159 | }, 160 | "outputs": [], 161 | "source": [ 162 | "N = 10\n", 163 | "f = 0.2\n", 164 | "# to be completed..." 165 | ] 166 | }, 167 | { 168 | "cell_type": "markdown", 169 | "id": "8aead9c0", 170 | "metadata": {}, 171 | "source": [ 172 | "**Exercise 2 (5 points):** Write the Stan code for this model and display it. Then fit the model to your simulated data. Assume that both the mean and standard deviation of the signal distribution, $\\mu=0.5$, $\\sigma=0.2$, are known and therefore $f$ is the only free parameter. Plot the marginal posterior for f.\n", 173 | "\n", 174 | ">**Hint:** See [this page](https://mc-stan.org/docs/2_27/stan-users-guide/summing-out-the-responsibility-parameter.html) in the Stan manual for some tips." 175 | ] 176 | }, 177 | { 178 | "cell_type": "code", 179 | "execution_count": 3, 180 | "id": "cd3cc8b1", 181 | "metadata": { 182 | "ExecuteTime": { 183 | "end_time": "2021-09-15T12:01:53.956173Z", 184 | "start_time": "2021-09-15T12:01:53.953678Z" 185 | } 186 | }, 187 | "outputs": [], 188 | "source": [ 189 | "# to be completed..." 190 | ] 191 | }, 192 | { 193 | "cell_type": "markdown", 194 | "id": "67d8146a", 195 | "metadata": {}, 196 | "source": [ 197 | "**Exercise 3 (5 points):** Now repeat your simulation a few times, steadily increasing the number of observations. Visualise the effect this has on the resulting $f$ distribution." 198 | ] 199 | }, 200 | { 201 | "cell_type": "code", 202 | "execution_count": 4, 203 | "id": "8caa0caf", 204 | "metadata": { 205 | "ExecuteTime": { 206 | "end_time": "2021-09-15T12:01:54.968596Z", 207 | "start_time": "2021-09-15T12:01:54.966202Z" 208 | } 209 | }, 210 | "outputs": [], 211 | "source": [ 212 | "# to be completed..." 213 | ] 214 | }, 215 | { 216 | "cell_type": "markdown", 217 | "id": "27bac92a", 218 | "metadata": {}, 219 | "source": [ 220 | "**Homework exercise 1 (20 points):** Let's now assume that the signal position, $\\mu$ is unknown. Expand your model to also fit for the signal position. Repeat the above experiment for increasing the sample size, this time visualising the results in terms of the joint posterior for $f$ and $\\mu$. For completeness, also simulate and fit the case of zero signal observations to add to this plot.\n", 221 | "\n", 222 | "
\n", 223 | "\n", 224 | "Some points to note:\n", 225 | "\n", 226 | "* If we wanted to make a decision about the presence of signal in this dataset, we could consider how \"far away\" the marginal distribution for $f$ is away from zero, or how inconsistent $f=0$ is with our results. This could be quantified if necessary.\n", 227 | "* By including $\\mu$ as a free parameter, our results for $f$ also include our uncertainty in it's value." 228 | ] 229 | }, 230 | { 231 | "cell_type": "markdown", 232 | "id": "3f0dae0f", 233 | "metadata": {}, 234 | "source": [ 235 | "### Further reading\n", 236 | "\n", 237 | "* Chapter 7 of [Bayesian Data Analysis](http://www.stat.columbia.edu/~gelman/book/) by Gelman et al.\n", 238 | "* Vehtari, A. & Ojanen, J. A survey of Bayesian predictive methods for model assessment, selection and comparison. Statistics Surveys 6, 142–228 (2012). [DOI: 10.1214/12-SS102](https://projecteuclid.org/journals/statistics-surveys/volume-6/issue-none/A-survey-of-Bayesian-predictive-methods-for-model-assessment-selection/10.1214/12-SS102.full).\n", 239 | "* Kamary, K., Mengersen, K., Robert, C. P. & Rousseau, J. Testing hypotheses via a mixture estimation model. arXiv.org stat.ME, (2014). [arXiv:1412.2044](https://arxiv.org/abs/1412.2044).\n", 240 | " \n", 241 | " " 242 | ] 243 | } 244 | ], 245 | "metadata": { 246 | "kernelspec": { 247 | "display_name": "bayesian_workflow", 248 | "language": "python", 249 | "name": "bayesian_workflow" 250 | }, 251 | "language_info": { 252 | "codemirror_mode": { 253 | "name": "ipython", 254 | "version": 3 255 | }, 256 | "file_extension": ".py", 257 | "mimetype": "text/x-python", 258 | "name": "python", 259 | "nbconvert_exporter": "python", 260 | "pygments_lexer": "ipython3", 261 | "version": "3.9.7" 262 | } 263 | }, 264 | "nbformat": 4, 265 | "nbformat_minor": 5 266 | } 267 | -------------------------------------------------------------------------------- /src/notebooks/stan/normal.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Code generated by stanc v2.27.0 3 | #include 4 | namespace normal_model_namespace { 5 | 6 | using stan::io::dump; 7 | using stan::model::assign; 8 | using stan::model::index_uni; 9 | using stan::model::index_max; 10 | using stan::model::index_min; 11 | using stan::model::index_min_max; 12 | using stan::model::index_multi; 13 | using stan::model::index_omni; 14 | using stan::model::model_base_crtp; 15 | using stan::model::rvalue; 16 | using namespace stan::math; 17 | 18 | 19 | stan::math::profile_map profiles__; 20 | static constexpr std::array locations_array__ = 21 | {" (found before start of program)", 22 | " (in '/Users/fran/projects/BayesianWorkflow/src/notebooks/stan/normal.stan', line 7, column 4 to column 12)", 23 | " (in '/Users/fran/projects/BayesianWorkflow/src/notebooks/stan/normal.stan', line 8, column 4 to column 24)", 24 | " (in '/Users/fran/projects/BayesianWorkflow/src/notebooks/stan/normal.stan', line 12, column 4 to column 26)", 25 | " (in '/Users/fran/projects/BayesianWorkflow/src/notebooks/stan/normal.stan', line 2, column 4 to column 10)", 26 | " (in '/Users/fran/projects/BayesianWorkflow/src/notebooks/stan/normal.stan', line 3, column 11 to column 12)", 27 | " (in '/Users/fran/projects/BayesianWorkflow/src/notebooks/stan/normal.stan', line 3, column 4 to column 16)"}; 28 | 29 | 30 | 31 | class normal_model final : public model_base_crtp { 32 | 33 | private: 34 | int N; 35 | Eigen::Matrix x__; 36 | Eigen::Map> x{nullptr, 0}; 37 | 38 | public: 39 | ~normal_model() { } 40 | 41 | inline std::string model_name() const final { return "normal_model"; } 42 | 43 | inline std::vector model_compile_info() const noexcept { 44 | return std::vector{"stanc_version = stanc3 v2.27.0", "stancflags = "}; 45 | } 46 | 47 | 48 | normal_model(stan::io::var_context& context__, 49 | unsigned int random_seed__ = 0, 50 | std::ostream* pstream__ = nullptr) : model_base_crtp(0) { 51 | int current_statement__ = 0; 52 | using local_scalar_t__ = double ; 53 | boost::ecuyer1988 base_rng__ = 54 | stan::services::util::create_rng(random_seed__, 0); 55 | (void) base_rng__; // suppress unused var warning 56 | static constexpr const char* function__ = "normal_model_namespace::normal_model"; 57 | (void) function__; // suppress unused var warning 58 | local_scalar_t__ DUMMY_VAR__(std::numeric_limits::quiet_NaN()); 59 | (void) DUMMY_VAR__; // suppress unused var warning 60 | try { 61 | int pos__; 62 | pos__ = std::numeric_limits::min(); 63 | 64 | pos__ = 1; 65 | current_statement__ = 4; 66 | context__.validate_dims("data initialization","N","int", 67 | std::vector{}); 68 | N = std::numeric_limits::min(); 69 | 70 | current_statement__ = 4; 71 | N = context__.vals_i("N")[(1 - 1)]; 72 | current_statement__ = 5; 73 | validate_non_negative_index("x", "N", N); 74 | current_statement__ = 6; 75 | context__.validate_dims("data initialization","x","double", 76 | std::vector{static_cast(N)}); 77 | x__ = Eigen::Matrix(N); 78 | new (&x) Eigen::Map>(x__.data(), N); 79 | 80 | { 81 | std::vector x_flat__; 82 | current_statement__ = 6; 83 | x_flat__ = context__.vals_r("x"); 84 | current_statement__ = 6; 85 | pos__ = 1; 86 | current_statement__ = 6; 87 | for (int sym1__ = 1; sym1__ <= N; ++sym1__) { 88 | current_statement__ = 6; 89 | assign(x, x_flat__[(pos__ - 1)], 90 | "assigning variable x", index_uni(sym1__)); 91 | current_statement__ = 6; 92 | pos__ = (pos__ + 1); 93 | } 94 | } 95 | } catch (const std::exception& e) { 96 | stan::lang::rethrow_located(e, locations_array__[current_statement__]); 97 | // Next line prevents compiler griping about no return 98 | throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); 99 | } 100 | num_params_r__ = 1 + 1; 101 | 102 | } 103 | 104 | template * = nullptr, 106 | stan::require_vector_like_vt* = nullptr> 107 | inline stan::scalar_type_t log_prob_impl(VecR& params_r__, 108 | VecI& params_i__, 109 | std::ostream* pstream__ = nullptr) const { 110 | using T__ = stan::scalar_type_t; 111 | using local_scalar_t__ = T__; 112 | T__ lp__(0.0); 113 | stan::math::accumulator lp_accum__; 114 | stan::io::deserializer in__(params_r__, params_i__); 115 | int current_statement__ = 0; 116 | local_scalar_t__ DUMMY_VAR__(std::numeric_limits::quiet_NaN()); 117 | (void) DUMMY_VAR__; // suppress unused var warning 118 | static constexpr const char* function__ = "normal_model_namespace::log_prob"; 119 | (void) function__; // suppress unused var warning 120 | 121 | try { 122 | local_scalar_t__ mu; 123 | mu = DUMMY_VAR__; 124 | 125 | current_statement__ = 1; 126 | mu = in__.template read(); 127 | local_scalar_t__ sigma; 128 | sigma = DUMMY_VAR__; 129 | 130 | current_statement__ = 2; 131 | sigma = in__.template read_constrain_lb( 132 | 0, lp__); 133 | { 134 | current_statement__ = 3; 135 | lp_accum__.add(normal_lpdf(x, mu, sigma)); 136 | } 137 | } catch (const std::exception& e) { 138 | stan::lang::rethrow_located(e, locations_array__[current_statement__]); 139 | // Next line prevents compiler griping about no return 140 | throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); 141 | } 142 | lp_accum__.add(lp__); 143 | return lp_accum__.sum(); 144 | } // log_prob_impl() 145 | 146 | template * = nullptr, 148 | stan::require_vector_like_vt* = nullptr, 149 | stan::require_std_vector_vt* = nullptr> 150 | inline void write_array_impl(RNG& base_rng__, VecR& params_r__, 151 | VecI& params_i__, VecVar& vars__, 152 | const bool emit_transformed_parameters__ = true, 153 | const bool emit_generated_quantities__ = true, 154 | std::ostream* pstream__ = nullptr) const { 155 | using local_scalar_t__ = double; 156 | vars__.resize(0); 157 | stan::io::deserializer in__(params_r__, params_i__); 158 | static constexpr bool propto__ = true; 159 | (void) propto__; 160 | double lp__ = 0.0; 161 | (void) lp__; // dummy to suppress unused var warning 162 | int current_statement__ = 0; 163 | stan::math::accumulator lp_accum__; 164 | local_scalar_t__ DUMMY_VAR__(std::numeric_limits::quiet_NaN()); 165 | constexpr bool jacobian__ = false; 166 | (void) DUMMY_VAR__; // suppress unused var warning 167 | static constexpr const char* function__ = "normal_model_namespace::write_array"; 168 | (void) function__; // suppress unused var warning 169 | 170 | try { 171 | double mu; 172 | mu = std::numeric_limits::quiet_NaN(); 173 | 174 | current_statement__ = 1; 175 | mu = in__.template read(); 176 | double sigma; 177 | sigma = std::numeric_limits::quiet_NaN(); 178 | 179 | current_statement__ = 2; 180 | sigma = in__.template read_constrain_lb( 181 | 0, lp__); 182 | vars__.emplace_back(mu); 183 | vars__.emplace_back(sigma); 184 | if (logical_negation((primitive_value(emit_transformed_parameters__) || 185 | primitive_value(emit_generated_quantities__)))) { 186 | return ; 187 | } 188 | if (logical_negation(emit_generated_quantities__)) { 189 | return ; 190 | } 191 | } catch (const std::exception& e) { 192 | stan::lang::rethrow_located(e, locations_array__[current_statement__]); 193 | // Next line prevents compiler griping about no return 194 | throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); 195 | } 196 | } // write_array_impl() 197 | 198 | template * = nullptr, 200 | stan::require_vector_like_vt* = nullptr> 201 | inline void transform_inits_impl(const stan::io::var_context& context__, 202 | VecI& params_i__, VecVar& vars__, 203 | std::ostream* pstream__ = nullptr) const { 204 | using local_scalar_t__ = double; 205 | vars__.clear(); 206 | vars__.reserve(num_params_r__); 207 | int current_statement__ = 0; 208 | 209 | try { 210 | int pos__; 211 | pos__ = std::numeric_limits::min(); 212 | 213 | pos__ = 1; 214 | double mu; 215 | mu = std::numeric_limits::quiet_NaN(); 216 | 217 | current_statement__ = 1; 218 | mu = context__.vals_r("mu")[(1 - 1)]; 219 | double sigma; 220 | sigma = std::numeric_limits::quiet_NaN(); 221 | 222 | current_statement__ = 2; 223 | sigma = context__.vals_r("sigma")[(1 - 1)]; 224 | double sigma_free__; 225 | sigma_free__ = std::numeric_limits::quiet_NaN(); 226 | 227 | current_statement__ = 2; 228 | sigma_free__ = stan::math::lb_free(sigma, 0); 229 | vars__.emplace_back(mu); 230 | vars__.emplace_back(sigma_free__); 231 | } catch (const std::exception& e) { 232 | stan::lang::rethrow_located(e, locations_array__[current_statement__]); 233 | // Next line prevents compiler griping about no return 234 | throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); 235 | } 236 | } // transform_inits_impl() 237 | 238 | inline void get_param_names(std::vector& names__) const { 239 | 240 | names__ = std::vector{"mu", "sigma"}; 241 | 242 | } // get_param_names() 243 | 244 | inline void get_dims(std::vector>& dimss__) const { 245 | 246 | dimss__ = std::vector>{std::vector{}, 247 | std::vector{}}; 248 | 249 | } // get_dims() 250 | 251 | inline void constrained_param_names( 252 | std::vector& param_names__, 253 | bool emit_transformed_parameters__ = true, 254 | bool emit_generated_quantities__ = true) const 255 | final { 256 | 257 | param_names__.emplace_back(std::string() + "mu"); 258 | param_names__.emplace_back(std::string() + "sigma"); 259 | if (emit_transformed_parameters__) { 260 | 261 | } 262 | 263 | if (emit_generated_quantities__) { 264 | 265 | } 266 | 267 | } // constrained_param_names() 268 | 269 | inline void unconstrained_param_names( 270 | std::vector& param_names__, 271 | bool emit_transformed_parameters__ = true, 272 | bool emit_generated_quantities__ = true) const 273 | final { 274 | 275 | param_names__.emplace_back(std::string() + "mu"); 276 | param_names__.emplace_back(std::string() + "sigma"); 277 | if (emit_transformed_parameters__) { 278 | 279 | } 280 | 281 | if (emit_generated_quantities__) { 282 | 283 | } 284 | 285 | } // unconstrained_param_names() 286 | 287 | inline std::string get_constrained_sizedtypes() const { 288 | 289 | return std::string("[{\"name\":\"mu\",\"type\":{\"name\":\"real\"},\"block\":\"parameters\"},{\"name\":\"sigma\",\"type\":{\"name\":\"real\"},\"block\":\"parameters\"}]"); 290 | 291 | } // get_constrained_sizedtypes() 292 | 293 | inline std::string get_unconstrained_sizedtypes() const { 294 | 295 | return std::string("[{\"name\":\"mu\",\"type\":{\"name\":\"real\"},\"block\":\"parameters\"},{\"name\":\"sigma\",\"type\":{\"name\":\"real\"},\"block\":\"parameters\"}]"); 296 | 297 | } // get_unconstrained_sizedtypes() 298 | 299 | 300 | // Begin method overload boilerplate 301 | template 302 | inline void write_array(RNG& base_rng, 303 | Eigen::Matrix& params_r, 304 | Eigen::Matrix& vars, 305 | const bool emit_transformed_parameters = true, 306 | const bool emit_generated_quantities = true, 307 | std::ostream* pstream = nullptr) const { 308 | std::vector vars_vec; 309 | vars_vec.reserve(vars.size()); 310 | std::vector params_i; 311 | write_array_impl(base_rng, params_r, params_i, vars_vec, 312 | emit_transformed_parameters, emit_generated_quantities, pstream); 313 | vars = Eigen::Map>( 314 | vars_vec.data(), vars_vec.size()); 315 | } 316 | 317 | template 318 | inline void write_array(RNG& base_rng, std::vector& params_r, 319 | std::vector& params_i, 320 | std::vector& vars, 321 | bool emit_transformed_parameters = true, 322 | bool emit_generated_quantities = true, 323 | std::ostream* pstream = nullptr) const { 324 | write_array_impl(base_rng, params_r, params_i, vars, 325 | emit_transformed_parameters, emit_generated_quantities, pstream); 326 | } 327 | 328 | template 329 | inline T_ log_prob(Eigen::Matrix& params_r, 330 | std::ostream* pstream = nullptr) const { 331 | Eigen::Matrix params_i; 332 | return log_prob_impl(params_r, params_i, pstream); 333 | } 334 | 335 | template 336 | inline T__ log_prob(std::vector& params_r, 337 | std::vector& params_i, 338 | std::ostream* pstream = nullptr) const { 339 | return log_prob_impl(params_r, params_i, pstream); 340 | } 341 | 342 | 343 | inline void transform_inits(const stan::io::var_context& context, 344 | Eigen::Matrix& params_r, 345 | std::ostream* pstream = nullptr) const final { 346 | std::vector params_r_vec; 347 | params_r_vec.reserve(params_r.size()); 348 | std::vector params_i; 349 | transform_inits_impl(context, params_i, params_r_vec, pstream); 350 | params_r = Eigen::Map>( 351 | params_r_vec.data(), params_r_vec.size()); 352 | } 353 | inline void transform_inits(const stan::io::var_context& context, 354 | std::vector& params_i, 355 | std::vector& vars, 356 | std::ostream* pstream = nullptr) const final { 357 | transform_inits_impl(context, params_i, vars, pstream); 358 | } 359 | 360 | }; 361 | } 362 | using stan_model = normal_model_namespace::normal_model; 363 | 364 | #ifndef USING_R 365 | 366 | // Boilerplate 367 | stan::model::model_base& new_model( 368 | stan::io::var_context& data_context, 369 | unsigned int seed, 370 | std::ostream* msg_stream) { 371 | stan_model* m = new stan_model(data_context, seed, msg_stream); 372 | return *m; 373 | } 374 | 375 | stan::math::profile_map& get_stan_profile_data() { 376 | return normal_model_namespace::profiles__; 377 | } 378 | 379 | #endif 380 | 381 | 382 | -------------------------------------------------------------------------------- /src/notebooks/stan/cepheid_v0.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Code generated by stanc v2.27.0 3 | #include 4 | namespace cepheid_v0_model_namespace { 5 | 6 | using stan::io::dump; 7 | using stan::model::assign; 8 | using stan::model::index_uni; 9 | using stan::model::index_max; 10 | using stan::model::index_min; 11 | using stan::model::index_min_max; 12 | using stan::model::index_multi; 13 | using stan::model::index_omni; 14 | using stan::model::model_base_crtp; 15 | using stan::model::rvalue; 16 | using namespace stan::math; 17 | 18 | 19 | stan::math::profile_map profiles__; 20 | static constexpr std::array locations_array__ = 21 | {" (found before start of program)", 22 | " (in '/Users/fran/projects/BayesianWorkflow/src/notebooks/stan/cepheid_v0.stan', line 33, column 2 to column 13)", 23 | " (in '/Users/fran/projects/BayesianWorkflow/src/notebooks/stan/cepheid_v0.stan', line 34, column 2 to column 12)", 24 | " (in '/Users/fran/projects/BayesianWorkflow/src/notebooks/stan/cepheid_v0.stan', line 40, column 2 to column 20)", 25 | " (in '/Users/fran/projects/BayesianWorkflow/src/notebooks/stan/cepheid_v0.stan', line 41, column 2 to column 20)", 26 | " (in '/Users/fran/projects/BayesianWorkflow/src/notebooks/stan/cepheid_v0.stan', line 44, column 2 to column 33)", 27 | " (in '/Users/fran/projects/BayesianWorkflow/src/notebooks/stan/cepheid_v0.stan', line 47, column 2 to column 39)", 28 | " (in '/Users/fran/projects/BayesianWorkflow/src/notebooks/stan/cepheid_v0.stan', line 60, column 2 to column 21)", 29 | " (in '/Users/fran/projects/BayesianWorkflow/src/notebooks/stan/cepheid_v0.stan', line 63, column 2 to column 36)", 30 | " (in '/Users/fran/projects/BayesianWorkflow/src/notebooks/stan/cepheid_v0.stan', line 54, column 2 to column 34)", 31 | " (in '/Users/fran/projects/BayesianWorkflow/src/notebooks/stan/cepheid_v0.stan', line 10, column 2 to column 9)", 32 | " (in '/Users/fran/projects/BayesianWorkflow/src/notebooks/stan/cepheid_v0.stan', line 11, column 9 to column 11)", 33 | " (in '/Users/fran/projects/BayesianWorkflow/src/notebooks/stan/cepheid_v0.stan', line 11, column 2 to column 19)", 34 | " (in '/Users/fran/projects/BayesianWorkflow/src/notebooks/stan/cepheid_v0.stan', line 12, column 2 to column 15)", 35 | " (in '/Users/fran/projects/BayesianWorkflow/src/notebooks/stan/cepheid_v0.stan', line 13, column 9 to column 11)", 36 | " (in '/Users/fran/projects/BayesianWorkflow/src/notebooks/stan/cepheid_v0.stan', line 13, column 2 to column 20)", 37 | " (in '/Users/fran/projects/BayesianWorkflow/src/notebooks/stan/cepheid_v0.stan', line 14, column 2 to column 9)", 38 | " (in '/Users/fran/projects/BayesianWorkflow/src/notebooks/stan/cepheid_v0.stan', line 17, column 2 to column 12)", 39 | " (in '/Users/fran/projects/BayesianWorkflow/src/notebooks/stan/cepheid_v0.stan', line 18, column 9 to column 14)", 40 | " (in '/Users/fran/projects/BayesianWorkflow/src/notebooks/stan/cepheid_v0.stan', line 18, column 2 to column 28)", 41 | " (in '/Users/fran/projects/BayesianWorkflow/src/notebooks/stan/cepheid_v0.stan', line 23, column 2 to column 10)", 42 | " (in '/Users/fran/projects/BayesianWorkflow/src/notebooks/stan/cepheid_v0.stan', line 26, column 2 to column 26)", 43 | " (in '/Users/fran/projects/BayesianWorkflow/src/notebooks/stan/cepheid_v0.stan', line 40, column 9 to column 11)", 44 | " (in '/Users/fran/projects/BayesianWorkflow/src/notebooks/stan/cepheid_v0.stan', line 41, column 9 to column 11)", 45 | " (in '/Users/fran/projects/BayesianWorkflow/src/notebooks/stan/cepheid_v0.stan', line 60, column 9 to column 14)"}; 46 | 47 | 48 | 49 | class cepheid_v0_model final : public model_base_crtp { 50 | 51 | private: 52 | int Nc; 53 | Eigen::Matrix m_obs__; 54 | double sigma_m; 55 | Eigen::Matrix log10P__; 56 | double z; 57 | int Ngrid; 58 | Eigen::Matrix log10P_grid__; 59 | double dL; 60 | Eigen::Map> m_obs{nullptr, 0}; 61 | Eigen::Map> log10P{nullptr, 0}; 62 | Eigen::Map> log10P_grid{nullptr, 0}; 63 | 64 | public: 65 | ~cepheid_v0_model() { } 66 | 67 | inline std::string model_name() const final { return "cepheid_v0_model"; } 68 | 69 | inline std::vector model_compile_info() const noexcept { 70 | return std::vector{"stanc_version = stanc3 v2.27.0", "stancflags = "}; 71 | } 72 | 73 | 74 | cepheid_v0_model(stan::io::var_context& context__, 75 | unsigned int random_seed__ = 0, 76 | std::ostream* pstream__ = nullptr) : model_base_crtp(0) { 77 | int current_statement__ = 0; 78 | using local_scalar_t__ = double ; 79 | boost::ecuyer1988 base_rng__ = 80 | stan::services::util::create_rng(random_seed__, 0); 81 | (void) base_rng__; // suppress unused var warning 82 | static constexpr const char* function__ = "cepheid_v0_model_namespace::cepheid_v0_model"; 83 | (void) function__; // suppress unused var warning 84 | local_scalar_t__ DUMMY_VAR__(std::numeric_limits::quiet_NaN()); 85 | (void) DUMMY_VAR__; // suppress unused var warning 86 | try { 87 | int pos__; 88 | pos__ = std::numeric_limits::min(); 89 | 90 | pos__ = 1; 91 | current_statement__ = 10; 92 | context__.validate_dims("data initialization","Nc","int", 93 | std::vector{}); 94 | Nc = std::numeric_limits::min(); 95 | 96 | current_statement__ = 10; 97 | Nc = context__.vals_i("Nc")[(1 - 1)]; 98 | current_statement__ = 11; 99 | validate_non_negative_index("m_obs", "Nc", Nc); 100 | current_statement__ = 12; 101 | context__.validate_dims("data initialization","m_obs","double", 102 | std::vector{static_cast(Nc)}); 103 | m_obs__ = Eigen::Matrix(Nc); 104 | new (&m_obs) Eigen::Map>(m_obs__.data(), Nc); 105 | 106 | 107 | { 108 | std::vector m_obs_flat__; 109 | current_statement__ = 12; 110 | m_obs_flat__ = context__.vals_r("m_obs"); 111 | current_statement__ = 12; 112 | pos__ = 1; 113 | current_statement__ = 12; 114 | for (int sym1__ = 1; sym1__ <= Nc; ++sym1__) { 115 | current_statement__ = 12; 116 | assign(m_obs, m_obs_flat__[(pos__ - 1)], 117 | "assigning variable m_obs", index_uni(sym1__)); 118 | current_statement__ = 12; 119 | pos__ = (pos__ + 1); 120 | } 121 | } 122 | current_statement__ = 13; 123 | context__.validate_dims("data initialization","sigma_m","double", 124 | std::vector{}); 125 | sigma_m = std::numeric_limits::quiet_NaN(); 126 | 127 | current_statement__ = 13; 128 | sigma_m = context__.vals_r("sigma_m")[(1 - 1)]; 129 | current_statement__ = 14; 130 | validate_non_negative_index("log10P", "Nc", Nc); 131 | current_statement__ = 15; 132 | context__.validate_dims("data initialization","log10P","double", 133 | std::vector{static_cast(Nc)}); 134 | log10P__ = Eigen::Matrix(Nc); 135 | new (&log10P) Eigen::Map>(log10P__.data(), Nc); 136 | 137 | 138 | { 139 | std::vector log10P_flat__; 140 | current_statement__ = 15; 141 | log10P_flat__ = context__.vals_r("log10P"); 142 | current_statement__ = 15; 143 | pos__ = 1; 144 | current_statement__ = 15; 145 | for (int sym1__ = 1; sym1__ <= Nc; ++sym1__) { 146 | current_statement__ = 15; 147 | assign(log10P, log10P_flat__[(pos__ - 1)], 148 | "assigning variable log10P", index_uni(sym1__)); 149 | current_statement__ = 15; 150 | pos__ = (pos__ + 1); 151 | } 152 | } 153 | current_statement__ = 16; 154 | context__.validate_dims("data initialization","z","double", 155 | std::vector{}); 156 | z = std::numeric_limits::quiet_NaN(); 157 | 158 | current_statement__ = 16; 159 | z = context__.vals_r("z")[(1 - 1)]; 160 | current_statement__ = 17; 161 | context__.validate_dims("data initialization","Ngrid","int", 162 | std::vector{}); 163 | Ngrid = std::numeric_limits::min(); 164 | 165 | current_statement__ = 17; 166 | Ngrid = context__.vals_i("Ngrid")[(1 - 1)]; 167 | current_statement__ = 18; 168 | validate_non_negative_index("log10P_grid", "Ngrid", Ngrid); 169 | current_statement__ = 19; 170 | context__.validate_dims("data initialization","log10P_grid","double", 171 | std::vector{static_cast(Ngrid)}); 172 | log10P_grid__ = Eigen::Matrix(Ngrid); 173 | new (&log10P_grid) Eigen::Map>(log10P_grid__.data(), Ngrid); 174 | 175 | 176 | { 177 | std::vector log10P_grid_flat__; 178 | current_statement__ = 19; 179 | log10P_grid_flat__ = context__.vals_r("log10P_grid"); 180 | current_statement__ = 19; 181 | pos__ = 1; 182 | current_statement__ = 19; 183 | for (int sym1__ = 1; sym1__ <= Ngrid; ++sym1__) { 184 | current_statement__ = 19; 185 | assign(log10P_grid, log10P_grid_flat__[(pos__ - 1)], 186 | "assigning variable log10P_grid", index_uni(sym1__)); 187 | current_statement__ = 19; 188 | pos__ = (pos__ + 1); 189 | } 190 | } 191 | current_statement__ = 20; 192 | dL = std::numeric_limits::quiet_NaN(); 193 | 194 | current_statement__ = 21; 195 | dL = ((3.0e5 * z) / 70.0); 196 | current_statement__ = 22; 197 | validate_non_negative_index("M_true", "Nc", Nc); 198 | current_statement__ = 23; 199 | validate_non_negative_index("m_true", "Nc", Nc); 200 | current_statement__ = 24; 201 | validate_non_negative_index("line", "Ngrid", Ngrid); 202 | } catch (const std::exception& e) { 203 | stan::lang::rethrow_located(e, locations_array__[current_statement__]); 204 | // Next line prevents compiler griping about no return 205 | throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); 206 | } 207 | num_params_r__ = 1 + 1; 208 | 209 | } 210 | 211 | template * = nullptr, 213 | stan::require_vector_like_vt* = nullptr> 214 | inline stan::scalar_type_t log_prob_impl(VecR& params_r__, 215 | VecI& params_i__, 216 | std::ostream* pstream__ = nullptr) const { 217 | using T__ = stan::scalar_type_t; 218 | using local_scalar_t__ = T__; 219 | T__ lp__(0.0); 220 | stan::math::accumulator lp_accum__; 221 | stan::io::deserializer in__(params_r__, params_i__); 222 | int current_statement__ = 0; 223 | local_scalar_t__ DUMMY_VAR__(std::numeric_limits::quiet_NaN()); 224 | (void) DUMMY_VAR__; // suppress unused var warning 225 | static constexpr const char* function__ = "cepheid_v0_model_namespace::log_prob"; 226 | (void) function__; // suppress unused var warning 227 | 228 | try { 229 | local_scalar_t__ alpha; 230 | alpha = DUMMY_VAR__; 231 | 232 | current_statement__ = 1; 233 | alpha = in__.template read(); 234 | local_scalar_t__ beta; 235 | beta = DUMMY_VAR__; 236 | 237 | current_statement__ = 2; 238 | beta = in__.template read(); 239 | Eigen::Matrix M_true; 240 | M_true = Eigen::Matrix(Nc); 241 | stan::math::fill(M_true, DUMMY_VAR__); 242 | 243 | Eigen::Matrix m_true; 244 | m_true = Eigen::Matrix(Nc); 245 | stan::math::fill(m_true, DUMMY_VAR__); 246 | 247 | current_statement__ = 5; 248 | assign(M_true, add(alpha, multiply(beta, log10P)), 249 | "assigning variable M_true"); 250 | current_statement__ = 6; 251 | assign(m_true, add(add(M_true, (5 * stan::math::log10(dL))), 25), 252 | "assigning variable m_true"); 253 | { 254 | current_statement__ = 9; 255 | lp_accum__.add(normal_lpdf(m_obs, m_true, sigma_m)); 256 | } 257 | } catch (const std::exception& e) { 258 | stan::lang::rethrow_located(e, locations_array__[current_statement__]); 259 | // Next line prevents compiler griping about no return 260 | throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); 261 | } 262 | lp_accum__.add(lp__); 263 | return lp_accum__.sum(); 264 | } // log_prob_impl() 265 | 266 | template * = nullptr, 268 | stan::require_vector_like_vt* = nullptr, 269 | stan::require_std_vector_vt* = nullptr> 270 | inline void write_array_impl(RNG& base_rng__, VecR& params_r__, 271 | VecI& params_i__, VecVar& vars__, 272 | const bool emit_transformed_parameters__ = true, 273 | const bool emit_generated_quantities__ = true, 274 | std::ostream* pstream__ = nullptr) const { 275 | using local_scalar_t__ = double; 276 | vars__.resize(0); 277 | stan::io::deserializer in__(params_r__, params_i__); 278 | static constexpr bool propto__ = true; 279 | (void) propto__; 280 | double lp__ = 0.0; 281 | (void) lp__; // dummy to suppress unused var warning 282 | int current_statement__ = 0; 283 | stan::math::accumulator lp_accum__; 284 | local_scalar_t__ DUMMY_VAR__(std::numeric_limits::quiet_NaN()); 285 | constexpr bool jacobian__ = false; 286 | (void) DUMMY_VAR__; // suppress unused var warning 287 | static constexpr const char* function__ = "cepheid_v0_model_namespace::write_array"; 288 | (void) function__; // suppress unused var warning 289 | 290 | try { 291 | double alpha; 292 | alpha = std::numeric_limits::quiet_NaN(); 293 | 294 | current_statement__ = 1; 295 | alpha = in__.template read(); 296 | double beta; 297 | beta = std::numeric_limits::quiet_NaN(); 298 | 299 | current_statement__ = 2; 300 | beta = in__.template read(); 301 | Eigen::Matrix M_true; 302 | M_true = Eigen::Matrix(Nc); 303 | stan::math::fill(M_true, std::numeric_limits::quiet_NaN()); 304 | 305 | Eigen::Matrix m_true; 306 | m_true = Eigen::Matrix(Nc); 307 | stan::math::fill(m_true, std::numeric_limits::quiet_NaN()); 308 | 309 | vars__.emplace_back(alpha); 310 | vars__.emplace_back(beta); 311 | if (logical_negation((primitive_value(emit_transformed_parameters__) || 312 | primitive_value(emit_generated_quantities__)))) { 313 | return ; 314 | } 315 | current_statement__ = 5; 316 | assign(M_true, add(alpha, multiply(beta, log10P)), 317 | "assigning variable M_true"); 318 | current_statement__ = 6; 319 | assign(m_true, add(add(M_true, (5 * stan::math::log10(dL))), 25), 320 | "assigning variable m_true"); 321 | if (emit_transformed_parameters__) { 322 | for (int sym1__ = 1; sym1__ <= Nc; ++sym1__) { 323 | vars__.emplace_back(M_true[(sym1__ - 1)]); 324 | } 325 | for (int sym1__ = 1; sym1__ <= Nc; ++sym1__) { 326 | vars__.emplace_back(m_true[(sym1__ - 1)]); 327 | } 328 | } 329 | if (logical_negation(emit_generated_quantities__)) { 330 | return ; 331 | } 332 | Eigen::Matrix line; 333 | line = Eigen::Matrix(Ngrid); 334 | stan::math::fill(line, std::numeric_limits::quiet_NaN()); 335 | 336 | current_statement__ = 8; 337 | assign(line, add(alpha, multiply(beta, log10P_grid)), 338 | "assigning variable line"); 339 | for (int sym1__ = 1; sym1__ <= Ngrid; ++sym1__) { 340 | vars__.emplace_back(line[(sym1__ - 1)]); 341 | } 342 | } catch (const std::exception& e) { 343 | stan::lang::rethrow_located(e, locations_array__[current_statement__]); 344 | // Next line prevents compiler griping about no return 345 | throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); 346 | } 347 | } // write_array_impl() 348 | 349 | template * = nullptr, 351 | stan::require_vector_like_vt* = nullptr> 352 | inline void transform_inits_impl(const stan::io::var_context& context__, 353 | VecI& params_i__, VecVar& vars__, 354 | std::ostream* pstream__ = nullptr) const { 355 | using local_scalar_t__ = double; 356 | vars__.clear(); 357 | vars__.reserve(num_params_r__); 358 | int current_statement__ = 0; 359 | 360 | try { 361 | int pos__; 362 | pos__ = std::numeric_limits::min(); 363 | 364 | pos__ = 1; 365 | double alpha; 366 | alpha = std::numeric_limits::quiet_NaN(); 367 | 368 | current_statement__ = 1; 369 | alpha = context__.vals_r("alpha")[(1 - 1)]; 370 | double beta; 371 | beta = std::numeric_limits::quiet_NaN(); 372 | 373 | current_statement__ = 2; 374 | beta = context__.vals_r("beta")[(1 - 1)]; 375 | vars__.emplace_back(alpha); 376 | vars__.emplace_back(beta); 377 | } catch (const std::exception& e) { 378 | stan::lang::rethrow_located(e, locations_array__[current_statement__]); 379 | // Next line prevents compiler griping about no return 380 | throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); 381 | } 382 | } // transform_inits_impl() 383 | 384 | inline void get_param_names(std::vector& names__) const { 385 | 386 | names__ = std::vector{"alpha", "beta", "M_true", "m_true", 387 | "line"}; 388 | 389 | } // get_param_names() 390 | 391 | inline void get_dims(std::vector>& dimss__) const { 392 | 393 | dimss__ = std::vector>{std::vector{}, 394 | std::vector{}, std::vector{static_cast(Nc)}, 395 | std::vector{static_cast(Nc)}, 396 | std::vector{static_cast(Ngrid)}}; 397 | 398 | } // get_dims() 399 | 400 | inline void constrained_param_names( 401 | std::vector& param_names__, 402 | bool emit_transformed_parameters__ = true, 403 | bool emit_generated_quantities__ = true) const 404 | final { 405 | 406 | param_names__.emplace_back(std::string() + "alpha"); 407 | param_names__.emplace_back(std::string() + "beta"); 408 | if (emit_transformed_parameters__) { 409 | for (int sym1__ = 1; sym1__ <= Nc; ++sym1__) { 410 | { 411 | param_names__.emplace_back(std::string() + "M_true" + '.' + std::to_string(sym1__)); 412 | } 413 | } 414 | for (int sym1__ = 1; sym1__ <= Nc; ++sym1__) { 415 | { 416 | param_names__.emplace_back(std::string() + "m_true" + '.' + std::to_string(sym1__)); 417 | } 418 | } 419 | } 420 | 421 | if (emit_generated_quantities__) { 422 | for (int sym1__ = 1; sym1__ <= Ngrid; ++sym1__) { 423 | { 424 | param_names__.emplace_back(std::string() + "line" + '.' + std::to_string(sym1__)); 425 | } 426 | } 427 | } 428 | 429 | } // constrained_param_names() 430 | 431 | inline void unconstrained_param_names( 432 | std::vector& param_names__, 433 | bool emit_transformed_parameters__ = true, 434 | bool emit_generated_quantities__ = true) const 435 | final { 436 | 437 | param_names__.emplace_back(std::string() + "alpha"); 438 | param_names__.emplace_back(std::string() + "beta"); 439 | if (emit_transformed_parameters__) { 440 | for (int sym1__ = 1; sym1__ <= Nc; ++sym1__) { 441 | { 442 | param_names__.emplace_back(std::string() + "M_true" + '.' + std::to_string(sym1__)); 443 | } 444 | } 445 | for (int sym1__ = 1; sym1__ <= Nc; ++sym1__) { 446 | { 447 | param_names__.emplace_back(std::string() + "m_true" + '.' + std::to_string(sym1__)); 448 | } 449 | } 450 | } 451 | 452 | if (emit_generated_quantities__) { 453 | for (int sym1__ = 1; sym1__ <= Ngrid; ++sym1__) { 454 | { 455 | param_names__.emplace_back(std::string() + "line" + '.' + std::to_string(sym1__)); 456 | } 457 | } 458 | } 459 | 460 | } // unconstrained_param_names() 461 | 462 | inline std::string get_constrained_sizedtypes() const { 463 | 464 | return std::string("[{\"name\":\"alpha\",\"type\":{\"name\":\"real\"},\"block\":\"parameters\"},{\"name\":\"beta\",\"type\":{\"name\":\"real\"},\"block\":\"parameters\"},{\"name\":\"M_true\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(Nc) + "},\"block\":\"transformed_parameters\"},{\"name\":\"m_true\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(Nc) + "},\"block\":\"transformed_parameters\"},{\"name\":\"line\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(Ngrid) + "},\"block\":\"generated_quantities\"}]"); 465 | 466 | } // get_constrained_sizedtypes() 467 | 468 | inline std::string get_unconstrained_sizedtypes() const { 469 | 470 | return std::string("[{\"name\":\"alpha\",\"type\":{\"name\":\"real\"},\"block\":\"parameters\"},{\"name\":\"beta\",\"type\":{\"name\":\"real\"},\"block\":\"parameters\"},{\"name\":\"M_true\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(Nc) + "},\"block\":\"transformed_parameters\"},{\"name\":\"m_true\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(Nc) + "},\"block\":\"transformed_parameters\"},{\"name\":\"line\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(Ngrid) + "},\"block\":\"generated_quantities\"}]"); 471 | 472 | } // get_unconstrained_sizedtypes() 473 | 474 | 475 | // Begin method overload boilerplate 476 | template 477 | inline void write_array(RNG& base_rng, 478 | Eigen::Matrix& params_r, 479 | Eigen::Matrix& vars, 480 | const bool emit_transformed_parameters = true, 481 | const bool emit_generated_quantities = true, 482 | std::ostream* pstream = nullptr) const { 483 | std::vector vars_vec; 484 | vars_vec.reserve(vars.size()); 485 | std::vector params_i; 486 | write_array_impl(base_rng, params_r, params_i, vars_vec, 487 | emit_transformed_parameters, emit_generated_quantities, pstream); 488 | vars = Eigen::Map>( 489 | vars_vec.data(), vars_vec.size()); 490 | } 491 | 492 | template 493 | inline void write_array(RNG& base_rng, std::vector& params_r, 494 | std::vector& params_i, 495 | std::vector& vars, 496 | bool emit_transformed_parameters = true, 497 | bool emit_generated_quantities = true, 498 | std::ostream* pstream = nullptr) const { 499 | write_array_impl(base_rng, params_r, params_i, vars, 500 | emit_transformed_parameters, emit_generated_quantities, pstream); 501 | } 502 | 503 | template 504 | inline T_ log_prob(Eigen::Matrix& params_r, 505 | std::ostream* pstream = nullptr) const { 506 | Eigen::Matrix params_i; 507 | return log_prob_impl(params_r, params_i, pstream); 508 | } 509 | 510 | template 511 | inline T__ log_prob(std::vector& params_r, 512 | std::vector& params_i, 513 | std::ostream* pstream = nullptr) const { 514 | return log_prob_impl(params_r, params_i, pstream); 515 | } 516 | 517 | 518 | inline void transform_inits(const stan::io::var_context& context, 519 | Eigen::Matrix& params_r, 520 | std::ostream* pstream = nullptr) const final { 521 | std::vector params_r_vec; 522 | params_r_vec.reserve(params_r.size()); 523 | std::vector params_i; 524 | transform_inits_impl(context, params_i, params_r_vec, pstream); 525 | params_r = Eigen::Map>( 526 | params_r_vec.data(), params_r_vec.size()); 527 | } 528 | inline void transform_inits(const stan::io::var_context& context, 529 | std::vector& params_i, 530 | std::vector& vars, 531 | std::ostream* pstream = nullptr) const final { 532 | transform_inits_impl(context, params_i, vars, pstream); 533 | } 534 | 535 | }; 536 | } 537 | using stan_model = cepheid_v0_model_namespace::cepheid_v0_model; 538 | 539 | #ifndef USING_R 540 | 541 | // Boilerplate 542 | stan::model::model_base& new_model( 543 | stan::io::var_context& data_context, 544 | unsigned int seed, 545 | std::ostream* msg_stream) { 546 | stan_model* m = new stan_model(data_context, seed, msg_stream); 547 | return *m; 548 | } 549 | 550 | stan::math::profile_map& get_stan_profile_data() { 551 | return cepheid_v0_model_namespace::profiles__; 552 | } 553 | 554 | #endif 555 | 556 | 557 | -------------------------------------------------------------------------------- /src/notebooks/stan/cepheid_v1.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Code generated by stanc v2.27.0 3 | #include 4 | namespace cepheid_v1_model_namespace { 5 | 6 | using stan::io::dump; 7 | using stan::model::assign; 8 | using stan::model::index_uni; 9 | using stan::model::index_max; 10 | using stan::model::index_min; 11 | using stan::model::index_min_max; 12 | using stan::model::index_multi; 13 | using stan::model::index_omni; 14 | using stan::model::model_base_crtp; 15 | using stan::model::rvalue; 16 | using namespace stan::math; 17 | 18 | 19 | stan::math::profile_map profiles__; 20 | static constexpr std::array locations_array__ = 21 | {" (found before start of program)", 22 | " (in '/Users/fran/projects/BayesianWorkflow/src/notebooks/stan/cepheid_v1.stan', line 34, column 2 to column 13)", 23 | " (in '/Users/fran/projects/BayesianWorkflow/src/notebooks/stan/cepheid_v1.stan', line 35, column 2 to column 21)", 24 | " (in '/Users/fran/projects/BayesianWorkflow/src/notebooks/stan/cepheid_v1.stan', line 41, column 2 to column 20)", 25 | " (in '/Users/fran/projects/BayesianWorkflow/src/notebooks/stan/cepheid_v1.stan', line 42, column 2 to column 20)", 26 | " (in '/Users/fran/projects/BayesianWorkflow/src/notebooks/stan/cepheid_v1.stan', line 45, column 2 to column 33)", 27 | " (in '/Users/fran/projects/BayesianWorkflow/src/notebooks/stan/cepheid_v1.stan', line 48, column 2 to column 39)", 28 | " (in '/Users/fran/projects/BayesianWorkflow/src/notebooks/stan/cepheid_v1.stan', line 65, column 2 to column 21)", 29 | " (in '/Users/fran/projects/BayesianWorkflow/src/notebooks/stan/cepheid_v1.stan', line 68, column 2 to column 36)", 30 | " (in '/Users/fran/projects/BayesianWorkflow/src/notebooks/stan/cepheid_v1.stan', line 55, column 2 to column 24)", 31 | " (in '/Users/fran/projects/BayesianWorkflow/src/notebooks/stan/cepheid_v1.stan', line 56, column 2 to column 23)", 32 | " (in '/Users/fran/projects/BayesianWorkflow/src/notebooks/stan/cepheid_v1.stan', line 59, column 2 to column 34)", 33 | " (in '/Users/fran/projects/BayesianWorkflow/src/notebooks/stan/cepheid_v1.stan', line 11, column 2 to column 9)", 34 | " (in '/Users/fran/projects/BayesianWorkflow/src/notebooks/stan/cepheid_v1.stan', line 12, column 9 to column 11)", 35 | " (in '/Users/fran/projects/BayesianWorkflow/src/notebooks/stan/cepheid_v1.stan', line 12, column 2 to column 19)", 36 | " (in '/Users/fran/projects/BayesianWorkflow/src/notebooks/stan/cepheid_v1.stan', line 13, column 2 to column 15)", 37 | " (in '/Users/fran/projects/BayesianWorkflow/src/notebooks/stan/cepheid_v1.stan', line 14, column 9 to column 11)", 38 | " (in '/Users/fran/projects/BayesianWorkflow/src/notebooks/stan/cepheid_v1.stan', line 14, column 2 to column 20)", 39 | " (in '/Users/fran/projects/BayesianWorkflow/src/notebooks/stan/cepheid_v1.stan', line 15, column 2 to column 9)", 40 | " (in '/Users/fran/projects/BayesianWorkflow/src/notebooks/stan/cepheid_v1.stan', line 18, column 2 to column 12)", 41 | " (in '/Users/fran/projects/BayesianWorkflow/src/notebooks/stan/cepheid_v1.stan', line 19, column 9 to column 14)", 42 | " (in '/Users/fran/projects/BayesianWorkflow/src/notebooks/stan/cepheid_v1.stan', line 19, column 2 to column 28)", 43 | " (in '/Users/fran/projects/BayesianWorkflow/src/notebooks/stan/cepheid_v1.stan', line 24, column 2 to column 10)", 44 | " (in '/Users/fran/projects/BayesianWorkflow/src/notebooks/stan/cepheid_v1.stan', line 27, column 2 to column 26)", 45 | " (in '/Users/fran/projects/BayesianWorkflow/src/notebooks/stan/cepheid_v1.stan', line 41, column 9 to column 11)", 46 | " (in '/Users/fran/projects/BayesianWorkflow/src/notebooks/stan/cepheid_v1.stan', line 42, column 9 to column 11)", 47 | " (in '/Users/fran/projects/BayesianWorkflow/src/notebooks/stan/cepheid_v1.stan', line 65, column 9 to column 14)"}; 48 | 49 | 50 | 51 | class cepheid_v1_model final : public model_base_crtp { 52 | 53 | private: 54 | int Nc; 55 | Eigen::Matrix m_obs__; 56 | double sigma_m; 57 | Eigen::Matrix log10P__; 58 | double z; 59 | int Ngrid; 60 | Eigen::Matrix log10P_grid__; 61 | double dL; 62 | Eigen::Map> m_obs{nullptr, 0}; 63 | Eigen::Map> log10P{nullptr, 0}; 64 | Eigen::Map> log10P_grid{nullptr, 0}; 65 | 66 | public: 67 | ~cepheid_v1_model() { } 68 | 69 | inline std::string model_name() const final { return "cepheid_v1_model"; } 70 | 71 | inline std::vector model_compile_info() const noexcept { 72 | return std::vector{"stanc_version = stanc3 v2.27.0", "stancflags = "}; 73 | } 74 | 75 | 76 | cepheid_v1_model(stan::io::var_context& context__, 77 | unsigned int random_seed__ = 0, 78 | std::ostream* pstream__ = nullptr) : model_base_crtp(0) { 79 | int current_statement__ = 0; 80 | using local_scalar_t__ = double ; 81 | boost::ecuyer1988 base_rng__ = 82 | stan::services::util::create_rng(random_seed__, 0); 83 | (void) base_rng__; // suppress unused var warning 84 | static constexpr const char* function__ = "cepheid_v1_model_namespace::cepheid_v1_model"; 85 | (void) function__; // suppress unused var warning 86 | local_scalar_t__ DUMMY_VAR__(std::numeric_limits::quiet_NaN()); 87 | (void) DUMMY_VAR__; // suppress unused var warning 88 | try { 89 | int pos__; 90 | pos__ = std::numeric_limits::min(); 91 | 92 | pos__ = 1; 93 | current_statement__ = 12; 94 | context__.validate_dims("data initialization","Nc","int", 95 | std::vector{}); 96 | Nc = std::numeric_limits::min(); 97 | 98 | current_statement__ = 12; 99 | Nc = context__.vals_i("Nc")[(1 - 1)]; 100 | current_statement__ = 13; 101 | validate_non_negative_index("m_obs", "Nc", Nc); 102 | current_statement__ = 14; 103 | context__.validate_dims("data initialization","m_obs","double", 104 | std::vector{static_cast(Nc)}); 105 | m_obs__ = Eigen::Matrix(Nc); 106 | new (&m_obs) Eigen::Map>(m_obs__.data(), Nc); 107 | 108 | 109 | { 110 | std::vector m_obs_flat__; 111 | current_statement__ = 14; 112 | m_obs_flat__ = context__.vals_r("m_obs"); 113 | current_statement__ = 14; 114 | pos__ = 1; 115 | current_statement__ = 14; 116 | for (int sym1__ = 1; sym1__ <= Nc; ++sym1__) { 117 | current_statement__ = 14; 118 | assign(m_obs, m_obs_flat__[(pos__ - 1)], 119 | "assigning variable m_obs", index_uni(sym1__)); 120 | current_statement__ = 14; 121 | pos__ = (pos__ + 1); 122 | } 123 | } 124 | current_statement__ = 15; 125 | context__.validate_dims("data initialization","sigma_m","double", 126 | std::vector{}); 127 | sigma_m = std::numeric_limits::quiet_NaN(); 128 | 129 | current_statement__ = 15; 130 | sigma_m = context__.vals_r("sigma_m")[(1 - 1)]; 131 | current_statement__ = 16; 132 | validate_non_negative_index("log10P", "Nc", Nc); 133 | current_statement__ = 17; 134 | context__.validate_dims("data initialization","log10P","double", 135 | std::vector{static_cast(Nc)}); 136 | log10P__ = Eigen::Matrix(Nc); 137 | new (&log10P) Eigen::Map>(log10P__.data(), Nc); 138 | 139 | 140 | { 141 | std::vector log10P_flat__; 142 | current_statement__ = 17; 143 | log10P_flat__ = context__.vals_r("log10P"); 144 | current_statement__ = 17; 145 | pos__ = 1; 146 | current_statement__ = 17; 147 | for (int sym1__ = 1; sym1__ <= Nc; ++sym1__) { 148 | current_statement__ = 17; 149 | assign(log10P, log10P_flat__[(pos__ - 1)], 150 | "assigning variable log10P", index_uni(sym1__)); 151 | current_statement__ = 17; 152 | pos__ = (pos__ + 1); 153 | } 154 | } 155 | current_statement__ = 18; 156 | context__.validate_dims("data initialization","z","double", 157 | std::vector{}); 158 | z = std::numeric_limits::quiet_NaN(); 159 | 160 | current_statement__ = 18; 161 | z = context__.vals_r("z")[(1 - 1)]; 162 | current_statement__ = 19; 163 | context__.validate_dims("data initialization","Ngrid","int", 164 | std::vector{}); 165 | Ngrid = std::numeric_limits::min(); 166 | 167 | current_statement__ = 19; 168 | Ngrid = context__.vals_i("Ngrid")[(1 - 1)]; 169 | current_statement__ = 20; 170 | validate_non_negative_index("log10P_grid", "Ngrid", Ngrid); 171 | current_statement__ = 21; 172 | context__.validate_dims("data initialization","log10P_grid","double", 173 | std::vector{static_cast(Ngrid)}); 174 | log10P_grid__ = Eigen::Matrix(Ngrid); 175 | new (&log10P_grid) Eigen::Map>(log10P_grid__.data(), Ngrid); 176 | 177 | 178 | { 179 | std::vector log10P_grid_flat__; 180 | current_statement__ = 21; 181 | log10P_grid_flat__ = context__.vals_r("log10P_grid"); 182 | current_statement__ = 21; 183 | pos__ = 1; 184 | current_statement__ = 21; 185 | for (int sym1__ = 1; sym1__ <= Ngrid; ++sym1__) { 186 | current_statement__ = 21; 187 | assign(log10P_grid, log10P_grid_flat__[(pos__ - 1)], 188 | "assigning variable log10P_grid", index_uni(sym1__)); 189 | current_statement__ = 21; 190 | pos__ = (pos__ + 1); 191 | } 192 | } 193 | current_statement__ = 22; 194 | dL = std::numeric_limits::quiet_NaN(); 195 | 196 | current_statement__ = 23; 197 | dL = ((3.0e5 * z) / 70.0); 198 | current_statement__ = 24; 199 | validate_non_negative_index("M_true", "Nc", Nc); 200 | current_statement__ = 25; 201 | validate_non_negative_index("m_true", "Nc", Nc); 202 | current_statement__ = 26; 203 | validate_non_negative_index("line", "Ngrid", Ngrid); 204 | } catch (const std::exception& e) { 205 | stan::lang::rethrow_located(e, locations_array__[current_statement__]); 206 | // Next line prevents compiler griping about no return 207 | throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); 208 | } 209 | num_params_r__ = 1 + 1; 210 | 211 | } 212 | 213 | template * = nullptr, 215 | stan::require_vector_like_vt* = nullptr> 216 | inline stan::scalar_type_t log_prob_impl(VecR& params_r__, 217 | VecI& params_i__, 218 | std::ostream* pstream__ = nullptr) const { 219 | using T__ = stan::scalar_type_t; 220 | using local_scalar_t__ = T__; 221 | T__ lp__(0.0); 222 | stan::math::accumulator lp_accum__; 223 | stan::io::deserializer in__(params_r__, params_i__); 224 | int current_statement__ = 0; 225 | local_scalar_t__ DUMMY_VAR__(std::numeric_limits::quiet_NaN()); 226 | (void) DUMMY_VAR__; // suppress unused var warning 227 | static constexpr const char* function__ = "cepheid_v1_model_namespace::log_prob"; 228 | (void) function__; // suppress unused var warning 229 | 230 | try { 231 | local_scalar_t__ alpha; 232 | alpha = DUMMY_VAR__; 233 | 234 | current_statement__ = 1; 235 | alpha = in__.template read(); 236 | local_scalar_t__ beta; 237 | beta = DUMMY_VAR__; 238 | 239 | current_statement__ = 2; 240 | beta = in__.template read_constrain_ub(0, 241 | lp__); 242 | Eigen::Matrix M_true; 243 | M_true = Eigen::Matrix(Nc); 244 | stan::math::fill(M_true, DUMMY_VAR__); 245 | 246 | Eigen::Matrix m_true; 247 | m_true = Eigen::Matrix(Nc); 248 | stan::math::fill(m_true, DUMMY_VAR__); 249 | 250 | current_statement__ = 5; 251 | assign(M_true, add(alpha, multiply(beta, log10P)), 252 | "assigning variable M_true"); 253 | current_statement__ = 6; 254 | assign(m_true, add(add(M_true, (5 * stan::math::log10(dL))), 25), 255 | "assigning variable m_true"); 256 | { 257 | current_statement__ = 9; 258 | lp_accum__.add(normal_lpdf(alpha, 0, 10)); 259 | current_statement__ = 10; 260 | lp_accum__.add(normal_lpdf(beta, -5, 5)); 261 | current_statement__ = 11; 262 | lp_accum__.add(normal_lpdf(m_obs, m_true, sigma_m)); 263 | } 264 | } catch (const std::exception& e) { 265 | stan::lang::rethrow_located(e, locations_array__[current_statement__]); 266 | // Next line prevents compiler griping about no return 267 | throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); 268 | } 269 | lp_accum__.add(lp__); 270 | return lp_accum__.sum(); 271 | } // log_prob_impl() 272 | 273 | template * = nullptr, 275 | stan::require_vector_like_vt* = nullptr, 276 | stan::require_std_vector_vt* = nullptr> 277 | inline void write_array_impl(RNG& base_rng__, VecR& params_r__, 278 | VecI& params_i__, VecVar& vars__, 279 | const bool emit_transformed_parameters__ = true, 280 | const bool emit_generated_quantities__ = true, 281 | std::ostream* pstream__ = nullptr) const { 282 | using local_scalar_t__ = double; 283 | vars__.resize(0); 284 | stan::io::deserializer in__(params_r__, params_i__); 285 | static constexpr bool propto__ = true; 286 | (void) propto__; 287 | double lp__ = 0.0; 288 | (void) lp__; // dummy to suppress unused var warning 289 | int current_statement__ = 0; 290 | stan::math::accumulator lp_accum__; 291 | local_scalar_t__ DUMMY_VAR__(std::numeric_limits::quiet_NaN()); 292 | constexpr bool jacobian__ = false; 293 | (void) DUMMY_VAR__; // suppress unused var warning 294 | static constexpr const char* function__ = "cepheid_v1_model_namespace::write_array"; 295 | (void) function__; // suppress unused var warning 296 | 297 | try { 298 | double alpha; 299 | alpha = std::numeric_limits::quiet_NaN(); 300 | 301 | current_statement__ = 1; 302 | alpha = in__.template read(); 303 | double beta; 304 | beta = std::numeric_limits::quiet_NaN(); 305 | 306 | current_statement__ = 2; 307 | beta = in__.template read_constrain_ub(0, 308 | lp__); 309 | Eigen::Matrix M_true; 310 | M_true = Eigen::Matrix(Nc); 311 | stan::math::fill(M_true, std::numeric_limits::quiet_NaN()); 312 | 313 | Eigen::Matrix m_true; 314 | m_true = Eigen::Matrix(Nc); 315 | stan::math::fill(m_true, std::numeric_limits::quiet_NaN()); 316 | 317 | vars__.emplace_back(alpha); 318 | vars__.emplace_back(beta); 319 | if (logical_negation((primitive_value(emit_transformed_parameters__) || 320 | primitive_value(emit_generated_quantities__)))) { 321 | return ; 322 | } 323 | current_statement__ = 5; 324 | assign(M_true, add(alpha, multiply(beta, log10P)), 325 | "assigning variable M_true"); 326 | current_statement__ = 6; 327 | assign(m_true, add(add(M_true, (5 * stan::math::log10(dL))), 25), 328 | "assigning variable m_true"); 329 | if (emit_transformed_parameters__) { 330 | for (int sym1__ = 1; sym1__ <= Nc; ++sym1__) { 331 | vars__.emplace_back(M_true[(sym1__ - 1)]); 332 | } 333 | for (int sym1__ = 1; sym1__ <= Nc; ++sym1__) { 334 | vars__.emplace_back(m_true[(sym1__ - 1)]); 335 | } 336 | } 337 | if (logical_negation(emit_generated_quantities__)) { 338 | return ; 339 | } 340 | Eigen::Matrix line; 341 | line = Eigen::Matrix(Ngrid); 342 | stan::math::fill(line, std::numeric_limits::quiet_NaN()); 343 | 344 | current_statement__ = 8; 345 | assign(line, add(alpha, multiply(beta, log10P_grid)), 346 | "assigning variable line"); 347 | for (int sym1__ = 1; sym1__ <= Ngrid; ++sym1__) { 348 | vars__.emplace_back(line[(sym1__ - 1)]); 349 | } 350 | } catch (const std::exception& e) { 351 | stan::lang::rethrow_located(e, locations_array__[current_statement__]); 352 | // Next line prevents compiler griping about no return 353 | throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); 354 | } 355 | } // write_array_impl() 356 | 357 | template * = nullptr, 359 | stan::require_vector_like_vt* = nullptr> 360 | inline void transform_inits_impl(const stan::io::var_context& context__, 361 | VecI& params_i__, VecVar& vars__, 362 | std::ostream* pstream__ = nullptr) const { 363 | using local_scalar_t__ = double; 364 | vars__.clear(); 365 | vars__.reserve(num_params_r__); 366 | int current_statement__ = 0; 367 | 368 | try { 369 | int pos__; 370 | pos__ = std::numeric_limits::min(); 371 | 372 | pos__ = 1; 373 | double alpha; 374 | alpha = std::numeric_limits::quiet_NaN(); 375 | 376 | current_statement__ = 1; 377 | alpha = context__.vals_r("alpha")[(1 - 1)]; 378 | double beta; 379 | beta = std::numeric_limits::quiet_NaN(); 380 | 381 | current_statement__ = 2; 382 | beta = context__.vals_r("beta")[(1 - 1)]; 383 | double beta_free__; 384 | beta_free__ = std::numeric_limits::quiet_NaN(); 385 | 386 | current_statement__ = 2; 387 | beta_free__ = stan::math::ub_free(beta, 0); 388 | vars__.emplace_back(alpha); 389 | vars__.emplace_back(beta_free__); 390 | } catch (const std::exception& e) { 391 | stan::lang::rethrow_located(e, locations_array__[current_statement__]); 392 | // Next line prevents compiler griping about no return 393 | throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); 394 | } 395 | } // transform_inits_impl() 396 | 397 | inline void get_param_names(std::vector& names__) const { 398 | 399 | names__ = std::vector{"alpha", "beta", "M_true", "m_true", 400 | "line"}; 401 | 402 | } // get_param_names() 403 | 404 | inline void get_dims(std::vector>& dimss__) const { 405 | 406 | dimss__ = std::vector>{std::vector{}, 407 | std::vector{}, std::vector{static_cast(Nc)}, 408 | std::vector{static_cast(Nc)}, 409 | std::vector{static_cast(Ngrid)}}; 410 | 411 | } // get_dims() 412 | 413 | inline void constrained_param_names( 414 | std::vector& param_names__, 415 | bool emit_transformed_parameters__ = true, 416 | bool emit_generated_quantities__ = true) const 417 | final { 418 | 419 | param_names__.emplace_back(std::string() + "alpha"); 420 | param_names__.emplace_back(std::string() + "beta"); 421 | if (emit_transformed_parameters__) { 422 | for (int sym1__ = 1; sym1__ <= Nc; ++sym1__) { 423 | { 424 | param_names__.emplace_back(std::string() + "M_true" + '.' + std::to_string(sym1__)); 425 | } 426 | } 427 | for (int sym1__ = 1; sym1__ <= Nc; ++sym1__) { 428 | { 429 | param_names__.emplace_back(std::string() + "m_true" + '.' + std::to_string(sym1__)); 430 | } 431 | } 432 | } 433 | 434 | if (emit_generated_quantities__) { 435 | for (int sym1__ = 1; sym1__ <= Ngrid; ++sym1__) { 436 | { 437 | param_names__.emplace_back(std::string() + "line" + '.' + std::to_string(sym1__)); 438 | } 439 | } 440 | } 441 | 442 | } // constrained_param_names() 443 | 444 | inline void unconstrained_param_names( 445 | std::vector& param_names__, 446 | bool emit_transformed_parameters__ = true, 447 | bool emit_generated_quantities__ = true) const 448 | final { 449 | 450 | param_names__.emplace_back(std::string() + "alpha"); 451 | param_names__.emplace_back(std::string() + "beta"); 452 | if (emit_transformed_parameters__) { 453 | for (int sym1__ = 1; sym1__ <= Nc; ++sym1__) { 454 | { 455 | param_names__.emplace_back(std::string() + "M_true" + '.' + std::to_string(sym1__)); 456 | } 457 | } 458 | for (int sym1__ = 1; sym1__ <= Nc; ++sym1__) { 459 | { 460 | param_names__.emplace_back(std::string() + "m_true" + '.' + std::to_string(sym1__)); 461 | } 462 | } 463 | } 464 | 465 | if (emit_generated_quantities__) { 466 | for (int sym1__ = 1; sym1__ <= Ngrid; ++sym1__) { 467 | { 468 | param_names__.emplace_back(std::string() + "line" + '.' + std::to_string(sym1__)); 469 | } 470 | } 471 | } 472 | 473 | } // unconstrained_param_names() 474 | 475 | inline std::string get_constrained_sizedtypes() const { 476 | 477 | return std::string("[{\"name\":\"alpha\",\"type\":{\"name\":\"real\"},\"block\":\"parameters\"},{\"name\":\"beta\",\"type\":{\"name\":\"real\"},\"block\":\"parameters\"},{\"name\":\"M_true\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(Nc) + "},\"block\":\"transformed_parameters\"},{\"name\":\"m_true\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(Nc) + "},\"block\":\"transformed_parameters\"},{\"name\":\"line\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(Ngrid) + "},\"block\":\"generated_quantities\"}]"); 478 | 479 | } // get_constrained_sizedtypes() 480 | 481 | inline std::string get_unconstrained_sizedtypes() const { 482 | 483 | return std::string("[{\"name\":\"alpha\",\"type\":{\"name\":\"real\"},\"block\":\"parameters\"},{\"name\":\"beta\",\"type\":{\"name\":\"real\"},\"block\":\"parameters\"},{\"name\":\"M_true\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(Nc) + "},\"block\":\"transformed_parameters\"},{\"name\":\"m_true\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(Nc) + "},\"block\":\"transformed_parameters\"},{\"name\":\"line\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(Ngrid) + "},\"block\":\"generated_quantities\"}]"); 484 | 485 | } // get_unconstrained_sizedtypes() 486 | 487 | 488 | // Begin method overload boilerplate 489 | template 490 | inline void write_array(RNG& base_rng, 491 | Eigen::Matrix& params_r, 492 | Eigen::Matrix& vars, 493 | const bool emit_transformed_parameters = true, 494 | const bool emit_generated_quantities = true, 495 | std::ostream* pstream = nullptr) const { 496 | std::vector vars_vec; 497 | vars_vec.reserve(vars.size()); 498 | std::vector params_i; 499 | write_array_impl(base_rng, params_r, params_i, vars_vec, 500 | emit_transformed_parameters, emit_generated_quantities, pstream); 501 | vars = Eigen::Map>( 502 | vars_vec.data(), vars_vec.size()); 503 | } 504 | 505 | template 506 | inline void write_array(RNG& base_rng, std::vector& params_r, 507 | std::vector& params_i, 508 | std::vector& vars, 509 | bool emit_transformed_parameters = true, 510 | bool emit_generated_quantities = true, 511 | std::ostream* pstream = nullptr) const { 512 | write_array_impl(base_rng, params_r, params_i, vars, 513 | emit_transformed_parameters, emit_generated_quantities, pstream); 514 | } 515 | 516 | template 517 | inline T_ log_prob(Eigen::Matrix& params_r, 518 | std::ostream* pstream = nullptr) const { 519 | Eigen::Matrix params_i; 520 | return log_prob_impl(params_r, params_i, pstream); 521 | } 522 | 523 | template 524 | inline T__ log_prob(std::vector& params_r, 525 | std::vector& params_i, 526 | std::ostream* pstream = nullptr) const { 527 | return log_prob_impl(params_r, params_i, pstream); 528 | } 529 | 530 | 531 | inline void transform_inits(const stan::io::var_context& context, 532 | Eigen::Matrix& params_r, 533 | std::ostream* pstream = nullptr) const final { 534 | std::vector params_r_vec; 535 | params_r_vec.reserve(params_r.size()); 536 | std::vector params_i; 537 | transform_inits_impl(context, params_i, params_r_vec, pstream); 538 | params_r = Eigen::Map>( 539 | params_r_vec.data(), params_r_vec.size()); 540 | } 541 | inline void transform_inits(const stan::io::var_context& context, 542 | std::vector& params_i, 543 | std::vector& vars, 544 | std::ostream* pstream = nullptr) const final { 545 | transform_inits_impl(context, params_i, vars, pstream); 546 | } 547 | 548 | }; 549 | } 550 | using stan_model = cepheid_v1_model_namespace::cepheid_v1_model; 551 | 552 | #ifndef USING_R 553 | 554 | // Boilerplate 555 | stan::model::model_base& new_model( 556 | stan::io::var_context& data_context, 557 | unsigned int seed, 558 | std::ostream* msg_stream) { 559 | stan_model* m = new stan_model(data_context, seed, msg_stream); 560 | return *m; 561 | } 562 | 563 | stan::math::profile_map& get_stan_profile_data() { 564 | return cepheid_v1_model_namespace::profiles__; 565 | } 566 | 567 | #endif 568 | 569 | 570 | -------------------------------------------------------------------------------- /src/notebooks/data/cepheids.dat: -------------------------------------------------------------------------------- 1 | # gal m_obs sigma_m P delta_logO_H 2 | 1309 24.81 0.3465 40.4 0.3795 3 | 1309 26.05 0.4568 18.37 -0.2468 4 | 1309 26.04 0.53 26.94 1.159 5 | 1309 22.8 0.3921 36.51 -0.3276 6 | 1309 21.86 0.2858 60.36 -0.896 7 | 1309 23.45 0.4465 35.8 -0.2532 8 | 1309 23.85 0.365 21.23 -0.7035 9 | 1309 25.68 0.3158 21.88 0.5588 10 | 1309 24.6 0.2928 27.06 0.2014 11 | 1309 24.94 0.2249 25.44 0.2183 12 | 1309 21.34 0.3708 42.35 -1.65 13 | 1309 25.51 0.3951 23.35 0.366 14 | 1309 23.45 0.6394 22.37 -0.7328 15 | 1309 27.49 0.5376 10.06 0.1837 16 | 1309 24.16 0.5621 15.77 -0.4942 17 | 1309 25.81 0.3253 22.25 0.5304 18 | 1309 23.9 0.3062 54.26 0.1846 19 | 1309 26.28 0.493 20.12 0.22 20 | 1309 22.47 0.5266 32.54 -0.7342 21 | 1309 25.13 0.1681 27.51 0.1816 22 | 1309 26.4 0.1798 17.33 0.678 23 | 1309 23.37 0.3736 37.04 -0.5568 24 | 1309 24.78 0.1958 23.86 -0.0891 25 | 1309 24.04 0.677 29.43 -0.2413 26 | 1309 23.86 0.6026 93.36 0.1106 27 | 1309 23.36 0.4121 44.58 0.3603 28 | 1309 23.68 0.231 70.27 0.4864 29 | 1309 22.48 0.181 112.6 0.1157 30 | 1309 22.99 0.6874 91.35 0.06798 31 | 1309 22 0.5242 37.71 -0.9633 32 | 1309 26.91 0.616 17.65 0.9988 33 | 1309 25.79 0.3323 16.04 -0.01389 34 | 1309 24.11 0.2505 25.6 -0.2523 35 | 1309 23.51 0.2797 56.44 0.3159 36 | 1309 23.73 0.6141 9.834 -1.385 37 | 1309 21.48 0.3838 70.04 -1.108 38 | 1309 25.02 0.498 15.53 -0.4778 39 | 1309 25.08 0.5834 22.22 0.6161 40 | 1309 26.24 0.2518 6.193 -0.4173 41 | 1309 25.71 0.1477 33.97 1.155 42 | 1309 22.85 0.5397 105.1 -0.2238 43 | 1309 21.75 0.6768 74.57 -0.2596 44 | 1309 23.16 0.6723 34.65 0.6923 45 | 1309 23.74 0.3943 47.13 -0.4224 46 | 1309 28.62 0.4793 10.65 1.27 47 | 1309 26.46 0.5398 12.95 0.4487 48 | 1309 24.58 0.6414 20.05 -0.1107 49 | 1309 27.17 0.1973 17.29 1.237 50 | 1309 26.19 0.3435 19.64 0.7325 51 | 1309 24.32 0.3503 21.85 -0.2851 52 | 1309 20.03 0.5174 90.86 -1.354 53 | 1309 23.12 0.3549 49.45 -0.3475 54 | 1309 25.08 0.6149 19.81 0.1892 55 | 1309 23.71 0.6082 26.33 -0.4236 56 | 1309 21.8 0.1421 52.95 -0.7808 57 | 1309 28.82 0.2811 3.637 0.5495 58 | 1309 23.5 0.6878 32.95 -0.4174 59 | 1309 25.2 0.1214 17.28 0.1361 60 | 1309 22.87 0.3954 65.99 -0.0877 61 | 1309 23.52 0.6714 21.28 -0.8897 62 | 1309 25.4 0.5863 18.16 0.3616 63 | 1309 23.58 0.2766 67.28 0.2815 64 | 1309 23.66 0.4577 49.59 0.1661 65 | 1309 23.02 0.3587 140.7 1.011 66 | 1309 21.95 0.4554 20.34 -1.969 67 | 1309 23.83 0.6363 25.11 -0.9261 68 | 1309 26.71 0.4324 23.37 1.118 69 | 1309 28.23 0.3957 8.477 1.114 70 | 1309 23.38 0.2916 13.53 -1.365 71 | 1309 23.38 0.258 54.76 0.03091 72 | 1309 26.54 0.4254 14.19 0.5538 73 | 1309 23.67 0.1494 46.11 0.0539 74 | 1309 23.03 0.4814 70.63 -0.05804 75 | 1309 24.22 0.5778 49.85 0.2621 76 | 1309 24.77 0.6728 45.41 0.3747 77 | 1309 24.19 0.5108 79.09 0.8287 78 | 1309 23.63 0.393 68.2 0.4081 79 | 1309 24.34 0.3912 15.05 -0.347 80 | 1309 25.71 0.68 40.09 0.6551 81 | 1309 22.09 0.2268 62.46 -0.5 82 | 1309 22.22 0.347 52.6 -0.797 83 | 1309 25.38 0.6938 7.514 0.01028 84 | 1309 24.78 0.117 25.73 0.09176 85 | 1309 25.57 0.5208 9.577 0.1988 86 | 1309 24.74 0.1151 31.7 0.3133 87 | 1309 23.65 0.2925 120.3 1.305 88 | 1309 23.87 0.1441 36.75 0.02101 89 | 1309 22.16 0.1365 110.5 -0.005696 90 | 1309 27.46 0.1668 5.435 0.3532 91 | 1309 22.85 0.2016 27.44 -1.119 92 | 1309 27.57 0.4766 31.83 2.016 93 | 1309 28.2 0.363 6.819 0.4762 94 | 1309 24.14 0.5985 17.39 -0.7656 95 | 1309 24.53 0.2439 29.19 0.3582 96 | 1309 23.56 0.214 34.22 -0.4937 97 | 1309 23.59 0.5271 30.37 -0.3202 98 | 1309 22.15 0.615 48.6 -0.5463 99 | 1309 25.75 0.4354 10.2 -0.2144 100 | 1309 21.87 0.5227 38.98 -1.008 101 | 1309 19.88 0.4631 132.8 -1.058 102 | 1309 24.36 0.4355 13.25 -0.8279 103 | 1309 24.4 0.6162 39.69 0.536 104 | 1309 25.17 0.6519 13.71 -0.4936 105 | 1309 26.11 0.6098 23.32 0.1985 106 | 3021 23.57 0.2096 57.92 -0.5499 107 | 3021 23.73 0.4018 140.2 1.214 108 | 3021 23.06 0.6704 77.02 -0.3123 109 | 3021 24.17 0.2395 28.66 -0.8679 110 | 3021 23.5 0.5434 99.95 -0.2043 111 | 3021 25.65 0.557 12.19 -0.4621 112 | 3021 19.99 0.5596 454.3 -0.7643 113 | 3021 21.25 0.6547 264.7 0.3954 114 | 3021 22.07 0.2937 56.14 -1.361 115 | 3021 26.43 0.5074 17.24 0.1848 116 | 3021 27.07 0.2031 34.83 1.077 117 | 3021 26.92 0.5257 51.73 1.678 118 | 3021 27.06 0.3936 40.54 1.089 119 | 3021 23.4 0.3652 51.74 -0.1419 120 | 3021 23.44 0.4879 66.17 -0.07623 121 | 3021 27.09 0.3871 22.46 0.7946 122 | 3021 25.6 0.5686 34.66 0.7069 123 | 3021 24.82 0.4383 29.86 -0.6394 124 | 3021 22.03 0.6095 36.67 -1.56 125 | 3021 24.22 0.2995 51.03 -0.3239 126 | 3021 28.69 0.5126 8.463 1.14 127 | 3021 24.89 0.2862 34.27 -0.05313 128 | 3021 22.25 0.4965 106.3 -0.9762 129 | 3021 24.64 0.3127 24.06 -0.546 130 | 3021 27.11 0.1368 16.6 0.489 131 | 3021 26.54 0.3663 19.86 0.331 132 | 3021 24.08 0.525 51.8 -0.1907 133 | 3021 28.01 0.2545 9.183 0.1294 134 | 3021 24.89 0.471 36.92 -0.2373 135 | 3021 28.8 0.173 3.444 -0.09962 136 | 3021 21.98 0.4824 90.59 -1.014 137 | 3021 23.77 0.135 30.14 -0.9259 138 | 3021 22.95 0.1286 81.22 -0.4976 139 | 3021 25.48 0.4072 21.5 -0.4243 140 | 3021 24.05 0.2796 38.25 -0.7506 141 | 3021 23.6 0.3079 166.1 0.3818 142 | 3021 27.19 0.4895 15.73 0.3774 143 | 3021 24.61 0.6693 60.64 0.8392 144 | 3021 27.83 0.4097 6.816 -0.05379 145 | 3021 27.21 0.5281 5.3 -0.4854 146 | 3021 23.11 0.4517 50.9 -0.6629 147 | 3021 22.57 0.337 32.54 -1.588 148 | 3021 26.07 0.5031 22.42 0.1495 149 | 3021 23.72 0.2423 31.41 -0.8855 150 | 3021 27.04 0.6089 22.12 0.6746 151 | 3021 24.93 0.2755 38.96 0.3628 152 | 3021 24.46 0.1724 53.96 0.413 153 | 3021 25.22 0.3587 62.58 0.7918 154 | 3021 24.7 0.2632 32.01 -0.07635 155 | 3021 24.07 0.2642 55.71 -0.04072 156 | 3021 22.63 0.4853 50.85 -0.5898 157 | 3021 23.25 0.3699 41.49 -0.5271 158 | 3021 25.48 0.6451 22.22 -0.3378 159 | 3021 28.69 0.5652 4.725 0.3672 160 | 3021 25.17 0.3035 27.69 -0.1852 161 | 3021 25.86 0.5222 26.9 0.2471 162 | 3021 27.15 0.2435 10.46 0.1567 163 | 3021 24.27 0.2231 54.61 -0.2605 164 | 3370 24.51 0.1206 17.72 -0.4724 165 | 3370 24.62 0.3879 16.76 -0.5505 166 | 3370 25.8 0.411 42.54 0.9577 167 | 3370 25.04 0.4355 22.47 0.002806 168 | 3370 26.36 0.6741 15.61 0.3172 169 | 3370 26.08 0.5638 26.91 -0.2845 170 | 3370 26.42 0.534 29.91 0.4789 171 | 3370 27.47 0.627 74.92 2.019 172 | 3370 22.85 0.6795 24.64 -0.4117 173 | 3370 25.71 0.3038 17.64 0.2557 174 | 3370 26.7 0.5361 12.75 0.2262 175 | 3370 25.21 0.4757 28.3 0.4077 176 | 3370 24.75 0.5856 93.16 -0.00592 177 | 3370 22.94 0.5989 34.4 -1.207 178 | 3370 23.14 0.6538 47.49 -0.7179 179 | 3370 24.44 0.5885 41.66 0.3744 180 | 3370 22.5 0.271 46.87 -1.155 181 | 3370 25.5 0.4635 42.47 0.4683 182 | 3370 24.27 0.2566 59.64 0.1962 183 | 3370 25.4 0.5888 16.63 0.2819 184 | 3370 26.74 0.3787 15.13 0.4166 185 | 3370 23.9 0.264 79.95 -0.03143 186 | 3370 26.3 0.1807 12.5 0.4517 187 | 3370 22.43 0.1868 94.73 -0.7892 188 | 3370 26.29 0.218 8.353 0.1572 189 | 3370 24.94 0.3987 34.88 0.074 190 | 3370 23.61 0.2237 27.48 -0.7009 191 | 3370 24.36 0.5604 35.17 -0.1303 192 | 3370 27.77 0.254 16.7 1.399 193 | 3370 23.83 0.2576 78.44 0.4008 194 | 3370 23.92 0.4856 14.49 -0.9581 195 | 3370 23.64 0.6971 20.99 -0.8104 196 | 3370 25.02 0.4255 39.67 0.7461 197 | 3982 26.61 0.1558 33.08 0.9693 198 | 3982 25.72 0.1874 16.67 -0.225 199 | 3982 24.23 0.2361 28.33 -0.4425 200 | 3982 26.33 0.1506 13.41 0.2043 201 | 3982 24.52 0.6015 85.1 0.3608 202 | 3982 26.33 0.6069 14.84 -0.04329 203 | 3982 23.7 0.6917 13.91 -0.9318 204 | 3982 28.41 0.4281 14.62 1.596 205 | 3982 23.23 0.6635 18.91 -1.356 206 | 3982 24.26 0.1476 15.2 -1.002 207 | 3982 24.46 0.3714 22.58 -0.3187 208 | 3982 25.93 0.3653 18.98 -0.1523 209 | 3982 22.91 0.4878 37.47 -0.8961 210 | 3982 25.58 0.4193 32.53 0.4618 211 | 3982 25.68 0.5985 62.12 0.7796 212 | 3982 26.73 0.1599 19.68 0.7386 213 | 3982 26.94 0.1554 31.39 1.362 214 | 3982 23.91 0.1117 61.44 -0.177 215 | 3982 24.21 0.5767 24.35 -0.04404 216 | 3982 25.75 0.1907 57.7 1.141 217 | 3982 25.16 0.1483 14.75 -0.5189 218 | 3982 24.25 0.5196 53.35 -0.4775 219 | 3982 24.06 0.1269 66.69 0.097 220 | 3982 23.65 0.2592 52 -0.4574 221 | 3982 24.55 0.4025 15.75 -0.3644 222 | 3982 23.46 0.1224 28.59 -1.005 223 | 3982 25.18 0.4489 36.22 0.1608 224 | 3982 24.09 0.4106 23.65 -0.7131 225 | 3982 26.15 0.356 15.64 0.3629 226 | 3982 25.7 0.6492 32.53 0.2554 227 | 3982 26.69 0.3555 27.35 1.134 228 | 3982 25.52 0.5855 10.45 -0.3102 229 | 3982 24.88 0.1359 12.47 -0.9553 230 | 3982 24.45 0.153 23.35 -0.6433 231 | 3982 22.15 0.3132 90.28 -0.9712 232 | 3982 22.43 0.1886 14.69 -2.288 233 | 3982 26.59 0.5153 33.99 0.8142 234 | 3982 27.81 0.5712 12.51 1.025 235 | 3982 24.14 0.3503 57.62 0.1232 236 | 3982 24.86 0.294 53.53 0.5507 237 | 3982 24.9 0.6497 27.02 -0.1175 238 | 3982 23.6 0.6024 39.18 -0.6587 239 | 3982 26.98 0.4582 51.16 1.598 240 | 3982 21.65 0.5478 74.14 -0.8335 241 | 3982 22.77 0.4783 57.66 -0.4648 242 | 3982 26.22 0.1087 47.52 1.18 243 | 3982 25.5 0.1978 18.12 -0.1476 244 | 3982 24.4 0.4539 33.8 0.09441 245 | 3982 24.79 0.1072 20.94 -0.5371 246 | 3982 26.24 0.5289 27.92 0.4451 247 | 3982 25.97 0.3218 19.13 -0.1041 248 | 3982 25.72 0.1759 18.1 0.06964 249 | 3982 25.02 0.3523 21.84 -0.03249 250 | 3982 22.23 0.5553 65.56 -1.017 251 | 3982 25.99 0.3082 25.4 0.4606 252 | 3982 23.77 0.1223 48.83 -0.4734 253 | 3982 25.69 0.2443 44.45 0.7801 254 | 3982 23.51 0.306 86.94 0.2761 255 | 3982 26.76 0.224 20.35 0.6919 256 | 3982 25.58 0.181 34.26 0.5254 257 | 3982 24.35 0.4569 11.34 -0.9923 258 | 3982 24.77 0.1727 33.61 0.03167 259 | 3982 25.78 0.6033 30.03 0.4145 260 | 3982 22.57 0.4076 44.93 -0.9367 261 | 3982 22.17 0.5552 72.82 -0.7333 262 | 3982 23.11 0.3307 124.8 -0.1191 263 | 3982 22.77 0.1338 144.2 -0.2594 264 | 3982 24.81 0.1585 22.72 -0.4047 265 | 4038 23.25 0.1475 105.7 -0.4692 266 | 4038 23.62 0.2199 85.69 -0.2481 267 | 4038 27.54 0.3209 16.76 1.145 268 | 4038 26.93 0.4041 67.15 2.051 269 | 4038 25 0.1844 67.26 0.7175 270 | 4038 26.54 0.1305 25.28 0.5785 271 | 4038 23.18 0.2478 55.86 -0.8433 272 | 4038 25.15 0.4853 122 0.7728 273 | 4038 27.3 0.46 20.17 0.2876 274 | 4038 23.9 0.5681 61.75 -0.8143 275 | 4038 23.41 0.519 42.27 -0.4978 276 | 4038 25.94 0.1109 9.72 -0.5444 277 | 4038 24.53 0.5833 31.49 -0.491 278 | 4038 26.17 0.3653 18.96 0.3618 279 | 4038 24.05 0.428 80.47 -0.2901 280 | 4038 25.19 0.487 20.25 -0.3931 281 | 4038 25.06 0.4438 28.41 0.2406 282 | 4038 27.3 0.1744 30.16 1.223 283 | 4038 25.72 0.2391 23.46 0.3779 284 | 4038 27.06 0.4219 6.929 -0.3466 285 | 4038 25.54 0.4787 58.57 0.3241 286 | 4038 25.48 0.2059 34.93 0.1662 287 | 4038 23.33 0.4238 76.33 -0.4143 288 | 4038 26.53 0.4321 22.87 0.4586 289 | 4038 24.78 0.2806 43.88 0.06616 290 | 4038 26.87 0.596 50.18 0.8284 291 | 4038 26.44 0.6739 13.76 -0.1551 292 | 4038 25.01 0.2583 17.57 -0.5437 293 | 4038 24.58 0.1916 58.85 0.03944 294 | 4038 25.62 0.2185 60.42 0.2537 295 | 4038 24.97 0.3424 61.1 0.3013 296 | 4038 27.08 0.4541 6.894 0.04313 297 | 4038 24.69 0.3995 6.54 -1.973 298 | 4038 26.4 0.4959 20.73 0.579 299 | 4038 23.49 0.641 220.2 0.6035 300 | 4038 24.84 0.2753 35.71 -0.3668 301 | 4038 26.06 0.4897 20.45 0.3891 302 | 4038 23.31 0.1085 113.9 -0.2098 303 | 4038 24.64 0.471 35.33 -0.6 304 | 4038 27.72 0.6497 11.83 0.4673 305 | 4038 25.08 0.6687 24.53 0.6592 306 | 4038 25.85 0.4775 8.592 -0.4529 307 | 4038 26.99 0.4601 53.27 1.609 308 | 4038 25.31 0.4549 108.2 0.8934 309 | 4038 24.51 0.2132 49.64 -0.3291 310 | 4038 24.43 0.6547 37.26 -0.5034 311 | 4038 24.7 0.3666 47.67 -0.1106 312 | 4038 25.5 0.1924 14.46 -0.3838 313 | 4038 24.09 0.1099 44.59 -0.4865 314 | 4038 25.38 0.4298 26.71 -0.3557 315 | 4038 24.66 0.6125 64.89 0.5916 316 | 4038 25.37 0.3165 26.3 -0.2549 317 | 4038 25.37 0.6975 19.81 0.07291 318 | 4038 24.5 0.1584 19.88 -0.7929 319 | 4038 23.88 0.6513 193.9 0.6966 320 | 4038 28.54 0.6528 14.62 1.053 321 | 4038 22.8 0.6304 60.38 -0.2505 322 | 4038 26.42 0.5557 21.39 0.3075 323 | 4038 26.82 0.1766 22.3 0.6833 324 | 4038 26.96 0.3052 17.38 0.384 325 | 4038 24.46 0.31 83.01 0.1959 326 | 4038 26.76 0.4706 17.44 0.3224 327 | 4038 22.72 0.5196 29.2 -1.271 328 | 4038 25.51 0.6293 31.85 0.5173 329 | 4038 25.99 0.1826 22.09 0.2339 330 | 4038 23.9 0.1966 26.62 -0.7956 331 | 4038 24.43 0.5471 149 0.2358 332 | 4038 23.44 0.3679 22.65 -1.351 333 | 4038 28.47 0.2108 6.156 0.6583 334 | 4038 25.54 0.4823 16.73 -0.05491 335 | 4038 23.06 0.3629 90.3 -0.482 336 | 4038 24.22 0.2062 46.32 -0.5061 337 | 4038 27.08 0.5865 19.6 0.57 338 | 4038 27.17 0.2325 15.21 0.8498 339 | 4038 22.49 0.6484 87.13 -1.128 340 | 4038 25.85 0.3614 28.16 0.2679 341 | 4038 25.53 0.4985 53.45 0.5921 342 | 4038 25.91 0.1959 27.38 0.2265 343 | 4038 26.1 0.3456 30.59 0.1243 344 | 4038 25.14 0.5182 27.86 0.01591 345 | 4038 25.65 0.1513 76.72 0.7765 346 | 4038 25.71 0.4383 50.75 0.5224 347 | 4038 25.38 0.6391 44.91 0.5945 348 | 4038 24.08 0.2009 42.15 -0.502 349 | 4038 25.53 0.6024 34.9 0.439 350 | 4038 24.37 0.2527 30.3 -0.5912 351 | 4038 25.41 0.3287 25.44 0.08784 352 | 4038 24.61 0.5054 49.92 0.0138 353 | 4038 26.88 0.4908 14.84 0.2319 354 | 4038 27.11 0.2231 24.88 0.975 355 | 4038 24.6 0.5026 80.82 -0.2561 356 | 4038 28.02 0.1643 25.74 1.593 357 | 4038 25.51 0.5904 29.92 -0.2876 358 | 4038 23.02 0.5192 44.5 -0.6046 359 | 4038 25.11 0.3028 81.66 0.4264 360 | 4038 27.65 0.386 16.65 0.8834 361 | 4038 28.48 0.6889 15.24 0.8719 362 | 4038 24.65 0.1459 36.36 -0.4232 363 | 4038 26.22 0.1874 19.79 0.1465 364 | 4038 25.6 0.3178 31.15 0.04821 365 | 4038 27.74 0.5883 8.509 0.6444 366 | 4038 27.22 0.3151 15.59 0.6081 367 | 4038 25.17 0.1302 36.69 0.07874 368 | 4038 25.53 0.6386 21.98 0.3734 369 | 4038 26.41 0.204 22.01 0.186 370 | 4038 25.34 0.1657 46.14 0.3575 371 | 4258 22.42 0.6556 12.95 -0.5049 372 | 4258 17.96 0.1343 68.02 -0.9578 373 | 4258 21.57 0.5589 23.42 -0.4149 374 | 4258 21.15 0.5914 42.62 -0.349 375 | 4258 19.87 0.5756 19.28 -1.014 376 | 4258 19.68 0.3951 105.7 0.7335 377 | 4258 18.18 0.6045 54.08 -0.4968 378 | 4258 21.07 0.5787 32.27 0.7771 379 | 4258 22.7 0.5193 29.74 1.205 380 | 4258 21.72 0.1061 42.31 1.15 381 | 4258 20.34 0.424 54.11 0.2982 382 | 4258 22.79 0.2576 31.24 1.325 383 | 4258 24.06 0.2788 15.66 1.558 384 | 4258 19.27 0.1356 45.17 -0.6185 385 | 4258 22.12 0.1573 24.54 0.72 386 | 4258 22.04 0.5672 31.29 0.4111 387 | 4258 20.03 0.5376 20.61 -0.3163 388 | 4258 19.8 0.1523 68.81 0.332 389 | 4258 20.22 0.3099 42.66 -0.06701 390 | 4258 20.33 0.3195 44.79 0.2574 391 | 4258 20.25 0.4625 26.35 -0.1931 392 | 4258 21.72 0.1449 23.12 0.508 393 | 4258 20 0.4376 85.97 0.9468 394 | 4258 19.59 0.5284 26.15 -1.201 395 | 4258 22.47 0.2925 20 0.4826 396 | 4258 19.69 0.51 34.38 -0.502 397 | 4258 20.56 0.2222 20.15 -0.4381 398 | 4258 20.52 0.1626 39.18 -0.03403 399 | 4258 20.83 0.3855 28.42 -0.1985 400 | 4258 20.81 0.2115 29.97 0.01453 401 | 4258 19.94 0.1086 33.71 -0.4204 402 | 4258 19.57 0.5353 40.17 -0.8284 403 | 4258 22.98 0.4948 14.07 0.6869 404 | 4258 21.3 0.3747 30.08 0.7394 405 | 4258 18.44 0.4228 37.43 -0.9458 406 | 4258 20.87 0.1218 16.85 -0.8349 407 | 4258 22.1 0.3695 23.03 0.6341 408 | 4258 20.87 0.2844 22.31 -0.07724 409 | 4258 19.56 0.4238 39.01 -0.6768 410 | 4258 19.9 0.3189 114.4 1.099 411 | 4258 18.85 0.3054 136.4 0.7662 412 | 4258 20.04 0.4818 64.56 0.6737 413 | 4258 21.59 0.6011 23.66 0.6347 414 | 4258 20.29 0.1971 90.75 1.232 415 | 4258 22.41 0.2864 20.61 0.7123 416 | 4258 24.81 0.5205 17.41 1.149 417 | 4258 21.59 0.6403 35.33 0.6851 418 | 4258 21.15 0.1812 29.5 0.3163 419 | 4258 21.07 0.6857 21.68 0.5262 420 | 4258 19.49 0.652 57.49 0.3217 421 | 4258 22.41 0.2523 28.45 0.8523 422 | 4258 23.64 0.4616 9.045 0.2932 423 | 4258 22.01 0.5285 15.02 -0.7239 424 | 4258 23.3 0.1474 19.15 1.152 425 | 4258 17.95 0.2477 65.3 -0.8361 426 | 4258 20.3 0.5894 34.24 -0.171 427 | 4258 21.93 0.5988 30.18 0.6234 428 | 4258 20.4 0.3224 25.83 -0.4107 429 | 4258 18.89 0.4904 96.23 0.02137 430 | 4258 21.11 0.4742 55.59 1.06 431 | 4258 23.53 0.5629 12.67 0.6506 432 | 4258 18.48 0.404 118.2 0.4141 433 | 4258 20.66 0.2723 35.79 0.09851 434 | 4258 19.24 0.1822 30 -1.065 435 | 4258 21.21 0.2784 42.79 0.7153 436 | 4258 16.01 0.1735 161.4 -1.108 437 | 4258 23.01 0.2531 11.86 0.3567 438 | 4258 18.11 0.4086 77.74 -0.2498 439 | 4258 19.05 0.3984 12.88 -1.552 440 | 4258 20.8 0.1526 20.86 -0.4142 441 | 4258 17.2 0.4967 113.7 -0.8796 442 | 4258 22.07 0.2881 20.95 0.4694 443 | 4258 24.15 0.6463 6.961 0.06947 444 | 4258 20.07 0.6608 109.6 1.116 445 | 4258 19.65 0.3718 36.22 -0.6589 446 | 4258 19.32 0.3274 37.91 -0.517 447 | 4258 21.16 0.4595 21.08 0.1383 448 | 4258 19.83 0.5512 73.87 0.949 449 | 4258 22.2 0.6456 26.01 0.3768 450 | 4258 20.59 0.4725 30.69 0.02486 451 | 4258 19.92 0.2824 27.84 -0.6069 452 | 4258 24.43 0.5953 10.33 1.525 453 | 4258 19.01 0.1502 76.98 -0.1112 454 | 4258 19.95 0.2889 20.76 -0.8617 455 | 4258 19.59 0.549 50.84 0.1928 456 | 4258 20.63 0.6903 25.27 -0.5382 457 | 4258 18.04 0.2584 79.34 -0.6855 458 | 4258 21.85 0.5426 42.91 0.7961 459 | 4258 20.89 0.2268 39.8 0.4906 460 | 4258 21.24 0.4361 33.44 0.4144 461 | 4258 21.12 0.4533 42.26 0.8819 462 | 4258 18.71 0.1603 89.04 0.0926 463 | 4258 18.26 0.2599 61.78 -0.8864 464 | 4258 21.53 0.5567 25.72 0.1534 465 | 4258 22.59 0.1515 11.46 -0.00826 466 | 4258 20.06 0.3795 38.8 -0.6477 467 | 4258 21.57 0.4159 13.57 -0.8767 468 | 4258 24.04 0.1387 14.27 1.045 469 | 4258 23.52 0.4811 9.956 0.5498 470 | 4258 20.96 0.446 13.19 -0.6319 471 | 4258 18.87 0.1581 48.93 -0.6533 472 | 4258 20.09 0.411 50.8 0.3532 473 | 4258 21.14 0.6986 21.95 -0.02546 474 | 4258 21.84 0.1651 26.82 0.5993 475 | 4258 19.22 0.3645 54.39 -0.03594 476 | 4258 19.86 0.3354 37.22 -0.2307 477 | 4258 22.39 0.4566 16.72 0.3184 478 | 4258 21.12 0.6216 19.75 -0.1116 479 | 4258 22.67 0.1762 5.697 -0.472 480 | 4258 21.54 0.4874 22.26 0.3921 481 | 4258 22.35 0.6439 32.14 0.6922 482 | 4258 20.41 0.262 25.43 -0.3123 483 | 4258 20.56 0.6052 32.29 -0.2995 484 | 4258 21.47 0.602 14.39 -0.4558 485 | 4258 21.29 0.6173 19.23 -0.657 486 | 4258 23.37 0.4951 10.99 0.2668 487 | 4258 23.4 0.374 14.94 0.6555 488 | 4258 19.81 0.2337 21.45 -1.115 489 | 4258 18.71 0.4954 24.47 -1.479 490 | 4258 18.05 0.1908 48.23 -1.248 491 | 4258 23.7 0.3585 15.57 1.011 492 | 4258 22.62 0.1198 14.14 0.256 493 | 4258 24.39 0.3321 8.708 0.5913 494 | 4258 18.27 0.5554 58.47 -0.4136 495 | 4258 21.22 0.2465 32.17 0.6884 496 | 4258 23.05 0.5918 14.89 0.4032 497 | 4258 20.99 0.6273 23.62 -0.2948 498 | 4258 17.84 0.2131 36.54 -1.523 499 | 4258 21.82 0.278 26.9 0.6153 500 | 4258 20.66 0.5485 22.42 -0.4357 501 | 4258 21.25 0.1091 28.77 0.1924 502 | 4258 20.04 0.6225 47.9 0.135 503 | 4258 21.26 0.3538 36.08 0.5825 504 | 4258 20.36 0.2932 59.68 0.43 505 | 4258 21.75 0.5676 17.2 0.6196 506 | 4258 21.2 0.113 32.67 0.3419 507 | 4258 19.48 0.1294 46.61 -0.3343 508 | 4258 20.92 0.2065 31.15 0.2635 509 | 4258 22.54 0.6671 13.52 0.1782 510 | 4258 20.76 0.1421 28.92 -0.1883 511 | 4258 18.97 0.4352 92.13 0.08914 512 | 4258 22.16 0.3565 30.66 0.4806 513 | 4258 19.49 0.5111 33.33 -0.2119 514 | 4258 22.63 0.5228 17.78 0.756 515 | 4258 23.1 0.5066 16.58 1.073 516 | 4258 21.61 0.5765 24.33 0.484 517 | 4258 19.8 0.2371 59.11 0.2835 518 | 4258 19.23 0.5396 40.24 -0.4369 519 | 4258 20.12 0.3283 37.45 -0.2994 520 | 4258 19.3 0.1004 44.57 -0.4179 521 | 4258 20.71 0.4117 51.67 0.8573 522 | 4258 20.4 0.4381 34.62 -0.1349 523 | 4258 19.44 0.2376 61.03 -0.3139 524 | 4258 18.94 0.2463 46.16 -0.7037 525 | 4258 21.08 0.1108 28.51 0.1443 526 | 4258 20.56 0.4609 64.81 1.005 527 | 4258 20.48 0.2454 49.52 0.6811 528 | 4258 24.94 0.664 5.024 0.962 529 | 4258 20.13 0.4548 20.17 -0.8804 530 | 4258 21.56 0.5817 28.28 0.3099 531 | 4258 18.79 0.6411 59.64 -0.7737 532 | 4258 22.49 0.148 19.88 0.5261 533 | 4258 21.5 0.2375 40.51 0.7403 534 | 4258 22.55 0.4611 10.34 -0.3505 535 | 4258 18.49 0.5003 84.67 0.322 536 | 4258 21.83 0.3989 24.96 0.4592 537 | 4258 21.09 0.264 32.03 0.003788 538 | 4258 20.92 0.4787 20.9 -0.5162 539 | 4258 21.72 0.6526 69.43 0.7832 540 | 4258 19.4 0.4182 44.77 -0.7619 541 | 4258 19.19 0.2776 148.9 0.8285 542 | 4258 20.97 0.5823 24.69 0.2623 543 | 4258 22.09 0.6361 11.04 -0.7154 544 | 4258 21.22 0.1387 22.46 -0.1411 545 | 4258 20.64 0.646 52.77 0.3506 546 | 4258 22.74 0.3029 11.82 -0.05918 547 | 4258 21.2 0.5935 25.15 0.04607 548 | 4258 21.97 0.6968 15.16 0.007128 549 | 4258 21.41 0.696 43.18 1.246 550 | 4258 21.08 0.6935 35.28 0.06805 551 | 4258 19.34 0.6851 76.41 0.1922 552 | 4258 21.47 0.1108 31.31 0.428 553 | 4258 21.63 0.3651 17.64 0.2412 554 | 4258 22.59 0.4459 42.07 1.569 555 | 4258 17.08 0.4099 65.64 -1.459 556 | 4536 26.36 0.5173 15.56 0.01384 557 | 4536 24.45 0.6767 62.48 -0.1023 558 | 4536 25.6 0.255 14.6 -0.4741 559 | 4536 24.84 0.2414 40.15 -0.08233 560 | 4536 26.22 0.1381 14.48 -0.2636 561 | 4536 26.86 0.4676 24.34 0.91 562 | 4536 25.8 0.5047 22.35 0.02614 563 | 4536 27.82 0.4209 6.873 0.1808 564 | 4536 25.77 0.5101 19.6 0.131 565 | 4536 27.32 0.3671 24.24 1.344 566 | 4536 27.56 0.63 13.03 0.6494 567 | 4536 24.16 0.6242 81.13 0.8 568 | 4536 24.67 0.3907 58.58 0.5061 569 | 4536 26.33 0.4003 17.25 0.3796 570 | 4536 24.95 0.2141 28.72 -0.06456 571 | 4536 25.47 0.5532 52.43 0.4914 572 | 4536 27.23 0.4616 18.38 1.089 573 | 4536 23.42 0.3664 88.54 -0.2198 574 | 4536 24.68 0.6524 28.95 -0.2445 575 | 4536 25.49 0.1564 10.6 -0.9101 576 | 4536 24.32 0.482 50.32 -0.543 577 | 4536 27.17 0.3462 9.32 0.2066 578 | 4536 27.05 0.5529 18.42 0.5313 579 | 4536 26.56 0.4075 33.96 0.6625 580 | 4536 26.4 0.5169 58.43 0.5701 581 | 4536 25.29 0.1446 18.16 -0.5694 582 | 4536 25.72 0.3235 37 0.6478 583 | 4536 24.66 0.3145 38.9 0.08845 584 | 4536 27.22 0.5468 26.37 1.012 585 | 4536 25.27 0.2616 34.84 0.01408 586 | 4536 25.75 0.5295 33.86 0.0005355 587 | 4536 23.5 0.165 31.03 -0.9524 588 | 4536 24.44 0.2341 53.28 -0.2514 589 | 4536 24.69 0.5784 25.01 -0.4673 590 | 4536 24.73 0.1433 18.55 -0.7328 591 | 4536 25.43 0.312 49.66 0.3885 592 | 4536 25.56 0.4687 76.62 0.9819 593 | 4536 26.59 0.4997 16.59 0.05342 594 | 4536 25.89 0.2663 25.84 0.01584 595 | 4536 23.21 0.4967 33.86 -1.094 596 | 4536 25.32 0.5191 29.31 -0.561 597 | 4536 23.63 0.3738 103.2 0.05026 598 | 4536 24.73 0.4887 49.72 0.1693 599 | 4536 25.83 0.3837 19.09 -0.2568 600 | 4536 24.97 0.3436 23.7 -0.4907 601 | 4536 24.99 0.4077 54.21 0.5905 602 | 4536 25.81 0.1144 22.87 0.22 603 | 4536 25.33 0.1546 15.8 -0.7733 604 | 4536 25.22 0.1847 44.9 0.3098 605 | 4536 26.79 0.2316 28.34 0.8566 606 | 4536 23.04 0.3889 31.61 -1.399 607 | 4536 27.15 0.5038 10.22 0.4053 608 | 4536 24.43 0.2917 50.27 -0.1993 609 | 4536 23.33 0.4144 47.06 -0.7501 610 | 4536 27.3 0.5125 4.736 -0.2494 611 | 4536 25.79 0.4716 9.603 -1.08 612 | 4536 24.19 0.2304 33.53 -0.4797 613 | 4536 26.97 0.2085 10.49 -0.03526 614 | 4536 24.47 0.6887 17.96 -0.8072 615 | 4536 24.09 0.5298 33.5 -0.3741 616 | 4536 23.33 0.2522 105.5 -0.09206 617 | 4536 21.55 0.4863 90.9 -1.582 618 | 4536 26.3 0.4756 21.95 0.06988 619 | 4536 28.98 0.1999 16.83 1.918 620 | 4536 26.19 0.3522 80.7 1.141 621 | 4536 25 0.6714 48.71 0.3687 622 | 4639 22.17 0.6701 39.52 -0.007019 623 | 4639 19.08 0.5139 127.4 -0.5355 624 | 4639 23.66 0.6001 13.99 0.07797 625 | 4639 20.79 0.1238 48.64 -0.7582 626 | 4639 23.91 0.643 15.19 -0.5427 627 | 4639 22.51 0.4502 56.44 0.09597 628 | 4639 26.52 0.1466 4.984 0.2788 629 | 4639 24.63 0.2696 16.81 0.3301 630 | 4639 21.87 0.5786 48.37 0.1871 631 | 4639 22.93 0.284 34.29 -0.06087 632 | 4639 21.18 0.1336 63.83 -0.1654 633 | 4639 23.34 0.1565 24.21 -0.1347 634 | 4639 23.4 0.4415 39.25 0.4449 635 | 4639 22.13 0.3796 92.02 0.9371 636 | 4639 24.34 0.1579 38.02 1.214 637 | 4639 25.14 0.6278 9.286 -0.1976 638 | 4639 23.47 0.3796 25.44 -0.04723 639 | 4639 23.76 0.557 22.46 0.08938 640 | 4639 25.5 0.6012 19.04 0.09351 641 | 4639 21.69 0.106 34.05 -0.7119 642 | 4639 24.98 0.2194 16.75 0.4924 643 | 4639 22.9 0.1581 93.55 1.413 644 | 4639 20.75 0.2442 33.89 -1.483 645 | 4639 22.42 0.5389 51.45 0.6539 646 | 4639 21.65 0.5751 42.67 -0.8446 647 | 4639 24.99 0.1442 20.46 0.7682 648 | 4639 23.31 0.6624 36.43 0.3195 649 | 4639 27.11 0.2955 9.824 1.177 650 | 4639 22.94 0.3783 41.25 0.5563 651 | 4639 22.63 0.3341 36.75 -0.05593 652 | 4639 19.27 0.1553 113.4 -0.9388 653 | 4639 21.73 0.6353 74.74 0.09659 654 | 4639 24.84 0.2515 17.17 0.546 655 | 4639 24.46 0.3503 18.85 0.3407 656 | 4639 20.25 0.114 90.68 -0.4653 657 | 4639 23.6 0.671 15.31 -0.8428 658 | 4639 23.44 0.3714 28.7 0.1208 659 | 4639 24.35 0.5549 36.47 0.5642 660 | 4639 22.46 0.5819 102.7 0.8955 661 | 4639 23.6 0.6888 15.14 -0.3248 662 | 4639 23.17 0.4095 17.81 -0.3755 663 | 4639 24.16 0.3826 28.18 0.7167 664 | 4639 23.36 0.4469 27.07 -0.1244 665 | 4639 26.55 0.4427 13.18 0.5145 666 | 4639 23.09 0.1509 35.87 0.1523 667 | 4639 20.71 0.2728 43.93 -0.9418 668 | 4639 23.18 0.6469 31.49 -0.1627 669 | 4639 24.99 0.5965 23.52 0.8891 670 | 4639 23.74 0.6029 33.72 0.9143 671 | 4639 20.98 0.3927 28.45 -0.9312 672 | 4639 21.11 0.1501 66.76 -0.1907 673 | 4639 24.5 0.4728 20.47 0.2796 674 | 4639 24.27 0.5612 24.19 0.5055 675 | 4639 22.67 0.4119 92.14 0.5957 676 | 4639 20.95 0.3722 60.2 -0.1155 677 | 4639 20.56 0.4271 24.54 -1.98 678 | 4639 24.79 0.3893 10.97 -0.5968 679 | 4639 25.27 0.6283 20.43 0.6637 680 | 4639 23.22 0.4149 17.45 -0.576 681 | 4639 21.7 0.1657 51.03 -0.1348 682 | 4639 24.08 0.341 12.03 -0.408 683 | 4639 21.87 0.4323 30.78 -0.7817 684 | 4639 20.65 0.6214 50.83 -0.8029 685 | 4639 24.9 0.6032 32.16 0.7086 686 | 4639 20.5 0.4943 48.53 -0.4224 687 | 4639 23.09 0.172 31.22 0.1183 688 | 4639 23.9 0.6639 23.68 0.6977 689 | 4639 23.49 0.6064 22.29 0.2153 690 | 5584 28.63 0.1449 16.59 0.5625 691 | 5584 25.47 0.4898 43.97 -0.6501 692 | 5584 28.12 0.5356 22.59 0.2481 693 | 5584 26.88 0.1637 53.85 0.1861 694 | 5584 27.07 0.5089 28.46 -0.393 695 | 5584 26.92 0.2428 42.57 -0.2291 696 | 5584 24.36 0.4804 80.61 -0.5622 697 | 5584 27.07 0.3612 53.34 -0.004339 698 | 5584 26.35 0.5924 66.62 0.1422 699 | 5584 25.73 0.5597 44.17 -0.5815 700 | 5584 28.87 0.474 32.6 0.7643 701 | 5584 26.95 0.4113 53.22 0.1941 702 | 5584 26.85 0.4943 56.77 0.8421 703 | 5584 28.66 0.5388 14.11 -0.03569 704 | 5584 26.79 0.6903 6.14 -0.4369 705 | 5584 27.48 0.3065 30.03 0.3482 706 | 5584 27.23 0.5961 25.38 -0.4889 707 | 5584 27.25 0.1309 29.95 -0.1043 708 | 5584 26.31 0.4081 57.19 -0.4514 709 | 5584 25.49 0.5785 32.38 -0.9923 710 | 5584 26.25 0.4827 32.08 -0.4296 711 | 5584 27.73 0.5492 30.09 0.2213 712 | 5584 28.36 0.6086 22.13 -0.1252 713 | 5584 25.29 0.1549 66.28 -0.7537 714 | 5584 26.82 0.5154 18.35 -0.797 715 | 5584 27.22 0.2325 28.15 -0.0914 716 | 5584 27.17 0.6945 9.06 -0.2414 717 | 5584 26.82 0.5098 43.59 -0.4625 718 | 5584 26.63 0.1103 46.01 -0.03464 719 | 5584 25.87 0.3447 70.21 -0.2597 720 | 5584 25.97 0.2619 54.71 -0.09731 721 | 5584 28.12 0.3833 25.84 0.2095 722 | 5584 25.71 0.6889 45.09 -0.2682 723 | 5584 28.85 0.2589 21.31 0.7492 724 | 5584 27.5 0.5101 26 -0.1801 725 | 5584 28.03 0.4039 7.021 -0.1601 726 | 5584 27.78 0.3696 29.45 -0.07008 727 | 5584 26.81 0.4102 37.12 -0.3133 728 | 5584 26.07 0.2194 44.38 -0.4068 729 | 5584 24.95 0.2645 73.64 -0.7224 730 | 5584 28.23 0.361 41.21 0.4472 731 | 5584 27.91 0.4608 23.47 -0.0629 732 | 5584 25.97 0.5333 209.4 0.7176 733 | 5584 26.55 0.3408 65.78 -0.01364 734 | 5584 26.26 0.1562 42.29 -0.4934 735 | 5584 27.47 0.2084 29.02 -0.1384 736 | 5584 28.87 0.1594 12.43 0.4627 737 | 5584 26.09 0.4388 46.7 -0.116 738 | 5584 26.3 0.5125 47.92 -0.3688 739 | 5584 28.87 0.4686 17.19 0.5604 740 | 5584 28.83 0.6353 31.97 1.393 741 | 5584 28.03 0.448 90.64 1.102 742 | 5584 25.72 0.4186 40.89 -0.8806 743 | 5584 26.26 0.3823 35.85 -0.4217 744 | 5584 24.42 0.3566 43.03 -1.64 745 | 5584 26.99 0.5301 88.28 0.7967 746 | 5584 25.27 0.256 40.63 -0.9962 747 | 5584 27.67 0.3791 85.14 0.64 748 | 5584 28.08 0.5887 18.06 0.1591 749 | 5584 27.45 0.2384 15.14 -0.327 750 | 5584 27.46 0.2471 11.33 -0.6499 751 | 5584 26.58 0.1703 62.67 0.003382 752 | 5584 28.71 0.3088 13.31 -0.01793 753 | 5584 26.58 0.5085 3.511 -1.86 754 | 5584 28.74 0.1557 50.54 1.255 755 | 5584 27.79 0.5774 21.24 0.6135 756 | 5584 26.01 0.6736 39.17 -0.2066 757 | 5584 25.85 0.5754 52.79 -0.4482 758 | 5584 26.91 0.3066 41.14 0.1288 759 | 5584 24.48 0.5709 88.14 -0.9771 760 | 5584 27.1 0.2501 24.7 -0.05815 761 | 5584 27.08 0.4553 46.41 0.1552 762 | 5584 25.73 0.4802 31.37 -1.039 763 | 5584 27.85 0.3772 32.31 0.5842 764 | 5584 28.53 0.3765 15.41 0.492 765 | 5584 29.76 0.1913 11.28 0.8942 766 | 5584 30.17 0.3317 20.67 1.664 767 | 5584 25.97 0.6292 157.3 0.006415 768 | 5584 28.61 0.6126 24.62 0.4028 769 | 5584 27.05 0.6696 7.828 -1.058 770 | 5584 27.04 0.1921 76.72 0.6122 771 | 5584 31.75 0.1261 10.66 2.246 772 | 5584 26.53 0.3512 80.41 0.3861 773 | 5584 25.77 0.2626 232.2 -0.0005663 774 | 5584 25.5 0.59 31.57 -0.7646 775 | 5584 29.29 0.688 50.84 0.526 776 | 5584 26.92 0.6765 18.98 -1.014 777 | 5584 28.42 0.4442 26.38 0.8223 778 | 5584 28.21 0.5789 17.08 0.2883 779 | 5584 25.4 0.4084 25.79 -1.109 780 | 5584 28.13 0.2068 28.58 0.1861 781 | 5584 24.61 0.2939 42.84 -1.393 782 | 5584 25.39 0.5035 46.33 -0.7171 783 | 5584 24.99 0.5011 106.7 -0.5451 784 | 5584 23.48 0.499 70.69 -1.74 785 | 5584 25.71 0.5365 14.93 -0.7544 786 | 5584 24.77 0.5828 58.44 -0.994 787 | 5584 26.59 0.3892 131.7 1.075 788 | 5584 29.64 0.3687 20.37 1.463 789 | 5584 25.17 0.4988 38.13 -0.9641 790 | 5584 28.47 0.4629 23.63 0.7513 791 | 5584 27.46 0.4746 18.96 0.09471 792 | 5584 28.72 0.6318 14.81 -0.05339 793 | 5584 26.94 0.5385 28.26 -0.1843 794 | 5584 26.25 0.6062 39.22 -0.8128 795 | 5584 28.8 0.6922 17.03 0.2293 796 | 5584 27.85 0.371 18.75 0.09056 797 | 5584 26.4 0.5814 27.72 -0.7022 798 | 5584 28.4 0.6914 18.34 0.4082 799 | 5584 26.93 0.6678 39.02 -0.1762 800 | 5584 27.61 0.3048 37.4 0.3301 801 | 5584 32.2 0.5692 5.739 1.862 802 | 5584 27.09 0.2279 92.7 0.7964 803 | 5584 27.99 0.3098 38.71 0.2221 804 | 5584 27.85 0.6513 46.48 -0.06612 805 | 5584 28.5 0.3132 21.81 0.7664 806 | 5584 27.09 0.6324 49.81 0.3492 807 | 5584 28.06 0.4052 23.04 0.1371 808 | 5584 29.7 0.2874 8.621 1.097 809 | 5584 27.55 0.2874 49.19 0.4607 810 | 5584 27.31 0.1962 8.11 -0.8419 811 | 5584 29.56 0.4366 21.04 1.057 812 | 5584 28.33 0.1235 54.55 1.176 813 | 5584 29.41 0.2738 21.04 0.83 814 | 5584 28.23 0.6329 15.23 0.0972 815 | 5584 29.05 0.1461 27.02 0.9724 816 | 5584 25.87 0.1136 59.06 -0.3357 817 | 5584 26.88 0.167 69.82 0.3291 818 | 5584 25.05 0.698 36.75 -0.3463 819 | 5584 27.28 0.3823 61.41 0.2464 820 | 5584 26.07 0.6942 90.83 0.04312 821 | 5584 26.2 0.5417 17.14 -0.546 822 | 5584 26.75 0.6217 27.79 -0.7355 823 | 5584 26.42 0.2801 13.85 -1.221 824 | 5584 28.46 0.3632 8.09 -0.3418 825 | -------------------------------------------------------------------------------- /src/notebooks/stan/cepheid_v3.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Code generated by stanc v2.27.0 3 | #include 4 | namespace cepheid_v3_model_namespace { 5 | 6 | using stan::io::dump; 7 | using stan::model::assign; 8 | using stan::model::index_uni; 9 | using stan::model::index_max; 10 | using stan::model::index_min; 11 | using stan::model::index_min_max; 12 | using stan::model::index_multi; 13 | using stan::model::index_omni; 14 | using stan::model::model_base_crtp; 15 | using stan::model::rvalue; 16 | using namespace stan::math; 17 | 18 | 19 | stan::math::profile_map profiles__; 20 | static constexpr std::array locations_array__ = 21 | {" (found before start of program)", 22 | " (in '/Users/fran/projects/BayesianWorkflow/src/notebooks/stan/cepheid_v3.stan', line 34, column 2 to column 16)", 23 | " (in '/Users/fran/projects/BayesianWorkflow/src/notebooks/stan/cepheid_v3.stan', line 35, column 2 to column 26)", 24 | " (in '/Users/fran/projects/BayesianWorkflow/src/notebooks/stan/cepheid_v3.stan', line 37, column 2 to column 15)", 25 | " (in '/Users/fran/projects/BayesianWorkflow/src/notebooks/stan/cepheid_v3.stan', line 38, column 2 to column 25)", 26 | " (in '/Users/fran/projects/BayesianWorkflow/src/notebooks/stan/cepheid_v3.stan', line 41, column 2 to column 19)", 27 | " (in '/Users/fran/projects/BayesianWorkflow/src/notebooks/stan/cepheid_v3.stan', line 42, column 2 to column 18)", 28 | " (in '/Users/fran/projects/BayesianWorkflow/src/notebooks/stan/cepheid_v3.stan', line 48, column 2 to column 20)", 29 | " (in '/Users/fran/projects/BayesianWorkflow/src/notebooks/stan/cepheid_v3.stan', line 49, column 2 to column 20)", 30 | " (in '/Users/fran/projects/BayesianWorkflow/src/notebooks/stan/cepheid_v3.stan', line 52, column 2 to column 50)", 31 | " (in '/Users/fran/projects/BayesianWorkflow/src/notebooks/stan/cepheid_v3.stan', line 55, column 2 to column 47)", 32 | " (in '/Users/fran/projects/BayesianWorkflow/src/notebooks/stan/cepheid_v3.stan', line 62, column 2 to column 27)", 33 | " (in '/Users/fran/projects/BayesianWorkflow/src/notebooks/stan/cepheid_v3.stan', line 63, column 2 to column 26)", 34 | " (in '/Users/fran/projects/BayesianWorkflow/src/notebooks/stan/cepheid_v3.stan', line 64, column 2 to column 29)", 35 | " (in '/Users/fran/projects/BayesianWorkflow/src/notebooks/stan/cepheid_v3.stan', line 65, column 2 to column 28)", 36 | " (in '/Users/fran/projects/BayesianWorkflow/src/notebooks/stan/cepheid_v3.stan', line 68, column 2 to column 38)", 37 | " (in '/Users/fran/projects/BayesianWorkflow/src/notebooks/stan/cepheid_v3.stan', line 69, column 2 to column 35)", 38 | " (in '/Users/fran/projects/BayesianWorkflow/src/notebooks/stan/cepheid_v3.stan', line 72, column 2 to column 34)", 39 | " (in '/Users/fran/projects/BayesianWorkflow/src/notebooks/stan/cepheid_v3.stan', line 11, column 2 to column 9)", 40 | " (in '/Users/fran/projects/BayesianWorkflow/src/notebooks/stan/cepheid_v3.stan', line 12, column 2 to column 9)", 41 | " (in '/Users/fran/projects/BayesianWorkflow/src/notebooks/stan/cepheid_v3.stan', line 14, column 13 to column 15)", 42 | " (in '/Users/fran/projects/BayesianWorkflow/src/notebooks/stan/cepheid_v3.stan', line 14, column 2 to column 17)", 43 | " (in '/Users/fran/projects/BayesianWorkflow/src/notebooks/stan/cepheid_v3.stan', line 15, column 9 to column 11)", 44 | " (in '/Users/fran/projects/BayesianWorkflow/src/notebooks/stan/cepheid_v3.stan', line 15, column 2 to column 19)", 45 | " (in '/Users/fran/projects/BayesianWorkflow/src/notebooks/stan/cepheid_v3.stan', line 16, column 2 to column 15)", 46 | " (in '/Users/fran/projects/BayesianWorkflow/src/notebooks/stan/cepheid_v3.stan', line 17, column 9 to column 11)", 47 | " (in '/Users/fran/projects/BayesianWorkflow/src/notebooks/stan/cepheid_v3.stan', line 17, column 2 to column 20)", 48 | " (in '/Users/fran/projects/BayesianWorkflow/src/notebooks/stan/cepheid_v3.stan', line 18, column 9 to column 11)", 49 | " (in '/Users/fran/projects/BayesianWorkflow/src/notebooks/stan/cepheid_v3.stan', line 18, column 2 to column 15)", 50 | " (in '/Users/fran/projects/BayesianWorkflow/src/notebooks/stan/cepheid_v3.stan', line 24, column 9 to column 11)", 51 | " (in '/Users/fran/projects/BayesianWorkflow/src/notebooks/stan/cepheid_v3.stan', line 24, column 2 to column 16)", 52 | " (in '/Users/fran/projects/BayesianWorkflow/src/notebooks/stan/cepheid_v3.stan', line 27, column 2 to column 26)", 53 | " (in '/Users/fran/projects/BayesianWorkflow/src/notebooks/stan/cepheid_v3.stan', line 41, column 9 to column 11)", 54 | " (in '/Users/fran/projects/BayesianWorkflow/src/notebooks/stan/cepheid_v3.stan', line 42, column 9 to column 11)", 55 | " (in '/Users/fran/projects/BayesianWorkflow/src/notebooks/stan/cepheid_v3.stan', line 48, column 9 to column 11)", 56 | " (in '/Users/fran/projects/BayesianWorkflow/src/notebooks/stan/cepheid_v3.stan', line 49, column 9 to column 11)"}; 57 | 58 | 59 | 60 | class cepheid_v3_model final : public model_base_crtp { 61 | 62 | private: 63 | int Ng; 64 | int Nt; 65 | std::vector gal_id; 66 | Eigen::Matrix m_obs__; 67 | double sigma_m; 68 | Eigen::Matrix log10P__; 69 | Eigen::Matrix z__; 70 | Eigen::Matrix dL__; 71 | Eigen::Map> m_obs{nullptr, 0}; 72 | Eigen::Map> log10P{nullptr, 0}; 73 | Eigen::Map> z{nullptr, 0}; 74 | Eigen::Map> dL{nullptr, 0}; 75 | 76 | public: 77 | ~cepheid_v3_model() { } 78 | 79 | inline std::string model_name() const final { return "cepheid_v3_model"; } 80 | 81 | inline std::vector model_compile_info() const noexcept { 82 | return std::vector{"stanc_version = stanc3 v2.27.0", "stancflags = "}; 83 | } 84 | 85 | 86 | cepheid_v3_model(stan::io::var_context& context__, 87 | unsigned int random_seed__ = 0, 88 | std::ostream* pstream__ = nullptr) : model_base_crtp(0) { 89 | int current_statement__ = 0; 90 | using local_scalar_t__ = double ; 91 | boost::ecuyer1988 base_rng__ = 92 | stan::services::util::create_rng(random_seed__, 0); 93 | (void) base_rng__; // suppress unused var warning 94 | static constexpr const char* function__ = "cepheid_v3_model_namespace::cepheid_v3_model"; 95 | (void) function__; // suppress unused var warning 96 | local_scalar_t__ DUMMY_VAR__(std::numeric_limits::quiet_NaN()); 97 | (void) DUMMY_VAR__; // suppress unused var warning 98 | try { 99 | int pos__; 100 | pos__ = std::numeric_limits::min(); 101 | 102 | pos__ = 1; 103 | current_statement__ = 18; 104 | context__.validate_dims("data initialization","Ng","int", 105 | std::vector{}); 106 | Ng = std::numeric_limits::min(); 107 | 108 | current_statement__ = 18; 109 | Ng = context__.vals_i("Ng")[(1 - 1)]; 110 | current_statement__ = 19; 111 | context__.validate_dims("data initialization","Nt","int", 112 | std::vector{}); 113 | Nt = std::numeric_limits::min(); 114 | 115 | current_statement__ = 19; 116 | Nt = context__.vals_i("Nt")[(1 - 1)]; 117 | current_statement__ = 20; 118 | validate_non_negative_index("gal_id", "Nt", Nt); 119 | current_statement__ = 21; 120 | context__.validate_dims("data initialization","gal_id","int", 121 | std::vector{static_cast(Nt)}); 122 | gal_id = std::vector(Nt, std::numeric_limits::min()); 123 | 124 | current_statement__ = 21; 125 | gal_id = context__.vals_i("gal_id"); 126 | current_statement__ = 22; 127 | validate_non_negative_index("m_obs", "Nt", Nt); 128 | current_statement__ = 23; 129 | context__.validate_dims("data initialization","m_obs","double", 130 | std::vector{static_cast(Nt)}); 131 | m_obs__ = Eigen::Matrix(Nt); 132 | new (&m_obs) Eigen::Map>(m_obs__.data(), Nt); 133 | 134 | 135 | { 136 | std::vector m_obs_flat__; 137 | current_statement__ = 23; 138 | m_obs_flat__ = context__.vals_r("m_obs"); 139 | current_statement__ = 23; 140 | pos__ = 1; 141 | current_statement__ = 23; 142 | for (int sym1__ = 1; sym1__ <= Nt; ++sym1__) { 143 | current_statement__ = 23; 144 | assign(m_obs, m_obs_flat__[(pos__ - 1)], 145 | "assigning variable m_obs", index_uni(sym1__)); 146 | current_statement__ = 23; 147 | pos__ = (pos__ + 1); 148 | } 149 | } 150 | current_statement__ = 24; 151 | context__.validate_dims("data initialization","sigma_m","double", 152 | std::vector{}); 153 | sigma_m = std::numeric_limits::quiet_NaN(); 154 | 155 | current_statement__ = 24; 156 | sigma_m = context__.vals_r("sigma_m")[(1 - 1)]; 157 | current_statement__ = 25; 158 | validate_non_negative_index("log10P", "Nt", Nt); 159 | current_statement__ = 26; 160 | context__.validate_dims("data initialization","log10P","double", 161 | std::vector{static_cast(Nt)}); 162 | log10P__ = Eigen::Matrix(Nt); 163 | new (&log10P) Eigen::Map>(log10P__.data(), Nt); 164 | 165 | 166 | { 167 | std::vector log10P_flat__; 168 | current_statement__ = 26; 169 | log10P_flat__ = context__.vals_r("log10P"); 170 | current_statement__ = 26; 171 | pos__ = 1; 172 | current_statement__ = 26; 173 | for (int sym1__ = 1; sym1__ <= Nt; ++sym1__) { 174 | current_statement__ = 26; 175 | assign(log10P, log10P_flat__[(pos__ - 1)], 176 | "assigning variable log10P", index_uni(sym1__)); 177 | current_statement__ = 26; 178 | pos__ = (pos__ + 1); 179 | } 180 | } 181 | current_statement__ = 27; 182 | validate_non_negative_index("z", "Ng", Ng); 183 | current_statement__ = 28; 184 | context__.validate_dims("data initialization","z","double", 185 | std::vector{static_cast(Ng)}); 186 | z__ = Eigen::Matrix(Ng); 187 | new (&z) Eigen::Map>(z__.data(), Ng); 188 | 189 | { 190 | std::vector z_flat__; 191 | current_statement__ = 28; 192 | z_flat__ = context__.vals_r("z"); 193 | current_statement__ = 28; 194 | pos__ = 1; 195 | current_statement__ = 28; 196 | for (int sym1__ = 1; sym1__ <= Ng; ++sym1__) { 197 | current_statement__ = 28; 198 | assign(z, z_flat__[(pos__ - 1)], 199 | "assigning variable z", index_uni(sym1__)); 200 | current_statement__ = 28; 201 | pos__ = (pos__ + 1); 202 | } 203 | } 204 | current_statement__ = 29; 205 | validate_non_negative_index("dL", "Ng", Ng); 206 | current_statement__ = 30; 207 | dL__ = Eigen::Matrix(Ng); 208 | new (&dL) Eigen::Map>(dL__.data(), Ng); 209 | stan::math::fill(dL, std::numeric_limits::quiet_NaN()); 210 | 211 | current_statement__ = 31; 212 | assign(dL, divide(multiply(3.0e5, z), 70.0), "assigning variable dL"); 213 | current_statement__ = 32; 214 | validate_non_negative_index("alpha", "Ng", Ng); 215 | current_statement__ = 33; 216 | validate_non_negative_index("beta", "Ng", Ng); 217 | current_statement__ = 34; 218 | validate_non_negative_index("M_true", "Nt", Nt); 219 | current_statement__ = 35; 220 | validate_non_negative_index("m_true", "Nt", Nt); 221 | } catch (const std::exception& e) { 222 | stan::lang::rethrow_located(e, locations_array__[current_statement__]); 223 | // Next line prevents compiler griping about no return 224 | throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); 225 | } 226 | num_params_r__ = 1 + 1 + 1 + 1 + Ng + Ng; 227 | 228 | } 229 | 230 | template * = nullptr, 232 | stan::require_vector_like_vt* = nullptr> 233 | inline stan::scalar_type_t log_prob_impl(VecR& params_r__, 234 | VecI& params_i__, 235 | std::ostream* pstream__ = nullptr) const { 236 | using T__ = stan::scalar_type_t; 237 | using local_scalar_t__ = T__; 238 | T__ lp__(0.0); 239 | stan::math::accumulator lp_accum__; 240 | stan::io::deserializer in__(params_r__, params_i__); 241 | int current_statement__ = 0; 242 | local_scalar_t__ DUMMY_VAR__(std::numeric_limits::quiet_NaN()); 243 | (void) DUMMY_VAR__; // suppress unused var warning 244 | static constexpr const char* function__ = "cepheid_v3_model_namespace::log_prob"; 245 | (void) function__; // suppress unused var warning 246 | 247 | try { 248 | local_scalar_t__ mu_alpha; 249 | mu_alpha = DUMMY_VAR__; 250 | 251 | current_statement__ = 1; 252 | mu_alpha = in__.template read(); 253 | local_scalar_t__ tau_alpha; 254 | tau_alpha = DUMMY_VAR__; 255 | 256 | current_statement__ = 2; 257 | tau_alpha = in__.template read_constrain_lb( 258 | 0, lp__); 259 | local_scalar_t__ mu_beta; 260 | mu_beta = DUMMY_VAR__; 261 | 262 | current_statement__ = 3; 263 | mu_beta = in__.template read(); 264 | local_scalar_t__ tau_beta; 265 | tau_beta = DUMMY_VAR__; 266 | 267 | current_statement__ = 4; 268 | tau_beta = in__.template read_constrain_lb( 269 | 0, lp__); 270 | Eigen::Matrix alpha; 271 | alpha = Eigen::Matrix(Ng); 272 | stan::math::fill(alpha, DUMMY_VAR__); 273 | 274 | current_statement__ = 5; 275 | alpha = in__.template read>(Ng); 276 | Eigen::Matrix beta; 277 | beta = Eigen::Matrix(Ng); 278 | stan::math::fill(beta, DUMMY_VAR__); 279 | 280 | current_statement__ = 6; 281 | beta = in__.template read>(Ng); 282 | Eigen::Matrix M_true; 283 | M_true = Eigen::Matrix(Nt); 284 | stan::math::fill(M_true, DUMMY_VAR__); 285 | 286 | Eigen::Matrix m_true; 287 | m_true = Eigen::Matrix(Nt); 288 | stan::math::fill(m_true, DUMMY_VAR__); 289 | 290 | current_statement__ = 9; 291 | assign(M_true, 292 | add(rvalue(alpha, "alpha", index_multi(gal_id)), 293 | elt_multiply(rvalue(beta, "beta", index_multi(gal_id)), log10P)), 294 | "assigning variable M_true"); 295 | current_statement__ = 10; 296 | assign(m_true, 297 | add( 298 | add(M_true, 299 | multiply(5, 300 | stan::math::log10(rvalue(dL, "dL", index_multi(gal_id))))), 25), 301 | "assigning variable m_true"); 302 | { 303 | current_statement__ = 11; 304 | lp_accum__.add(normal_lpdf(mu_alpha, 0, 10)); 305 | current_statement__ = 12; 306 | lp_accum__.add(normal_lpdf(mu_beta, -5, 5)); 307 | current_statement__ = 13; 308 | lp_accum__.add(cauchy_lpdf(tau_alpha, 0, 2.5)); 309 | current_statement__ = 14; 310 | lp_accum__.add(cauchy_lpdf(tau_beta, 0, 2.5)); 311 | current_statement__ = 15; 312 | lp_accum__.add(normal_lpdf(alpha, mu_alpha, tau_alpha)); 313 | current_statement__ = 16; 314 | lp_accum__.add(normal_lpdf(beta, mu_beta, tau_beta)); 315 | current_statement__ = 17; 316 | lp_accum__.add(normal_lpdf(m_obs, m_true, sigma_m)); 317 | } 318 | } catch (const std::exception& e) { 319 | stan::lang::rethrow_located(e, locations_array__[current_statement__]); 320 | // Next line prevents compiler griping about no return 321 | throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); 322 | } 323 | lp_accum__.add(lp__); 324 | return lp_accum__.sum(); 325 | } // log_prob_impl() 326 | 327 | template * = nullptr, 329 | stan::require_vector_like_vt* = nullptr, 330 | stan::require_std_vector_vt* = nullptr> 331 | inline void write_array_impl(RNG& base_rng__, VecR& params_r__, 332 | VecI& params_i__, VecVar& vars__, 333 | const bool emit_transformed_parameters__ = true, 334 | const bool emit_generated_quantities__ = true, 335 | std::ostream* pstream__ = nullptr) const { 336 | using local_scalar_t__ = double; 337 | vars__.resize(0); 338 | stan::io::deserializer in__(params_r__, params_i__); 339 | static constexpr bool propto__ = true; 340 | (void) propto__; 341 | double lp__ = 0.0; 342 | (void) lp__; // dummy to suppress unused var warning 343 | int current_statement__ = 0; 344 | stan::math::accumulator lp_accum__; 345 | local_scalar_t__ DUMMY_VAR__(std::numeric_limits::quiet_NaN()); 346 | constexpr bool jacobian__ = false; 347 | (void) DUMMY_VAR__; // suppress unused var warning 348 | static constexpr const char* function__ = "cepheid_v3_model_namespace::write_array"; 349 | (void) function__; // suppress unused var warning 350 | 351 | try { 352 | double mu_alpha; 353 | mu_alpha = std::numeric_limits::quiet_NaN(); 354 | 355 | current_statement__ = 1; 356 | mu_alpha = in__.template read(); 357 | double tau_alpha; 358 | tau_alpha = std::numeric_limits::quiet_NaN(); 359 | 360 | current_statement__ = 2; 361 | tau_alpha = in__.template read_constrain_lb( 362 | 0, lp__); 363 | double mu_beta; 364 | mu_beta = std::numeric_limits::quiet_NaN(); 365 | 366 | current_statement__ = 3; 367 | mu_beta = in__.template read(); 368 | double tau_beta; 369 | tau_beta = std::numeric_limits::quiet_NaN(); 370 | 371 | current_statement__ = 4; 372 | tau_beta = in__.template read_constrain_lb( 373 | 0, lp__); 374 | Eigen::Matrix alpha; 375 | alpha = Eigen::Matrix(Ng); 376 | stan::math::fill(alpha, std::numeric_limits::quiet_NaN()); 377 | 378 | current_statement__ = 5; 379 | alpha = in__.template read>(Ng); 380 | Eigen::Matrix beta; 381 | beta = Eigen::Matrix(Ng); 382 | stan::math::fill(beta, std::numeric_limits::quiet_NaN()); 383 | 384 | current_statement__ = 6; 385 | beta = in__.template read>(Ng); 386 | Eigen::Matrix M_true; 387 | M_true = Eigen::Matrix(Nt); 388 | stan::math::fill(M_true, std::numeric_limits::quiet_NaN()); 389 | 390 | Eigen::Matrix m_true; 391 | m_true = Eigen::Matrix(Nt); 392 | stan::math::fill(m_true, std::numeric_limits::quiet_NaN()); 393 | 394 | vars__.emplace_back(mu_alpha); 395 | vars__.emplace_back(tau_alpha); 396 | vars__.emplace_back(mu_beta); 397 | vars__.emplace_back(tau_beta); 398 | for (int sym1__ = 1; sym1__ <= Ng; ++sym1__) { 399 | vars__.emplace_back(alpha[(sym1__ - 1)]); 400 | } 401 | for (int sym1__ = 1; sym1__ <= Ng; ++sym1__) { 402 | vars__.emplace_back(beta[(sym1__ - 1)]); 403 | } 404 | if (logical_negation((primitive_value(emit_transformed_parameters__) || 405 | primitive_value(emit_generated_quantities__)))) { 406 | return ; 407 | } 408 | current_statement__ = 9; 409 | assign(M_true, 410 | add(rvalue(alpha, "alpha", index_multi(gal_id)), 411 | elt_multiply(rvalue(beta, "beta", index_multi(gal_id)), log10P)), 412 | "assigning variable M_true"); 413 | current_statement__ = 10; 414 | assign(m_true, 415 | add( 416 | add(M_true, 417 | multiply(5, 418 | stan::math::log10(rvalue(dL, "dL", index_multi(gal_id))))), 25), 419 | "assigning variable m_true"); 420 | if (emit_transformed_parameters__) { 421 | for (int sym1__ = 1; sym1__ <= Nt; ++sym1__) { 422 | vars__.emplace_back(M_true[(sym1__ - 1)]); 423 | } 424 | for (int sym1__ = 1; sym1__ <= Nt; ++sym1__) { 425 | vars__.emplace_back(m_true[(sym1__ - 1)]); 426 | } 427 | } 428 | if (logical_negation(emit_generated_quantities__)) { 429 | return ; 430 | } 431 | } catch (const std::exception& e) { 432 | stan::lang::rethrow_located(e, locations_array__[current_statement__]); 433 | // Next line prevents compiler griping about no return 434 | throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); 435 | } 436 | } // write_array_impl() 437 | 438 | template * = nullptr, 440 | stan::require_vector_like_vt* = nullptr> 441 | inline void transform_inits_impl(const stan::io::var_context& context__, 442 | VecI& params_i__, VecVar& vars__, 443 | std::ostream* pstream__ = nullptr) const { 444 | using local_scalar_t__ = double; 445 | vars__.clear(); 446 | vars__.reserve(num_params_r__); 447 | int current_statement__ = 0; 448 | 449 | try { 450 | int pos__; 451 | pos__ = std::numeric_limits::min(); 452 | 453 | pos__ = 1; 454 | double mu_alpha; 455 | mu_alpha = std::numeric_limits::quiet_NaN(); 456 | 457 | current_statement__ = 1; 458 | mu_alpha = context__.vals_r("mu_alpha")[(1 - 1)]; 459 | double tau_alpha; 460 | tau_alpha = std::numeric_limits::quiet_NaN(); 461 | 462 | current_statement__ = 2; 463 | tau_alpha = context__.vals_r("tau_alpha")[(1 - 1)]; 464 | double tau_alpha_free__; 465 | tau_alpha_free__ = std::numeric_limits::quiet_NaN(); 466 | 467 | current_statement__ = 2; 468 | tau_alpha_free__ = stan::math::lb_free(tau_alpha, 0); 469 | double mu_beta; 470 | mu_beta = std::numeric_limits::quiet_NaN(); 471 | 472 | current_statement__ = 3; 473 | mu_beta = context__.vals_r("mu_beta")[(1 - 1)]; 474 | double tau_beta; 475 | tau_beta = std::numeric_limits::quiet_NaN(); 476 | 477 | current_statement__ = 4; 478 | tau_beta = context__.vals_r("tau_beta")[(1 - 1)]; 479 | double tau_beta_free__; 480 | tau_beta_free__ = std::numeric_limits::quiet_NaN(); 481 | 482 | current_statement__ = 4; 483 | tau_beta_free__ = stan::math::lb_free(tau_beta, 0); 484 | Eigen::Matrix alpha; 485 | alpha = Eigen::Matrix(Ng); 486 | stan::math::fill(alpha, std::numeric_limits::quiet_NaN()); 487 | 488 | { 489 | std::vector alpha_flat__; 490 | current_statement__ = 5; 491 | alpha_flat__ = context__.vals_r("alpha"); 492 | current_statement__ = 5; 493 | pos__ = 1; 494 | current_statement__ = 5; 495 | for (int sym1__ = 1; sym1__ <= Ng; ++sym1__) { 496 | current_statement__ = 5; 497 | assign(alpha, alpha_flat__[(pos__ - 1)], 498 | "assigning variable alpha", index_uni(sym1__)); 499 | current_statement__ = 5; 500 | pos__ = (pos__ + 1); 501 | } 502 | } 503 | Eigen::Matrix beta; 504 | beta = Eigen::Matrix(Ng); 505 | stan::math::fill(beta, std::numeric_limits::quiet_NaN()); 506 | 507 | { 508 | std::vector beta_flat__; 509 | current_statement__ = 6; 510 | beta_flat__ = context__.vals_r("beta"); 511 | current_statement__ = 6; 512 | pos__ = 1; 513 | current_statement__ = 6; 514 | for (int sym1__ = 1; sym1__ <= Ng; ++sym1__) { 515 | current_statement__ = 6; 516 | assign(beta, beta_flat__[(pos__ - 1)], 517 | "assigning variable beta", index_uni(sym1__)); 518 | current_statement__ = 6; 519 | pos__ = (pos__ + 1); 520 | } 521 | } 522 | vars__.emplace_back(mu_alpha); 523 | vars__.emplace_back(tau_alpha_free__); 524 | vars__.emplace_back(mu_beta); 525 | vars__.emplace_back(tau_beta_free__); 526 | for (int sym1__ = 1; sym1__ <= Ng; ++sym1__) { 527 | vars__.emplace_back(alpha[(sym1__ - 1)]); 528 | } 529 | for (int sym1__ = 1; sym1__ <= Ng; ++sym1__) { 530 | vars__.emplace_back(beta[(sym1__ - 1)]); 531 | } 532 | } catch (const std::exception& e) { 533 | stan::lang::rethrow_located(e, locations_array__[current_statement__]); 534 | // Next line prevents compiler griping about no return 535 | throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); 536 | } 537 | } // transform_inits_impl() 538 | 539 | inline void get_param_names(std::vector& names__) const { 540 | 541 | names__ = std::vector{"mu_alpha", "tau_alpha", "mu_beta", 542 | "tau_beta", "alpha", "beta", "M_true", "m_true"}; 543 | 544 | } // get_param_names() 545 | 546 | inline void get_dims(std::vector>& dimss__) const { 547 | 548 | dimss__ = std::vector>{std::vector{}, 549 | std::vector{}, std::vector{}, std::vector{ 550 | }, std::vector{static_cast(Ng)}, 551 | std::vector{static_cast(Ng)}, 552 | std::vector{static_cast(Nt)}, 553 | std::vector{static_cast(Nt)}}; 554 | 555 | } // get_dims() 556 | 557 | inline void constrained_param_names( 558 | std::vector& param_names__, 559 | bool emit_transformed_parameters__ = true, 560 | bool emit_generated_quantities__ = true) const 561 | final { 562 | 563 | param_names__.emplace_back(std::string() + "mu_alpha"); 564 | param_names__.emplace_back(std::string() + "tau_alpha"); 565 | param_names__.emplace_back(std::string() + "mu_beta"); 566 | param_names__.emplace_back(std::string() + "tau_beta"); 567 | for (int sym1__ = 1; sym1__ <= Ng; ++sym1__) { 568 | { 569 | param_names__.emplace_back(std::string() + "alpha" + '.' + std::to_string(sym1__)); 570 | } 571 | } 572 | for (int sym1__ = 1; sym1__ <= Ng; ++sym1__) { 573 | { 574 | param_names__.emplace_back(std::string() + "beta" + '.' + std::to_string(sym1__)); 575 | } 576 | } 577 | if (emit_transformed_parameters__) { 578 | for (int sym1__ = 1; sym1__ <= Nt; ++sym1__) { 579 | { 580 | param_names__.emplace_back(std::string() + "M_true" + '.' + std::to_string(sym1__)); 581 | } 582 | } 583 | for (int sym1__ = 1; sym1__ <= Nt; ++sym1__) { 584 | { 585 | param_names__.emplace_back(std::string() + "m_true" + '.' + std::to_string(sym1__)); 586 | } 587 | } 588 | } 589 | 590 | if (emit_generated_quantities__) { 591 | 592 | } 593 | 594 | } // constrained_param_names() 595 | 596 | inline void unconstrained_param_names( 597 | std::vector& param_names__, 598 | bool emit_transformed_parameters__ = true, 599 | bool emit_generated_quantities__ = true) const 600 | final { 601 | 602 | param_names__.emplace_back(std::string() + "mu_alpha"); 603 | param_names__.emplace_back(std::string() + "tau_alpha"); 604 | param_names__.emplace_back(std::string() + "mu_beta"); 605 | param_names__.emplace_back(std::string() + "tau_beta"); 606 | for (int sym1__ = 1; sym1__ <= Ng; ++sym1__) { 607 | { 608 | param_names__.emplace_back(std::string() + "alpha" + '.' + std::to_string(sym1__)); 609 | } 610 | } 611 | for (int sym1__ = 1; sym1__ <= Ng; ++sym1__) { 612 | { 613 | param_names__.emplace_back(std::string() + "beta" + '.' + std::to_string(sym1__)); 614 | } 615 | } 616 | if (emit_transformed_parameters__) { 617 | for (int sym1__ = 1; sym1__ <= Nt; ++sym1__) { 618 | { 619 | param_names__.emplace_back(std::string() + "M_true" + '.' + std::to_string(sym1__)); 620 | } 621 | } 622 | for (int sym1__ = 1; sym1__ <= Nt; ++sym1__) { 623 | { 624 | param_names__.emplace_back(std::string() + "m_true" + '.' + std::to_string(sym1__)); 625 | } 626 | } 627 | } 628 | 629 | if (emit_generated_quantities__) { 630 | 631 | } 632 | 633 | } // unconstrained_param_names() 634 | 635 | inline std::string get_constrained_sizedtypes() const { 636 | 637 | return std::string("[{\"name\":\"mu_alpha\",\"type\":{\"name\":\"real\"},\"block\":\"parameters\"},{\"name\":\"tau_alpha\",\"type\":{\"name\":\"real\"},\"block\":\"parameters\"},{\"name\":\"mu_beta\",\"type\":{\"name\":\"real\"},\"block\":\"parameters\"},{\"name\":\"tau_beta\",\"type\":{\"name\":\"real\"},\"block\":\"parameters\"},{\"name\":\"alpha\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(Ng) + "},\"block\":\"parameters\"},{\"name\":\"beta\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(Ng) + "},\"block\":\"parameters\"},{\"name\":\"M_true\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(Nt) + "},\"block\":\"transformed_parameters\"},{\"name\":\"m_true\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(Nt) + "},\"block\":\"transformed_parameters\"}]"); 638 | 639 | } // get_constrained_sizedtypes() 640 | 641 | inline std::string get_unconstrained_sizedtypes() const { 642 | 643 | return std::string("[{\"name\":\"mu_alpha\",\"type\":{\"name\":\"real\"},\"block\":\"parameters\"},{\"name\":\"tau_alpha\",\"type\":{\"name\":\"real\"},\"block\":\"parameters\"},{\"name\":\"mu_beta\",\"type\":{\"name\":\"real\"},\"block\":\"parameters\"},{\"name\":\"tau_beta\",\"type\":{\"name\":\"real\"},\"block\":\"parameters\"},{\"name\":\"alpha\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(Ng) + "},\"block\":\"parameters\"},{\"name\":\"beta\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(Ng) + "},\"block\":\"parameters\"},{\"name\":\"M_true\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(Nt) + "},\"block\":\"transformed_parameters\"},{\"name\":\"m_true\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(Nt) + "},\"block\":\"transformed_parameters\"}]"); 644 | 645 | } // get_unconstrained_sizedtypes() 646 | 647 | 648 | // Begin method overload boilerplate 649 | template 650 | inline void write_array(RNG& base_rng, 651 | Eigen::Matrix& params_r, 652 | Eigen::Matrix& vars, 653 | const bool emit_transformed_parameters = true, 654 | const bool emit_generated_quantities = true, 655 | std::ostream* pstream = nullptr) const { 656 | std::vector vars_vec; 657 | vars_vec.reserve(vars.size()); 658 | std::vector params_i; 659 | write_array_impl(base_rng, params_r, params_i, vars_vec, 660 | emit_transformed_parameters, emit_generated_quantities, pstream); 661 | vars = Eigen::Map>( 662 | vars_vec.data(), vars_vec.size()); 663 | } 664 | 665 | template 666 | inline void write_array(RNG& base_rng, std::vector& params_r, 667 | std::vector& params_i, 668 | std::vector& vars, 669 | bool emit_transformed_parameters = true, 670 | bool emit_generated_quantities = true, 671 | std::ostream* pstream = nullptr) const { 672 | write_array_impl(base_rng, params_r, params_i, vars, 673 | emit_transformed_parameters, emit_generated_quantities, pstream); 674 | } 675 | 676 | template 677 | inline T_ log_prob(Eigen::Matrix& params_r, 678 | std::ostream* pstream = nullptr) const { 679 | Eigen::Matrix params_i; 680 | return log_prob_impl(params_r, params_i, pstream); 681 | } 682 | 683 | template 684 | inline T__ log_prob(std::vector& params_r, 685 | std::vector& params_i, 686 | std::ostream* pstream = nullptr) const { 687 | return log_prob_impl(params_r, params_i, pstream); 688 | } 689 | 690 | 691 | inline void transform_inits(const stan::io::var_context& context, 692 | Eigen::Matrix& params_r, 693 | std::ostream* pstream = nullptr) const final { 694 | std::vector params_r_vec; 695 | params_r_vec.reserve(params_r.size()); 696 | std::vector params_i; 697 | transform_inits_impl(context, params_i, params_r_vec, pstream); 698 | params_r = Eigen::Map>( 699 | params_r_vec.data(), params_r_vec.size()); 700 | } 701 | inline void transform_inits(const stan::io::var_context& context, 702 | std::vector& params_i, 703 | std::vector& vars, 704 | std::ostream* pstream = nullptr) const final { 705 | transform_inits_impl(context, params_i, vars, pstream); 706 | } 707 | 708 | }; 709 | } 710 | using stan_model = cepheid_v3_model_namespace::cepheid_v3_model; 711 | 712 | #ifndef USING_R 713 | 714 | // Boilerplate 715 | stan::model::model_base& new_model( 716 | stan::io::var_context& data_context, 717 | unsigned int seed, 718 | std::ostream* msg_stream) { 719 | stan_model* m = new stan_model(data_context, seed, msg_stream); 720 | return *m; 721 | } 722 | 723 | stan::math::profile_map& get_stan_profile_data() { 724 | return cepheid_v3_model_namespace::profiles__; 725 | } 726 | 727 | #endif 728 | 729 | 730 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | --------------------------------------------------------------------------------