{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "753d084e",
   "metadata": {},
   "outputs": [],
   "source": [
    "import sys\n",
    "sys.path.insert(0, '../Results')\n",
    "sys.path.insert(0, '../../src')\n",
    "import pandas as pd\n",
    "import numpy as np\n",
    "import matplotlib.pyplot as plt\n",
    "import pickle\n",
    "import os\n",
    "from visualization_utils import perc, SetPlotRC, ApplyFont"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "c80f8315",
   "metadata": {},
   "outputs": [],
   "source": [
    "# if not os.path.exists(\"Figures\"):\n",
    "#     os.mkdir(\"Figures\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "8fe56d7a",
   "metadata": {},
   "source": [
    "# 4-PAM Noisy"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "f40e376b",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(100, 13)\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "<AxesSubplot:>"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "[encoded data, 6252 characters]\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "df_4pam_results = pd.read_pickle(r\"../Results/simulation_results_4PAM_V1.pkl\")\n",
    "print(df_4pam_results.shape)\n",
    "df_4pam_results['SINR'].hist()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "6120be78",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "findfont: Font family ['Times New Roman'] not found. Falling back to DejaVu Sans.\n",
      "findfont: Font family ['Times New Roman'] not found. Falling back to DejaVu Sans.\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 44372 characters]\n",
      "text/plain": [
       "<Figure size 800x480 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "data = np.stack(df_4pam_results['SINRlist'].apply(lambda row: np.array(row)).to_numpy(), axis = 0)\n",
    "\n",
    "# compute the mean, 25/75 percentiles, and standard deviation\n",
    "mean_, perc_25, perc_75, std_data = perc(data)\n",
    "\n",
    "x = np.arange(0, mean_.shape[0])\n",
    "fh2=plt.figure(figsize=(10, 6), dpi=80)\n",
    "plt.plot(x, mean_, linewidth=4, color='#006BB2')\n",
    "plt.fill_between(x, mean_ + std_data, mean_ - std_data, alpha=0.25, linewidth=0, color='#006BB2')\n",
    "\n",
    "\n",
    "gh=plt.grid(linewidth=2)\n",
    "plt.xticks(fontsize=20)\n",
    "plt.yticks(fontsize=20)\n",
    "plt.ylabel('SINR (dB)',fontsize=25)\n",
    "plt.xlabel(r\"Number of Iterations / 25000\",fontsize=25)\n",
    "plt.title(\"Online CorInfoMax 4-PAM SINR Convergence \")\n",
    "plt.axis([0.0,4.0,-0,32])\n",
    "ApplyFont(plt.gca())\n",
    "\n",
    "# plt.savefig('Figures/CorInfoMax4PAM_convergence30dBSNR.pdf', format='pdf')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "50ceabbf",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<AxesSubplot:>"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "[encoded data, 5652 characters]\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "df_4pam_results['SER'].hist()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "ccd43c0e",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "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.8.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
