{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>rt</th>\n",
       "      <th>choice</th>\n",
       "      <th>condition</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0.477</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>0.600</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>0.500</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>0.416</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>0.435</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "      rt  choice  condition\n",
       "0  0.477     1.0        1.0\n",
       "1  0.600     1.0        1.0\n",
       "2  0.500     0.0        1.0\n",
       "3  0.416     1.0        1.0\n",
       "4  0.435     1.0        1.0"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# DATA\n",
    "\n",
    "import pandas as pd\n",
    "import stan\n",
    "import numpy as np\n",
    "import matplotlib.pyplot as plt\n",
    "import seaborn as sns\n",
    "import arviz as az\n",
    "\n",
    "# stan problems\n",
    "import nest_asyncio\n",
    "nest_asyncio.apply()\n",
    "\n",
    "data = pd.read_csv(\"sample_response_times.csv\", sep=';')\n",
    "\n",
    "data.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "stan_code = \"\"\"\n",
    "data {\n",
    "    int<lower=1> N;\n",
    "    array[N] real<lower=0> y;\n",
    "    array[N] int<lower=1, upper=2> condition;\n",
    "    array[N] int<lower=0, upper=1> choice;\n",
    "}\n",
    "\n",
    "// EVERYTHING ABOVE 0!!!! EVERYTHING!!!!!!\n",
    "parameters {\n",
    "    real<lower=0> v_easy;         // Drift rate for easy condition\n",
    "    real<lower=0> v_hard;         // Drift rate for hard condition\n",
    "    real<lower=0> a;              // Boundary separation\n",
    "    real<lower=0, upper=1> beta;  // Starting point bias\n",
    "    real<lower=0, upper=min(y)> tau;  // Non-decision time with upper bound\n",
    "}\n",
    "\n",
    "model {\n",
    "    // Priors (updated)\n",
    "    v_easy ~ gamma(1, 2);\n",
    "    v_hard ~ gamma(1, 2);\n",
    "    a ~ gamma(2, 0.5);\n",
    "    beta ~ beta(2, 2);\n",
    "    tau ~ gamma(1, 10);\n",
    "\n",
    "    // Likelihood (unchanged)\n",
    "    for (n in 1:N) {\n",
    "        if (condition[n] == 1) {\n",
    "            if (choice[n] == 1) {\n",
    "                y[n] ~ wiener(a, tau, beta, v_easy);\n",
    "            } else {\n",
    "                y[n] ~ wiener(a, tau, 1 - beta, -v_easy);\n",
    "            }\n",
    "        }\n",
    "        if (condition[n] == 2) {\n",
    "            if (choice[n] == 1) {\n",
    "                y[n] ~ wiener(a, tau, beta, v_hard);\n",
    "            } else {\n",
    "                y[n] ~ wiener(a, tau, 1 - beta, -v_hard);\n",
    "            }\n",
    "        }\n",
    "    }\n",
    "}\n",
    "\"\"\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Building..."
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "In file included from /home/ion606/Desktop/Homework/COGMOD/HW3/COGMOD-HWI/HW3/.venv/lib/python3.12/site-packages/httpstan/include/tbb/tbb_profiling.h:123,\n",
      "                 from /home/ion606/Desktop/Homework/COGMOD/HW3/COGMOD-HWI/HW3/.venv/lib/python3.12/site-packages/httpstan/include/tbb/task.h:36,\n",
      "                 from /home/ion606/Desktop/Homework/COGMOD/HW3/COGMOD-HWI/HW3/.venv/lib/python3.12/site-packages/httpstan/include/tbb/task_arena.h:23,\n",
      "                 from /home/ion606/Desktop/Homework/COGMOD/HW3/COGMOD-HWI/HW3/.venv/lib/python3.12/site-packages/httpstan/include/stan/math/prim/core/init_threadpool_tbb.hpp:18,\n",
      "                 from /home/ion606/Desktop/Homework/COGMOD/HW3/COGMOD-HWI/HW3/.venv/lib/python3.12/site-packages/httpstan/include/stan/math/prim/core.hpp:4,\n",
      "                 from /home/ion606/Desktop/Homework/COGMOD/HW3/COGMOD-HWI/HW3/.venv/lib/python3.12/site-packages/httpstan/include/stan/math/rev/core/Eigen_NumTraits.hpp:5,\n",
      "                 from /home/ion606/Desktop/Homework/COGMOD/HW3/COGMOD-HWI/HW3/.venv/lib/python3.12/site-packages/httpstan/include/stan/math/rev/core/typedefs.hpp:7,\n",
      "                 from /home/ion606/Desktop/Homework/COGMOD/HW3/COGMOD-HWI/HW3/.venv/lib/python3.12/site-packages/httpstan/include/stan/math/rev/core/chainable_object.hpp:6,\n",
      "                 from /home/ion606/Desktop/Homework/COGMOD/HW3/COGMOD-HWI/HW3/.venv/lib/python3.12/site-packages/httpstan/include/stan/math/rev/core.hpp:10,\n",
      "                 from /home/ion606/Desktop/Homework/COGMOD/HW3/COGMOD-HWI/HW3/.venv/lib/python3.12/site-packages/httpstan/include/stan/math/rev.hpp:10,\n",
      "                 from /home/ion606/Desktop/Homework/COGMOD/HW3/COGMOD-HWI/HW3/.venv/lib/python3.12/site-packages/httpstan/include/stan/math.hpp:19,\n",
      "                 from /home/ion606/Desktop/Homework/COGMOD/HW3/COGMOD-HWI/HW3/.venv/lib/python3.12/site-packages/httpstan/include/stan/model/model_header.hpp:4,\n",
      "                 from /home/ion606/.cache/httpstan/4.13.0/models/4otogou3/model_4otogou3.cpp:2:\n",
      "/home/ion606/Desktop/Homework/COGMOD/HW3/COGMOD-HWI/HW3/.venv/lib/python3.12/site-packages/httpstan/include/tbb/atomic.h:422:24: warning: template-id not allowed for constructor in C++20 [-Wtemplate-id-cdtor]\n",
      "  422 |     constexpr atomic<T>(const atomic<T>& rhs): internal::atomic_impl<T>(rhs) {}\n",
      "      |                        ^\n",
      "/home/ion606/Desktop/Homework/COGMOD/HW3/COGMOD-HWI/HW3/.venv/lib/python3.12/site-packages/httpstan/include/tbb/atomic.h:422:24: note: remove the ‘< >’\n",
      "/home/ion606/Desktop/Homework/COGMOD/HW3/COGMOD-HWI/HW3/.venv/lib/python3.12/site-packages/httpstan/include/tbb/atomic.h:437:32: warning: template-id not allowed for constructor in C++20 [-Wtemplate-id-cdtor]\n",
      "  437 |             constexpr atomic<T>(const atomic<T>& rhs):                                              \\\n",
      "      |                                ^\n",
      "/home/ion606/Desktop/Homework/COGMOD/HW3/COGMOD-HWI/HW3/.venv/lib/python3.12/site-packages/httpstan/include/tbb/atomic.h:454:1: note: in expansion of macro ‘__TBB_DECL_ATOMIC’\n",
      "  454 | __TBB_DECL_ATOMIC(__TBB_LONG_LONG)\n",
      "      | ^~~~~~~~~~~~~~~~~\n",
      "/home/ion606/Desktop/Homework/COGMOD/HW3/COGMOD-HWI/HW3/.venv/lib/python3.12/site-packages/httpstan/include/tbb/atomic.h:437:32: note: remove the ‘< >’\n",
      "  437 |             constexpr atomic<T>(const atomic<T>& rhs):                                              \\\n",
      "      |                                ^\n",
      "/home/ion606/Desktop/Homework/COGMOD/HW3/COGMOD-HWI/HW3/.venv/lib/python3.12/site-packages/httpstan/include/tbb/atomic.h:454:1: note: in expansion of macro ‘__TBB_DECL_ATOMIC’\n",
      "  454 | __TBB_DECL_ATOMIC(__TBB_LONG_LONG)\n",
      "      | ^~~~~~~~~~~~~~~~~\n",
      "/home/ion606/Desktop/Homework/COGMOD/HW3/COGMOD-HWI/HW3/.venv/lib/python3.12/site-packages/httpstan/include/tbb/atomic.h:437:32: warning: template-id not allowed for constructor in C++20 [-Wtemplate-id-cdtor]\n",
      "  437 |             constexpr atomic<T>(const atomic<T>& rhs):                                              \\\n",
      "      |                                ^\n",
      "/home/ion606/Desktop/Homework/COGMOD/HW3/COGMOD-HWI/HW3/.venv/lib/python3.12/site-packages/httpstan/include/tbb/atomic.h:455:1: note: in expansion of macro ‘__TBB_DECL_ATOMIC’\n",
      "  455 | __TBB_DECL_ATOMIC(unsigned __TBB_LONG_LONG)\n",
      "      | ^~~~~~~~~~~~~~~~~\n",
      "/home/ion606/Desktop/Homework/COGMOD/HW3/COGMOD-HWI/HW3/.venv/lib/python3.12/site-packages/httpstan/include/tbb/atomic.h:437:32: note: remove the ‘< >’\n",
      "  437 |             constexpr atomic<T>(const atomic<T>& rhs):                                              \\\n",
      "      |                                ^\n",
      "/home/ion606/Desktop/Homework/COGMOD/HW3/COGMOD-HWI/HW3/.venv/lib/python3.12/site-packages/httpstan/include/tbb/atomic.h:455:1: note: in expansion of macro ‘__TBB_DECL_ATOMIC’\n",
      "  455 | __TBB_DECL_ATOMIC(unsigned __TBB_LONG_LONG)\n",
      "      | ^~~~~~~~~~~~~~~~~\n",
      "/home/ion606/Desktop/Homework/COGMOD/HW3/COGMOD-HWI/HW3/.venv/lib/python3.12/site-packages/httpstan/include/tbb/atomic.h:437:32: warning: template-id not allowed for constructor in C++20 [-Wtemplate-id-cdtor]\n",
      "  437 |             constexpr atomic<T>(const atomic<T>& rhs):                                              \\\n",
      "      |                                ^\n",
      "/home/ion606/Desktop/Homework/COGMOD/HW3/COGMOD-HWI/HW3/.venv/lib/python3.12/site-packages/httpstan/include/tbb/atomic.h:459:1: note: in expansion of macro ‘__TBB_DECL_ATOMIC’\n",
      "  459 | __TBB_DECL_ATOMIC(long)\n",
      "      | ^~~~~~~~~~~~~~~~~\n",
      "/home/ion606/Desktop/Homework/COGMOD/HW3/COGMOD-HWI/HW3/.venv/lib/python3.12/site-packages/httpstan/include/tbb/atomic.h:437:32: note: remove the ‘< >’\n",
      "  437 |             constexpr atomic<T>(const atomic<T>& rhs):                                              \\\n",
      "      |                                ^\n",
      "/home/ion606/Desktop/Homework/COGMOD/HW3/COGMOD-HWI/HW3/.venv/lib/python3.12/site-packages/httpstan/include/tbb/atomic.h:459:1: note: in expansion of macro ‘__TBB_DECL_ATOMIC’\n",
      "  459 | __TBB_DECL_ATOMIC(long)\n",
      "      | ^~~~~~~~~~~~~~~~~\n",
      "/home/ion606/Desktop/Homework/COGMOD/HW3/COGMOD-HWI/HW3/.venv/lib/python3.12/site-packages/httpstan/include/tbb/atomic.h:437:32: warning: template-id not allowed for constructor in C++20 [-Wtemplate-id-cdtor]\n",
      "  437 |             constexpr atomic<T>(const atomic<T>& rhs):                                              \\\n",
      "      |                                ^\n",
      "/home/ion606/Desktop/Homework/COGMOD/HW3/COGMOD-HWI/HW3/.venv/lib/python3.12/site-packages/httpstan/include/tbb/atomic.h:460:1: note: in expansion of macro ‘__TBB_DECL_ATOMIC’\n",
      "  460 | __TBB_DECL_ATOMIC(unsigned long)\n",
      "      | ^~~~~~~~~~~~~~~~~\n",
      "/home/ion606/Desktop/Homework/COGMOD/HW3/COGMOD-HWI/HW3/.venv/lib/python3.12/site-packages/httpstan/include/tbb/atomic.h:437:32: note: remove the ‘< >’\n",
      "  437 |             constexpr atomic<T>(const atomic<T>& rhs):                                              \\\n",
      "      |                                ^\n",
      "/home/ion606/Desktop/Homework/COGMOD/HW3/COGMOD-HWI/HW3/.venv/lib/python3.12/site-packages/httpstan/include/tbb/atomic.h:460:1: note: in expansion of macro ‘__TBB_DECL_ATOMIC’\n",
      "  460 | __TBB_DECL_ATOMIC(unsigned long)\n",
      "      | ^~~~~~~~~~~~~~~~~\n",
      "/home/ion606/Desktop/Homework/COGMOD/HW3/COGMOD-HWI/HW3/.venv/lib/python3.12/site-packages/httpstan/include/tbb/atomic.h:437:32: warning: template-id not allowed for constructor in C++20 [-Wtemplate-id-cdtor]\n",
      "  437 |             constexpr atomic<T>(const atomic<T>& rhs):                                              \\\n",
      "      |                                ^\n",
      "/home/ion606/Desktop/Homework/COGMOD/HW3/COGMOD-HWI/HW3/.venv/lib/python3.12/site-packages/httpstan/include/tbb/atomic.h:491:1: note: in expansion of macro ‘__TBB_DECL_ATOMIC’\n",
      "  491 | __TBB_DECL_ATOMIC(unsigned)\n",
      "      | ^~~~~~~~~~~~~~~~~\n",
      "/home/ion606/Desktop/Homework/COGMOD/HW3/COGMOD-HWI/HW3/.venv/lib/python3.12/site-packages/httpstan/include/tbb/atomic.h:437:32: note: remove the ‘< >’\n",
      "  437 |             constexpr atomic<T>(const atomic<T>& rhs):                                              \\\n",
      "      |                                ^\n",
      "/home/ion606/Desktop/Homework/COGMOD/HW3/COGMOD-HWI/HW3/.venv/lib/python3.12/site-packages/httpstan/include/tbb/atomic.h:491:1: note: in expansion of macro ‘__TBB_DECL_ATOMIC’\n",
      "  491 | __TBB_DECL_ATOMIC(unsigned)\n",
      "      | ^~~~~~~~~~~~~~~~~\n",
      "/home/ion606/Desktop/Homework/COGMOD/HW3/COGMOD-HWI/HW3/.venv/lib/python3.12/site-packages/httpstan/include/tbb/atomic.h:437:32: warning: template-id not allowed for constructor in C++20 [-Wtemplate-id-cdtor]\n",
      "  437 |             constexpr atomic<T>(const atomic<T>& rhs):                                              \\\n",
      "      |                                ^\n",
      "/home/ion606/Desktop/Homework/COGMOD/HW3/COGMOD-HWI/HW3/.venv/lib/python3.12/site-packages/httpstan/include/tbb/atomic.h:492:1: note: in expansion of macro ‘__TBB_DECL_ATOMIC’\n",
      "  492 | __TBB_DECL_ATOMIC(int)\n",
      "      | ^~~~~~~~~~~~~~~~~\n",
      "/home/ion606/Desktop/Homework/COGMOD/HW3/COGMOD-HWI/HW3/.venv/lib/python3.12/site-packages/httpstan/include/tbb/atomic.h:437:32: note: remove the ‘< >’\n",
      "  437 |             constexpr atomic<T>(const atomic<T>& rhs):                                              \\\n",
      "      |                                ^\n",
      "/home/ion606/Desktop/Homework/COGMOD/HW3/COGMOD-HWI/HW3/.venv/lib/python3.12/site-packages/httpstan/include/tbb/atomic.h:492:1: note: in expansion of macro ‘__TBB_DECL_ATOMIC’\n",
      "  492 | __TBB_DECL_ATOMIC(int)\n",
      "      | ^~~~~~~~~~~~~~~~~\n",
      "/home/ion606/Desktop/Homework/COGMOD/HW3/COGMOD-HWI/HW3/.venv/lib/python3.12/site-packages/httpstan/include/tbb/atomic.h:437:32: warning: template-id not allowed for constructor in C++20 [-Wtemplate-id-cdtor]\n",
      "  437 |             constexpr atomic<T>(const atomic<T>& rhs):                                              \\\n",
      "      |                                ^\n",
      "/home/ion606/Desktop/Homework/COGMOD/HW3/COGMOD-HWI/HW3/.venv/lib/python3.12/site-packages/httpstan/include/tbb/atomic.h:495:1: note: in expansion of macro ‘__TBB_DECL_ATOMIC’\n",
      "  495 | __TBB_DECL_ATOMIC(unsigned short)\n",
      "      | ^~~~~~~~~~~~~~~~~\n",
      "/home/ion606/Desktop/Homework/COGMOD/HW3/COGMOD-HWI/HW3/.venv/lib/python3.12/site-packages/httpstan/include/tbb/atomic.h:437:32: note: remove the ‘< >’\n",
      "  437 |             constexpr atomic<T>(const atomic<T>& rhs):                                              \\\n",
      "      |                                ^\n",
      "/home/ion606/Desktop/Homework/COGMOD/HW3/COGMOD-HWI/HW3/.venv/lib/python3.12/site-packages/httpstan/include/tbb/atomic.h:495:1: note: in expansion of macro ‘__TBB_DECL_ATOMIC’\n",
      "  495 | __TBB_DECL_ATOMIC(unsigned short)\n",
      "      | ^~~~~~~~~~~~~~~~~\n",
      "/home/ion606/Desktop/Homework/COGMOD/HW3/COGMOD-HWI/HW3/.venv/lib/python3.12/site-packages/httpstan/include/tbb/atomic.h:437:32: warning: template-id not allowed for constructor in C++20 [-Wtemplate-id-cdtor]\n",
      "  437 |             constexpr atomic<T>(const atomic<T>& rhs):                                              \\\n",
      "      |                                ^\n",
      "/home/ion606/Desktop/Homework/COGMOD/HW3/COGMOD-HWI/HW3/.venv/lib/python3.12/site-packages/httpstan/include/tbb/atomic.h:496:1: note: in expansion of macro ‘__TBB_DECL_ATOMIC’\n",
      "  496 | __TBB_DECL_ATOMIC(short)\n",
      "      | ^~~~~~~~~~~~~~~~~\n",
      "/home/ion606/Desktop/Homework/COGMOD/HW3/COGMOD-HWI/HW3/.venv/lib/python3.12/site-packages/httpstan/include/tbb/atomic.h:437:32: note: remove the ‘< >’\n",
      "  437 |             constexpr atomic<T>(const atomic<T>& rhs):                                              \\\n",
      "      |                                ^\n",
      "/home/ion606/Desktop/Homework/COGMOD/HW3/COGMOD-HWI/HW3/.venv/lib/python3.12/site-packages/httpstan/include/tbb/atomic.h:496:1: note: in expansion of macro ‘__TBB_DECL_ATOMIC’\n",
      "  496 | __TBB_DECL_ATOMIC(short)\n",
      "      | ^~~~~~~~~~~~~~~~~\n",
      "/home/ion606/Desktop/Homework/COGMOD/HW3/COGMOD-HWI/HW3/.venv/lib/python3.12/site-packages/httpstan/include/tbb/atomic.h:437:32: warning: template-id not allowed for constructor in C++20 [-Wtemplate-id-cdtor]\n",
      "  437 |             constexpr atomic<T>(const atomic<T>& rhs):                                              \\\n",
      "      |                                ^\n",
      "/home/ion606/Desktop/Homework/COGMOD/HW3/COGMOD-HWI/HW3/.venv/lib/python3.12/site-packages/httpstan/include/tbb/atomic.h:497:1: note: in expansion of macro ‘__TBB_DECL_ATOMIC’\n",
      "  497 | __TBB_DECL_ATOMIC(char)\n",
      "      | ^~~~~~~~~~~~~~~~~\n",
      "/home/ion606/Desktop/Homework/COGMOD/HW3/COGMOD-HWI/HW3/.venv/lib/python3.12/site-packages/httpstan/include/tbb/atomic.h:437:32: note: remove the ‘< >’\n",
      "  437 |             constexpr atomic<T>(const atomic<T>& rhs):                                              \\\n",
      "      |                                ^\n",
      "/home/ion606/Desktop/Homework/COGMOD/HW3/COGMOD-HWI/HW3/.venv/lib/python3.12/site-packages/httpstan/include/tbb/atomic.h:497:1: note: in expansion of macro ‘__TBB_DECL_ATOMIC’\n",
      "  497 | __TBB_DECL_ATOMIC(char)\n",
      "      | ^~~~~~~~~~~~~~~~~\n",
      "/home/ion606/Desktop/Homework/COGMOD/HW3/COGMOD-HWI/HW3/.venv/lib/python3.12/site-packages/httpstan/include/tbb/atomic.h:437:32: warning: template-id not allowed for constructor in C++20 [-Wtemplate-id-cdtor]\n",
      "  437 |             constexpr atomic<T>(const atomic<T>& rhs):                                              \\\n",
      "      |                                ^\n",
      "/home/ion606/Desktop/Homework/COGMOD/HW3/COGMOD-HWI/HW3/.venv/lib/python3.12/site-packages/httpstan/include/tbb/atomic.h:498:1: note: in expansion of macro ‘__TBB_DECL_ATOMIC’\n",
      "  498 | __TBB_DECL_ATOMIC(signed char)\n",
      "      | ^~~~~~~~~~~~~~~~~\n",
      "/home/ion606/Desktop/Homework/COGMOD/HW3/COGMOD-HWI/HW3/.venv/lib/python3.12/site-packages/httpstan/include/tbb/atomic.h:437:32: note: remove the ‘< >’\n",
      "  437 |             constexpr atomic<T>(const atomic<T>& rhs):                                              \\\n",
      "      |                                ^\n",
      "/home/ion606/Desktop/Homework/COGMOD/HW3/COGMOD-HWI/HW3/.venv/lib/python3.12/site-packages/httpstan/include/tbb/atomic.h:498:1: note: in expansion of macro ‘__TBB_DECL_ATOMIC’\n",
      "  498 | __TBB_DECL_ATOMIC(signed char)\n",
      "      | ^~~~~~~~~~~~~~~~~\n",
      "/home/ion606/Desktop/Homework/COGMOD/HW3/COGMOD-HWI/HW3/.venv/lib/python3.12/site-packages/httpstan/include/tbb/atomic.h:437:32: warning: template-id not allowed for constructor in C++20 [-Wtemplate-id-cdtor]\n",
      "  437 |             constexpr atomic<T>(const atomic<T>& rhs):                                              \\\n",
      "      |                                ^\n",
      "/home/ion606/Desktop/Homework/COGMOD/HW3/COGMOD-HWI/HW3/.venv/lib/python3.12/site-packages/httpstan/include/tbb/atomic.h:499:1: note: in expansion of macro ‘__TBB_DECL_ATOMIC’\n",
      "  499 | __TBB_DECL_ATOMIC(unsigned char)\n",
      "      | ^~~~~~~~~~~~~~~~~\n",
      "/home/ion606/Desktop/Homework/COGMOD/HW3/COGMOD-HWI/HW3/.venv/lib/python3.12/site-packages/httpstan/include/tbb/atomic.h:437:32: note: remove the ‘< >’\n",
      "  437 |             constexpr atomic<T>(const atomic<T>& rhs):                                              \\\n",
      "      |                                ^\n",
      "/home/ion606/Desktop/Homework/COGMOD/HW3/COGMOD-HWI/HW3/.venv/lib/python3.12/site-packages/httpstan/include/tbb/atomic.h:499:1: note: in expansion of macro ‘__TBB_DECL_ATOMIC’\n",
      "  499 | __TBB_DECL_ATOMIC(unsigned char)\n",
      "      | ^~~~~~~~~~~~~~~~~\n",
      "/home/ion606/Desktop/Homework/COGMOD/HW3/COGMOD-HWI/HW3/.venv/lib/python3.12/site-packages/httpstan/include/tbb/atomic.h:437:32: warning: template-id not allowed for constructor in C++20 [-Wtemplate-id-cdtor]\n",
      "  437 |             constexpr atomic<T>(const atomic<T>& rhs):                                              \\\n",
      "      |                                ^\n",
      "/home/ion606/Desktop/Homework/COGMOD/HW3/COGMOD-HWI/HW3/.venv/lib/python3.12/site-packages/httpstan/include/tbb/atomic.h:502:1: note: in expansion of macro ‘__TBB_DECL_ATOMIC’\n",
      "  502 | __TBB_DECL_ATOMIC(wchar_t)\n",
      "      | ^~~~~~~~~~~~~~~~~\n",
      "/home/ion606/Desktop/Homework/COGMOD/HW3/COGMOD-HWI/HW3/.venv/lib/python3.12/site-packages/httpstan/include/tbb/atomic.h:437:32: note: remove the ‘< >’\n",
      "  437 |             constexpr atomic<T>(const atomic<T>& rhs):                                              \\\n",
      "      |                                ^\n",
      "/home/ion606/Desktop/Homework/COGMOD/HW3/COGMOD-HWI/HW3/.venv/lib/python3.12/site-packages/httpstan/include/tbb/atomic.h:502:1: note: in expansion of macro ‘__TBB_DECL_ATOMIC’\n",
      "  502 | __TBB_DECL_ATOMIC(wchar_t)\n",
      "      | ^~~~~~~~~~~~~~~~~\n",
      "In file included from /home/ion606/Desktop/Homework/COGMOD/HW3/COGMOD-HWI/HW3/.venv/lib/python3.12/site-packages/httpstan/include/stan/math/prim/prob/normal_ccdf_log.hpp:5,\n",
      "                 from /home/ion606/Desktop/Homework/COGMOD/HW3/COGMOD-HWI/HW3/.venv/lib/python3.12/site-packages/httpstan/include/stan/math/prim/prob.hpp:243,\n",
      "                 from /home/ion606/Desktop/Homework/COGMOD/HW3/COGMOD-HWI/HW3/.venv/lib/python3.12/site-packages/httpstan/include/stan/math/prim.hpp:16,\n",
      "                 from /home/ion606/Desktop/Homework/COGMOD/HW3/COGMOD-HWI/HW3/.venv/lib/python3.12/site-packages/httpstan/include/stan/math/rev.hpp:16:\n",
      "/home/ion606/Desktop/Homework/COGMOD/HW3/COGMOD-HWI/HW3/.venv/lib/python3.12/site-packages/httpstan/include/stan/math/prim/prob/normal_lccdf.hpp: In function ‘stan::return_type_t<T_x, T_sigma, T_l> stan::math::normal_lccdf(const T_y&, const T_loc&, const T_scale&)’:\n",
      "/home/ion606/Desktop/Homework/COGMOD/HW3/COGMOD-HWI/HW3/.venv/lib/python3.12/site-packages/httpstan/include/stan/math/prim/prob/normal_lccdf.hpp:68: note: ‘-Wmisleading-indentation’ is disabled from this point onwards, since column-tracking was disabled due to the size of the code/headers\n",
      "   68 |     } else if (scaled_diff > 8.25 * INV_SQRT_TWO) {\n",
      "/home/ion606/Desktop/Homework/COGMOD/HW3/COGMOD-HWI/HW3/.venv/lib/python3.12/site-packages/httpstan/include/stan/math/prim/prob/normal_lccdf.hpp:68: note: adding ‘-flarge-source-files’ will allow for more column-tracking support, at the expense of compilation time and memory\n",
      "In file included from /home/ion606/Desktop/Homework/COGMOD/HW3/COGMOD-HWI/HW3/.venv/lib/python3.12/site-packages/httpstan/include/stan/model/model_header.hpp:11:\n",
      "/home/ion606/Desktop/Homework/COGMOD/HW3/COGMOD-HWI/HW3/.venv/lib/python3.12/site-packages/httpstan/include/stan/model/model_base_crtp.hpp: At global scope:\n",
      "/home/ion606/Desktop/Homework/COGMOD/HW3/COGMOD-HWI/HW3/.venv/lib/python3.12/site-packages/httpstan/include/stan/model/model_base_crtp.hpp:159: warning: ‘stan::math::var stan::model::model_base_crtp<M>::log_prob(std::vector<stan::math::var_value<double>, std::allocator<stan::math::var_value<double> > >&, std::vector<int>&, std::ostream*) const [with M = model_4otogou3_namespace::model_4otogou3; stan::math::var = stan::math::var_value<double>; std::ostream = std::basic_ostream<char>]’ was hidden [-Woverloaded-virtual=]\n",
      "  159 |   inline math::var log_prob(std::vector<math::var>& theta,\n",
      "/home/ion606/.cache/httpstan/4.13.0/models/4otogou3/model_4otogou3.cpp:590: note:   by ‘model_4otogou3_namespace::model_4otogou3::log_prob’\n",
      "  590 |   log_prob(std::vector<T_>& params_r, std::vector<int>& params_i,\n",
      "/home/ion606/Desktop/Homework/COGMOD/HW3/COGMOD-HWI/HW3/.venv/lib/python3.12/site-packages/httpstan/include/stan/model/model_base_crtp.hpp:154: warning: ‘double stan::model::model_base_crtp<M>::log_prob(std::vector<double, std::allocator<double> >&, std::vector<int>&, std::ostream*) const [with M = model_4otogou3_namespace::model_4otogou3; std::ostream = std::basic_ostream<char>]’ was hidden [-Woverloaded-virtual=]\n",
      "  154 |   inline double log_prob(std::vector<double>& theta, std::vector<int>& theta_i,\n",
      "/home/ion606/.cache/httpstan/4.13.0/models/4otogou3/model_4otogou3.cpp:590: note:   by ‘model_4otogou3_namespace::model_4otogou3::log_prob’\n",
      "  590 |   log_prob(std::vector<T_>& params_r, std::vector<int>& params_i,\n",
      "/home/ion606/Desktop/Homework/COGMOD/HW3/COGMOD-HWI/HW3/.venv/lib/python3.12/site-packages/httpstan/include/stan/model/model_base_crtp.hpp:96: warning: ‘stan::math::var stan::model::model_base_crtp<M>::log_prob(Eigen::Matrix<stan::math::var_value<double>, -1, 1>&, std::ostream*) const [with M = model_4otogou3_namespace::model_4otogou3; stan::math::var = stan::math::var_value<double>; std::ostream = std::basic_ostream<char>]’ was hidden [-Woverloaded-virtual=]\n",
      "   96 |   inline math::var log_prob(Eigen::Matrix<math::var, -1, 1>& theta,\n",
      "/home/ion606/.cache/httpstan/4.13.0/models/4otogou3/model_4otogou3.cpp:590: note:   by ‘model_4otogou3_namespace::model_4otogou3::log_prob’\n",
      "  590 |   log_prob(std::vector<T_>& params_r, std::vector<int>& params_i,\n",
      "/home/ion606/Desktop/Homework/COGMOD/HW3/COGMOD-HWI/HW3/.venv/lib/python3.12/site-packages/httpstan/include/stan/model/model_base_crtp.hpp:91: warning: ‘double stan::model::model_base_crtp<M>::log_prob(Eigen::VectorXd&, std::ostream*) const [with M = model_4otogou3_namespace::model_4otogou3; Eigen::VectorXd = Eigen::Matrix<double, -1, 1>; std::ostream = std::basic_ostream<char>]’ was hidden [-Woverloaded-virtual=]\n",
      "   91 |   inline double log_prob(Eigen::VectorXd& theta,\n",
      "/home/ion606/.cache/httpstan/4.13.0/models/4otogou3/model_4otogou3.cpp:590: note:   by ‘model_4otogou3_namespace::model_4otogou3::log_prob’\n",
      "  590 |   log_prob(std::vector<T_>& params_r, std::vector<int>& params_i,\n",
      "In file included from /home/ion606/Desktop/Homework/COGMOD/HW3/COGMOD-HWI/HW3/.venv/lib/python3.12/site-packages/httpstan/include/tbb/concurrent_unordered_map.h:26,\n",
      "                 from /home/ion606/Desktop/Homework/COGMOD/HW3/COGMOD-HWI/HW3/.venv/lib/python3.12/site-packages/httpstan/include/stan/math/rev/core/profiling.hpp:10,\n",
      "                 from /home/ion606/Desktop/Homework/COGMOD/HW3/COGMOD-HWI/HW3/.venv/lib/python3.12/site-packages/httpstan/include/stan/math/rev/core.hpp:53:\n",
      "/home/ion606/Desktop/Homework/COGMOD/HW3/COGMOD-HWI/HW3/.venv/lib/python3.12/site-packages/httpstan/include/tbb/internal/_concurrent_unordered_impl.h: In instantiation of ‘void tbb::interface5::internal::concurrent_unordered_base<Traits>::internal_init() [with Traits = tbb::interface5::concurrent_unordered_map_traits<std::pair<std::basic_string<char>, std::thread::id>, stan::math::profile_info, tbb::interface5::internal::hash_compare<std::pair<std::basic_string<char>, std::thread::id>, stan::math::internal::hash_profile_key, stan::math::internal::equal_profile_key>, tbb::tbb_allocator<std::pair<const std::pair<std::basic_string<char>, std::thread::id>, stan::math::profile_info> >, false>]’:\n",
      "/home/ion606/Desktop/Homework/COGMOD/HW3/COGMOD-HWI/HW3/.venv/lib/python3.12/site-packages/httpstan/include/tbb/internal/_concurrent_unordered_impl.h:773:9:   required from ‘tbb::interface5::internal::concurrent_unordered_base<Traits>::concurrent_unordered_base(size_type, const hash_compare&, const allocator_type&) [with Traits = tbb::interface5::concurrent_unordered_map_traits<std::pair<std::basic_string<char>, std::thread::id>, stan::math::profile_info, tbb::interface5::internal::hash_compare<std::pair<std::basic_string<char>, std::thread::id>, stan::math::internal::hash_profile_key, stan::math::internal::equal_profile_key>, tbb::tbb_allocator<std::pair<const std::pair<std::basic_string<char>, std::thread::id>, stan::math::profile_info> >, false>; size_type = long unsigned int; hash_compare = tbb::interface5::internal::hash_compare<std::pair<std::basic_string<char>, std::thread::id>, stan::math::internal::hash_profile_key, stan::math::internal::equal_profile_key>; allocator_type = std::allocator_traits<tbb::tbb_allocator<std::pair<const std::pair<std::basic_string<char>, std::thread::id>, stan::math::profile_info> > >::rebind_alloc<std::pair<const std::pair<std::basic_string<char>, std::thread::id>, stan::math::profile_info> >]’\n",
      "  773 |         internal_init();\n",
      "      |         ^~~~~~~~~~~~~\n",
      "/home/ion606/Desktop/Homework/COGMOD/HW3/COGMOD-HWI/HW3/.venv/lib/python3.12/site-packages/httpstan/include/tbb/concurrent_unordered_map.h:112:68:   required from ‘tbb::interface5::concurrent_unordered_map<Key, T, Hasher, Key_equality, Allocator>::concurrent_unordered_map(size_type, const hasher&, const key_equal&, const allocator_type&) [with Key = std::pair<std::basic_string<char>, std::thread::id>; T = stan::math::profile_info; Hasher = stan::math::internal::hash_profile_key; Key_equality = stan::math::internal::equal_profile_key; Allocator = tbb::tbb_allocator<std::pair<const std::pair<std::basic_string<char>, std::thread::id>, stan::math::profile_info> >; size_type = long unsigned int; hasher = stan::math::internal::hash_profile_key; key_equal = stan::math::internal::equal_profile_key; allocator_type = std::allocator_traits<tbb::tbb_allocator<std::pair<const std::pair<std::basic_string<char>, std::thread::id>, stan::math::profile_info> > >::rebind_alloc<std::pair<const std::pair<std::basic_string<char>, std::thread::id>, stan::math::profile_info> >]’\n",
      "  112 |         : base_type(n_of_buckets, key_compare(a_hasher, a_keyeq), a)\n",
      "      |                                                                    ^\n",
      "/home/ion606/.cache/httpstan/4.13.0/models/4otogou3/model_4otogou3.cpp:6:0:   required from here\n",
      "    6 | stan::math::profile_map profiles__;\n",
      "/home/ion606/Desktop/Homework/COGMOD/HW3/COGMOD-HWI/HW3/.venv/lib/python3.12/site-packages/httpstan/include/tbb/internal/_concurrent_unordered_impl.h:1345:15: warning: ‘void* memset(void*, int, size_t)’ clearing an object of type ‘struct tbb::atomic<tbb::interface5::internal::flist_iterator<tbb::interface5::internal::split_ordered_list<std::pair<const std::pair<std::basic_string<char>, std::thread::id>, stan::math::profile_info>, tbb::tbb_allocator<std::pair<const std::pair<std::basic_string<char>, std::thread::id>, stan::math::profile_info> > >, std::pair<const std::pair<std::basic_string<char>, std::thread::id>, stan::math::profile_info> >*>’ with no trivial copy-assignment; use assignment or value-initialization instead [-Wclass-memaccess]\n",
      " 1345 |         memset(my_buckets, 0, sizeof(my_buckets));\n",
      "      |         ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n",
      "/home/ion606/Desktop/Homework/COGMOD/HW3/COGMOD-HWI/HW3/.venv/lib/python3.12/site-packages/httpstan/include/tbb/atomic.h:507:1: note: ‘struct tbb::atomic<tbb::interface5::internal::flist_iterator<tbb::interface5::internal::split_ordered_list<std::pair<const std::pair<std::basic_string<char>, std::thread::id>, stan::math::profile_info>, tbb::tbb_allocator<std::pair<const std::pair<std::basic_string<char>, std::thread::id>, stan::math::profile_info> > >, std::pair<const std::pair<std::basic_string<char>, std::thread::id>, stan::math::profile_info> >*>’ declared here\n",
      "  507 | atomic<T*>: internal::atomic_impl_with_arithmetic<T*,ptrdiff_t,T> {\n",
      "      | ^~~~~~~~~~\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\n",
      "Building: 30.6s, done.Sampling:   0%\n",
      "Sampling:   0% (1/12000)\n",
      "Sampling:   0% (2/12000)\n",
      "Sampling:   0% (3/12000)\n",
      "Sampling:   0% (4/12000)\n",
      "Sampling:   1% (103/12000)\n",
      "Sampling:   2% (202/12000)\n",
      "Sampling:   3% (301/12000)\n",
      "Sampling:   3% (401/12000)\n",
      "Sampling:   4% (500/12000)\n",
      "Sampling:   5% (600/12000)\n",
      "Sampling:   6% (700/12000)\n",
      "Sampling:   7% (800/12000)\n",
      "Sampling:   8% (900/12000)\n",
      "Sampling:   8% (1000/12000)\n",
      "Sampling:   9% (1100/12000)\n",
      "Sampling:  10% (1200/12000)\n",
      "Sampling:  11% (1300/12000)\n",
      "Sampling:  12% (1400/12000)\n",
      "Sampling:  12% (1500/12000)\n",
      "Sampling:  13% (1600/12000)\n",
      "Sampling:  14% (1700/12000)\n",
      "Sampling:  15% (1800/12000)\n",
      "Sampling:  16% (1900/12000)\n",
      "Sampling:  17% (2000/12000)\n",
      "Sampling:  18% (2100/12000)\n",
      "Sampling:  18% (2200/12000)\n",
      "Sampling:  19% (2300/12000)\n",
      "Sampling:  20% (2400/12000)\n",
      "Sampling:  21% (2500/12000)\n",
      "Sampling:  22% (2600/12000)\n",
      "Sampling:  22% (2700/12000)\n",
      "Sampling:  23% (2800/12000)\n",
      "Sampling:  24% (2900/12000)\n",
      "Sampling:  25% (3000/12000)\n",
      "Sampling:  28% (3300/12000)\n",
      "Sampling:  31% (3700/12000)\n",
      "Sampling:  35% (4200/12000)\n",
      "Sampling:  41% (4900/12000)\n",
      "Sampling:  56% (6700/12000)\n",
      "Sampling:  72% (8600/12000)\n",
      "Sampling:  86% (10300/12000)\n",
      "Sampling:  95% (11400/12000)\n",
      "Sampling:  98% (11800/12000)\n",
      "Sampling: 100% (12000/12000)\n",
      "Sampling: 100% (12000/12000), done.\n",
      "Messages received during sampling:\n",
      "  Gradient evaluation took 0.000763 seconds\n",
      "  1000 transitions using 10 leapfrog steps per transition would take 7.63 seconds.\n",
      "  Adjust your expectations accordingly!\n",
      "  Informational Message: The current Metropolis proposal is about to be rejected because of the following issue:\n",
      "  Exception: gamma_lpdf: Random variable is 0, but must be positive finite! (in '/tmp/httpstan_t0dh1xl0/model_4otogou3.stan', line 21, column 4 to column 25)\n",
      "  If this warning occurs sporadically, such as for highly constrained variable types like covariance matrices, then the sampler is fine,\n",
      "  but if this warning occurs often then your model may be either severely ill-conditioned or misspecified.\n",
      "  Informational Message: The current Metropolis proposal is about to be rejected because of the following issue:\n",
      "  Exception: gamma_lpdf: Random variable is 0, but must be positive finite! (in '/tmp/httpstan_t0dh1xl0/model_4otogou3.stan', line 21, column 4 to column 25)\n",
      "  If this warning occurs sporadically, such as for highly constrained variable types like covariance matrices, then the sampler is fine,\n",
      "  but if this warning occurs often then your model may be either severely ill-conditioned or misspecified.\n",
      "  Informational Message: The current Metropolis proposal is about to be rejected because of the following issue:\n",
      "  Exception: gamma_lpdf: Random variable is inf, but must be positive finite! (in '/tmp/httpstan_t0dh1xl0/model_4otogou3.stan', line 22, column 4 to column 22)\n",
      "  If this warning occurs sporadically, such as for highly constrained variable types like covariance matrices, then the sampler is fine,\n",
      "  but if this warning occurs often then your model may be either severely ill-conditioned or misspecified.\n",
      "  Informational Message: The current Metropolis proposal is about to be rejected because of the following issue:\n",
      "  Exception: gamma_lpdf: Random variable is inf, but must be positive finite! (in '/tmp/httpstan_t0dh1xl0/model_4otogou3.stan', line 22, column 4 to column 22)\n",
      "  If this warning occurs sporadically, such as for highly constrained variable types like covariance matrices, then the sampler is fine,\n",
      "  but if this warning occurs often then your model may be either severely ill-conditioned or misspecified.\n",
      "  Informational Message: The current Metropolis proposal is about to be rejected because of the following issue:\n",
      "  Exception: gamma_lpdf: Random variable is 0, but must be positive finite! (in '/tmp/httpstan_t0dh1xl0/model_4otogou3.stan', line 20, column 4 to column 25)\n",
      "  If this warning occurs sporadically, such as for highly constrained variable types like covariance matrices, then the sampler is fine,\n",
      "  but if this warning occurs often then your model may be either severely ill-conditioned or misspecified.\n",
      "  Informational Message: The current Metropolis proposal is about to be rejected because of the following issue:\n",
      "  Exception: gamma_lpdf: Random variable is 0, but must be positive finite! (in '/tmp/httpstan_t0dh1xl0/model_4otogou3.stan', line 20, column 4 to column 25)\n",
      "  If this warning occurs sporadically, such as for highly constrained variable types like covariance matrices, then the sampler is fine,\n",
      "  but if this warning occurs often then your model may be either severely ill-conditioned or misspecified.\n",
      "  Gradient evaluation took 0.000896 seconds\n",
      "  1000 transitions using 10 leapfrog steps per transition would take 8.96 seconds.\n",
      "  Adjust your expectations accordingly!\n",
      "  Informational Message: The current Metropolis proposal is about to be rejected because of the following issue:\n",
      "  Exception: gamma_lpdf: Random variable is 0, but must be positive finite! (in '/tmp/httpstan_t0dh1xl0/model_4otogou3.stan', line 22, column 4 to column 22)\n",
      "  If this warning occurs sporadically, such as for highly constrained variable types like covariance matrices, then the sampler is fine,\n",
      "  but if this warning occurs often then your model may be either severely ill-conditioned or misspecified.\n",
      "  Informational Message: The current Metropolis proposal is about to be rejected because of the following issue:\n",
      "  Exception: gamma_lpdf: Random variable is 0, but must be positive finite! (in '/tmp/httpstan_t0dh1xl0/model_4otogou3.stan', line 22, column 4 to column 22)\n",
      "  If this warning occurs sporadically, such as for highly constrained variable types like covariance matrices, then the sampler is fine,\n",
      "  but if this warning occurs often then your model may be either severely ill-conditioned or misspecified.\n",
      "  Informational Message: The current Metropolis proposal is about to be rejected because of the following issue:\n",
      "  Exception: gamma_lpdf: Random variable is 0, but must be positive finite! (in '/tmp/httpstan_t0dh1xl0/model_4otogou3.stan', line 21, column 4 to column 25)\n",
      "  If this warning occurs sporadically, such as for highly constrained variable types like covariance matrices, then the sampler is fine,\n",
      "  but if this warning occurs often then your model may be either severely ill-conditioned or misspecified.\n",
      "  Informational Message: The current Metropolis proposal is about to be rejected because of the following issue:\n",
      "  Exception: gamma_lpdf: Random variable is inf, but must be positive finite! (in '/tmp/httpstan_t0dh1xl0/model_4otogou3.stan', line 22, column 4 to column 22)\n",
      "  If this warning occurs sporadically, such as for highly constrained variable types like covariance matrices, then the sampler is fine,\n",
      "  but if this warning occurs often then your model may be either severely ill-conditioned or misspecified.\n",
      "  Gradient evaluation took 0.001289 seconds\n",
      "  1000 transitions using 10 leapfrog steps per transition would take 12.89 seconds.\n",
      "  Adjust your expectations accordingly!\n",
      "  Informational Message: The current Metropolis proposal is about to be rejected because of the following issue:\n",
      "  Exception: gamma_lpdf: Random variable is inf, but must be positive finite! (in '/tmp/httpstan_t0dh1xl0/model_4otogou3.stan', line 22, column 4 to column 22)\n",
      "  If this warning occurs sporadically, such as for highly constrained variable types like covariance matrices, then the sampler is fine,\n",
      "  but if this warning occurs often then your model may be either severely ill-conditioned or misspecified.\n",
      "  Informational Message: The current Metropolis proposal is about to be rejected because of the following issue:\n",
      "  Exception: gamma_lpdf: Random variable is inf, but must be positive finite! (in '/tmp/httpstan_t0dh1xl0/model_4otogou3.stan', line 22, column 4 to column 22)\n",
      "  If this warning occurs sporadically, such as for highly constrained variable types like covariance matrices, then the sampler is fine,\n",
      "  but if this warning occurs often then your model may be either severely ill-conditioned or misspecified.\n",
      "  Informational Message: The current Metropolis proposal is about to be rejected because of the following issue:\n",
      "  Exception: wiener_lpdf: Random variable  = 0.411, but must be greater than nondecision time = 0.411 (in '/tmp/httpstan_t0dh1xl0/model_4otogou3.stan', line 30, column 16 to column 52)\n",
      "  If this warning occurs sporadically, such as for highly constrained variable types like covariance matrices, then the sampler is fine,\n",
      "  but if this warning occurs often then your model may be either severely ill-conditioned or misspecified.\n",
      "  Informational Message: The current Metropolis proposal is about to be rejected because of the following issue:\n",
      "  Exception: gamma_lpdf: Random variable is inf, but must be positive finite! (in '/tmp/httpstan_t0dh1xl0/model_4otogou3.stan', line 20, column 4 to column 25)\n",
      "  If this warning occurs sporadically, such as for highly constrained variable types like covariance matrices, then the sampler is fine,\n",
      "  but if this warning occurs often then your model may be either severely ill-conditioned or misspecified.\n",
      "  Informational Message: The current Metropolis proposal is about to be rejected because of the following issue:\n",
      "  Exception: gamma_lpdf: Random variable is 0, but must be positive finite! (in '/tmp/httpstan_t0dh1xl0/model_4otogou3.stan', line 22, column 4 to column 22)\n",
      "  If this warning occurs sporadically, such as for highly constrained variable types like covariance matrices, then the sampler is fine,\n",
      "  but if this warning occurs often then your model may be either severely ill-conditioned or misspecified.\n",
      "  Gradient evaluation took 0.002967 seconds\n",
      "  1000 transitions using 10 leapfrog steps per transition would take 29.67 seconds.\n",
      "  Adjust your expectations accordingly!\n",
      "  Informational Message: The current Metropolis proposal is about to be rejected because of the following issue:\n",
      "  Exception: gamma_lpdf: Random variable is inf, but must be positive finite! (in '/tmp/httpstan_t0dh1xl0/model_4otogou3.stan', line 22, column 4 to column 22)\n",
      "  If this warning occurs sporadically, such as for highly constrained variable types like covariance matrices, then the sampler is fine,\n",
      "  but if this warning occurs often then your model may be either severely ill-conditioned or misspecified.\n",
      "  Informational Message: The current Metropolis proposal is about to be rejected because of the following issue:\n",
      "  Exception: gamma_lpdf: Random variable is inf, but must be positive finite! (in '/tmp/httpstan_t0dh1xl0/model_4otogou3.stan', line 22, column 4 to column 22)\n",
      "  If this warning occurs sporadically, such as for highly constrained variable types like covariance matrices, then the sampler is fine,\n",
      "  but if this warning occurs often then your model may be either severely ill-conditioned or misspecified.\n",
      "  Informational Message: The current Metropolis proposal is about to be rejected because of the following issue:\n",
      "  Exception: gamma_lpdf: Random variable is inf, but must be positive finite! (in '/tmp/httpstan_t0dh1xl0/model_4otogou3.stan', line 22, column 4 to column 22)\n",
      "  If this warning occurs sporadically, such as for highly constrained variable types like covariance matrices, then the sampler is fine,\n",
      "  but if this warning occurs often then your model may be either severely ill-conditioned or misspecified.\n",
      "  Informational Message: The current Metropolis proposal is about to be rejected because of the following issue:\n",
      "  Exception: gamma_lpdf: Random variable is inf, but must be positive finite! (in '/tmp/httpstan_t0dh1xl0/model_4otogou3.stan', line 20, column 4 to column 25)\n",
      "  If this warning occurs sporadically, such as for highly constrained variable types like covariance matrices, then the sampler is fine,\n",
      "  but if this warning occurs often then your model may be either severely ill-conditioned or misspecified.\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<stan.Fit>\n",
      "Parameters:\n",
      "    v_easy: ()\n",
      "    v_hard: ()\n",
      "    a: ()\n",
      "    beta: ()\n",
      "    tau: ()\n",
      "Draws: 8000\n"
     ]
    }
   ],
   "source": [
    "stan_data = {\n",
    "    \"N\": len(data),\n",
    "    \"y\": data[\"rt\"].astype(float).values,\n",
    "    \"condition\": data[\"condition\"].astype(int).values,\n",
    "    \"choice\": data[\"choice\"].astype(int).values\n",
    "}\n",
    "\n",
    "model = stan.build(program_code=stan_code, data=stan_data)\n",
    "fit = model.sample(num_chains=4, num_samples=2000)\n",
    "\n",
    "# Diagnostics\n",
    "print(fit)  # R-hat and EES"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 500196 characters]",
      "text/plain": [
       "<Figure size 1200x1000 with 10 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "v_easy: mean = 2.48, 95% HDI = [1.95654057 2.98963516]\n",
      "v_hard: mean = 0.28, 95% HDI = [0.01961169 0.67641368]\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 29064 characters]",
      "text/plain": [
       "<Figure size 800x600 with 2 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>mean</th>\n",
       "      <th>sd</th>\n",
       "      <th>hdi_3%</th>\n",
       "      <th>hdi_97%</th>\n",
       "      <th>mcse_mean</th>\n",
       "      <th>mcse_sd</th>\n",
       "      <th>ess_bulk</th>\n",
       "      <th>ess_tail</th>\n",
       "      <th>r_hat</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>v_easy</th>\n",
       "      <td>2.478</td>\n",
       "      <td>0.262</td>\n",
       "      <td>1.986</td>\n",
       "      <td>2.972</td>\n",
       "      <td>0.004</td>\n",
       "      <td>0.003</td>\n",
       "      <td>4630.0</td>\n",
       "      <td>4592.0</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>v_hard</th>\n",
       "      <td>0.282</td>\n",
       "      <td>0.177</td>\n",
       "      <td>0.000</td>\n",
       "      <td>0.582</td>\n",
       "      <td>0.003</td>\n",
       "      <td>0.002</td>\n",
       "      <td>3177.0</td>\n",
       "      <td>2269.0</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>a</th>\n",
       "      <td>0.846</td>\n",
       "      <td>0.026</td>\n",
       "      <td>0.799</td>\n",
       "      <td>0.896</td>\n",
       "      <td>0.000</td>\n",
       "      <td>0.000</td>\n",
       "      <td>4537.0</td>\n",
       "      <td>4743.0</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>beta</th>\n",
       "      <td>0.524</td>\n",
       "      <td>0.021</td>\n",
       "      <td>0.484</td>\n",
       "      <td>0.561</td>\n",
       "      <td>0.000</td>\n",
       "      <td>0.000</td>\n",
       "      <td>4227.0</td>\n",
       "      <td>4836.0</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>tau</th>\n",
       "      <td>0.397</td>\n",
       "      <td>0.003</td>\n",
       "      <td>0.392</td>\n",
       "      <td>0.402</td>\n",
       "      <td>0.000</td>\n",
       "      <td>0.000</td>\n",
       "      <td>4290.0</td>\n",
       "      <td>5254.0</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "         mean     sd  hdi_3%  hdi_97%  mcse_mean  mcse_sd  ess_bulk  ess_tail  \\\n",
       "v_easy  2.478  0.262   1.986    2.972      0.004    0.003    4630.0    4592.0   \n",
       "v_hard  0.282  0.177   0.000    0.582      0.003    0.002    3177.0    2269.0   \n",
       "a       0.846  0.026   0.799    0.896      0.000    0.000    4537.0    4743.0   \n",
       "beta    0.524  0.021   0.484    0.561      0.000    0.000    4227.0    4836.0   \n",
       "tau     0.397  0.003   0.392    0.402      0.000    0.000    4290.0    5254.0   \n",
       "\n",
       "        r_hat  \n",
       "v_easy    1.0  \n",
       "v_hard    1.0  \n",
       "a         1.0  \n",
       "beta      1.0  \n",
       "tau       1.0  "
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# print and graph in a different cell because the stan takes 5 to 10 business centuries to run\n",
    "\n",
    "v_easy = fit[\"v_easy\"]\n",
    "v_hard = fit[\"v_hard\"]\n",
    "a = fit[\"a\"]\n",
    "beta = fit[\"beta\"]\n",
    "tau = fit[\"tau\"]\n",
    "\n",
    "fig = az.plot_trace(fit)\n",
    "plt.subplots_adjust(hspace=0.5)\n",
    "plt.savefig('trace_plot.png')\n",
    "plt.show()\n",
    "\n",
    "print(\n",
    "    f\"v_easy: mean = {np.mean(v_easy):.2f}, 95% HDI = {np.percentile(v_easy, [2.5, 97.5])}\")\n",
    "print(\n",
    "    f\"v_hard: mean = {np.mean(v_hard):.2f}, 95% HDI = {np.percentile(v_hard, [2.5, 97.5])}\")\n",
    "\n",
    "\n",
    "fig, axes = plt.subplots(2, 1, figsize=(8, 6))  # 2 subplots\n",
    "axes[0].hist(v_easy.flatten(), bins=30, density=True,\n",
    "             alpha=0.7, color='blue', edgecolor='black')\n",
    "axes[0].set_title(\"Histogram of v_easy\")\n",
    "\n",
    "axes[1].hist(v_hard.flatten(), bins=30, density=True,\n",
    "             alpha=0.7, color='red', edgecolor='black')\n",
    "axes[1].set_title(\"Histogram of v_hard\")\n",
    "\n",
    "plt.subplots_adjust(hspace=0.5)\n",
    "plt.savefig(\"drift_rate_histograms.png\", bbox_inches='tight')\n",
    "plt.show()\n",
    "\n",
    "az.summary(fit)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": ".venv",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.10"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
