{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "8cab8eff",
   "metadata": {},
   "source": [
    "### Exercise 5"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "1aeaf0c1",
   "metadata": {},
   "source": [
    "#### Import"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "de11939b",
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "from scipy.stats import beta"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "3e2e1d30",
   "metadata": {},
   "source": [
    "#### Parameters"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "438466ec",
   "metadata": {},
   "outputs": [],
   "source": [
    "n = 14\n",
    "sim = 10_000"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "5dc2fc49",
   "metadata": {},
   "source": [
    "### (e)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "23f339f5",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Posterior mean estimate: 0.937\n",
      "Posterior variance estimate: 0.004\n"
     ]
    }
   ],
   "source": [
    "sample = beta(n+1, 1).rvs(sim)\n",
    "posterior_mean_estimate = np.mean(sample)\n",
    "posterior_variance_estimate = np.var(sample)\n",
    "\n",
    "print(f'Posterior mean estimate: {np.round(posterior_mean_estimate, 3)}')\n",
    "print(f'Posterior variance estimate: {np.round(posterior_variance_estimate, 3)}')"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "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.10.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
