{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "11453582",
   "metadata": {},
   "outputs": [],
   "source": [
    "from fitter import Fitter\n",
    "from scipy import io"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "a45df375",
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import pandas as pd\n",
    "import seaborn as sns\n",
    "from fitter import Fitter, get_common_distributions, get_distributions"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "af1f1ae9",
   "metadata": {},
   "outputs": [],
   "source": [
    "suv_filename = \"/home/marija/maki/suv_percentilesSLOthenUWM.mat\"\n",
    "flags_filename=\"/home/marija/maki/flags_combined.mat\"\n",
    "normal_range_filename =\"/home/marija/maki/normal_range.mat\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "3a2a1241",
   "metadata": {},
   "outputs": [],
   "source": [
    "\"\"\"\n",
    "Loading all data\n",
    "\"\"\"\n",
    "suv_dict = io.loadmat(suv_filename)\n",
    "flags_dict = io.loadmat(flags_filename)\n",
    "normal_range_dict = io.loadmat(normal_range_filename)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "eb8fde87",
   "metadata": {},
   "outputs": [],
   "source": [
    "\"\"\"\n",
    " Extracting only data associated to lungs\n",
    "\"\"\"\n",
    "lung_suv = suv_dict['lung_SUVperc_COMBINED'][0:58,:]\n",
    "flags = flags_dict['flags'][0:58,3]  # 0 == NC, 1 == AE"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "3ba61636",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(58, 17, 100)\n",
      "(58,)\n"
     ]
    }
   ],
   "source": [
    "print(lung_suv.shape)\n",
    "print(flags.shape)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "6d7b11d0",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[1 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0\n",
      " 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]\n",
      "NC: 53\n",
      "AE: 5\n"
     ]
    }
   ],
   "source": [
    "print(flags)\n",
    "print(\"NC:\", np.count_nonzero(flags==0))\n",
    "print(\"AE:\", np.count_nonzero(flags==1))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "7fb4074a",
   "metadata": {},
   "outputs": [],
   "source": [
    "p = 95  # percentile of interest\n",
    "X = np.nanmax(lung_suv[:,:,p], axis=1)  # taking SUV max and ignoring NaNs"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "d2df8bf7",
   "metadata": {},
   "outputs": [],
   "source": [
    "X_NC = X[flags == 0]\n",
    "X_AE = X[flags == 1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "29b7c7f6",
   "metadata": {},
   "outputs": [],
   "source": [
    "import matplotlib.pyplot as plt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "0a4f215e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.legend.Legend at 0x7f4885eb7210>"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "[encoded data, 7416 characters]\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "\"\"\"\n",
    " Plotting stuff\n",
    "\"\"\"\n",
    "plt.hist(X_NC,density=True,label=\"NC\")\n",
    "plt.hist(X_AE,density=True,label=\"AE\")\n",
    "plt.legend()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "b64ee380",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Fitting 106 distributions:  14%|▏| 15/106 [00:01<00:04, 18.39WARNING:root:SKIPPED kstwo distribution (taking more than 30 seconds)\n",
      "Fitting 106 distributions:  21%|▏| 22/106 [00:02<00:07, 11.78WARNING:root:SKIPPED rv_continuous distribution (taking more than 30 seconds)\n",
      "Fitting 106 distributions:  25%|▏| 26/106 [00:02<00:07, 11.32WARNING:root:SKIPPED rv_histogram distribution (taking more than 30 seconds)\n",
      "Fitting 106 distributions:  80%|▊| 85/106 [00:09<00:02,  8.72/home/marija/.conda/envs/pytorch/lib/python3.7/site-packages/scipy/stats/_continuous_distns.py:3094: IntegrationWarning: The integral is probably divergent, or slowly convergent.\n",
      "  t1 = integrate.quad(llc, -np.inf, x)[0]\n",
      "Fitting 106 distributions:  95%|▉| 101/106 [00:24<00:13,  2.6/home/marija/.conda/envs/pytorch/lib/python3.7/site-packages/scipy/stats/_continuous_distns.py:4837: IntegrationWarning: The integral is probably divergent, or slowly convergent.\n",
      "  intg = integrate.quad(f, -xi, np.pi/2, **intg_kwargs)[0]\n",
      "/home/marija/.conda/envs/pytorch/lib/python3.7/site-packages/scipy/integrate/quadpack.py:880: IntegrationWarning: The maximum number of subdivisions (50) has been achieved.\n",
      "  If increasing the limit yields no improvement it is advised to analyze \n",
      "  the integrand in order to determine the difficulties.  If the position of a \n",
      "  local difficulty can be determined (singularity, discontinuity) one will \n",
      "  probably gain from splitting up the interval and calling the integrator \n",
      "  on the subranges.  Perhaps a special-purpose integrator should be used.\n",
      "  **opt)\n",
      "Fitting 106 distributions:  97%|▉| 103/106 [00:29<00:07,  2.5WARNING:root:SKIPPED levy_stable distribution (taking more than 30 seconds)\n",
      "Fitting 106 distributions:  98%|▉| 104/106 [00:31<00:04,  2.3WARNING:root:SKIPPED studentized_range distribution (taking more than 30 seconds)\n",
      "Fitting 106 distributions:  99%|▉| 105/106 [00:32<00:02,  2.1WARNING:root:SKIPPED vonmises distribution (taking more than 30 seconds)\n",
      "Fitting 106 distributions: 100%|█| 106/106 [00:34<00:00,  3.0\n"
     ]
    },
    {
     "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>sumsquare_error</th>\n",
       "      <th>aic</th>\n",
       "      <th>bic</th>\n",
       "      <th>kl_div</th>\n",
       "      <th>ks_statistic</th>\n",
       "      <th>ks_pvalue</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>dgamma</th>\n",
       "      <td>57.256870</td>\n",
       "      <td>425.526074</td>\n",
       "      <td>16.005429</td>\n",
       "      <td>inf</td>\n",
       "      <td>0.096016</td>\n",
       "      <td>0.677014</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>dweibull</th>\n",
       "      <td>59.582768</td>\n",
       "      <td>414.337885</td>\n",
       "      <td>18.115823</td>\n",
       "      <td>inf</td>\n",
       "      <td>0.098857</td>\n",
       "      <td>0.642004</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>mielke</th>\n",
       "      <td>61.068543</td>\n",
       "      <td>389.794907</td>\n",
       "      <td>23.391531</td>\n",
       "      <td>inf</td>\n",
       "      <td>0.092708</td>\n",
       "      <td>0.717457</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>logistic</th>\n",
       "      <td>61.387552</td>\n",
       "      <td>406.729837</td>\n",
       "      <td>15.727087</td>\n",
       "      <td>inf</td>\n",
       "      <td>0.100015</td>\n",
       "      <td>0.627755</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>burr</th>\n",
       "      <td>61.891249</td>\n",
       "      <td>371.295200</td>\n",
       "      <td>24.100772</td>\n",
       "      <td>inf</td>\n",
       "      <td>0.099767</td>\n",
       "      <td>0.630798</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "          sumsquare_error         aic        bic  kl_div  ks_statistic  \\\n",
       "dgamma          57.256870  425.526074  16.005429     inf      0.096016   \n",
       "dweibull        59.582768  414.337885  18.115823     inf      0.098857   \n",
       "mielke          61.068543  389.794907  23.391531     inf      0.092708   \n",
       "logistic        61.387552  406.729837  15.727087     inf      0.100015   \n",
       "burr            61.891249  371.295200  24.100772     inf      0.099767   \n",
       "\n",
       "          ks_pvalue  \n",
       "dgamma     0.677014  \n",
       "dweibull   0.642004  \n",
       "mielke     0.717457  \n",
       "logistic   0.627755  \n",
       "burr       0.630798  "
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/home/marija/.conda/envs/pytorch/lib/python3.7/site-packages/scipy/integrate/quadpack.py:880: IntegrationWarning: The integral is probably divergent, or slowly convergent.\n",
      "  **opt)\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 23220 characters]\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "f = Fitter(X_NC)\n",
    "f.fit()\n",
    "f.summary()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "1c87fdec",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Fitting 5 distributions: 100%|█| 5/5 [00:02<00:00,  1.82it/s]\n"
     ]
    },
    {
     "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>sumsquare_error</th>\n",
       "      <th>aic</th>\n",
       "      <th>bic</th>\n",
       "      <th>kl_div</th>\n",
       "      <th>ks_statistic</th>\n",
       "      <th>ks_pvalue</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>burr</th>\n",
       "      <td>61.891249</td>\n",
       "      <td>371.295200</td>\n",
       "      <td>24.100772</td>\n",
       "      <td>inf</td>\n",
       "      <td>0.099767</td>\n",
       "      <td>0.630798</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>norm</th>\n",
       "      <td>62.494042</td>\n",
       "      <td>445.292821</td>\n",
       "      <td>16.673888</td>\n",
       "      <td>inf</td>\n",
       "      <td>0.148212</td>\n",
       "      <td>0.176081</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>gamma</th>\n",
       "      <td>63.467576</td>\n",
       "      <td>352.535206</td>\n",
       "      <td>21.463450</td>\n",
       "      <td>inf</td>\n",
       "      <td>0.134092</td>\n",
       "      <td>0.271326</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>lognorm</th>\n",
       "      <td>63.523706</td>\n",
       "      <td>344.823594</td>\n",
       "      <td>21.510302</td>\n",
       "      <td>inf</td>\n",
       "      <td>0.130770</td>\n",
       "      <td>0.298382</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>beta</th>\n",
       "      <td>63.641649</td>\n",
       "      <td>348.827907</td>\n",
       "      <td>25.578906</td>\n",
       "      <td>inf</td>\n",
       "      <td>0.135396</td>\n",
       "      <td>0.261207</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "         sumsquare_error         aic        bic  kl_div  ks_statistic  \\\n",
       "burr           61.891249  371.295200  24.100772     inf      0.099767   \n",
       "norm           62.494042  445.292821  16.673888     inf      0.148212   \n",
       "gamma          63.467576  352.535206  21.463450     inf      0.134092   \n",
       "lognorm        63.523706  344.823594  21.510302     inf      0.130770   \n",
       "beta           63.641649  348.827907  25.578906     inf      0.135396   \n",
       "\n",
       "         ks_pvalue  \n",
       "burr      0.630798  \n",
       "norm      0.176081  \n",
       "gamma     0.271326  \n",
       "lognorm   0.298382  \n",
       "beta      0.261207  "
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "[encoded data, 24376 characters]\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "f = Fitter(X_NC, distributions=['gamma',\n",
    "                          'lognorm',\n",
    "                          \"beta\",\n",
    "                          \"burr\",\n",
    "                          \"norm\"])\n",
    "f.fit()\n",
    "f.summary()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "e6a1a7ad",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Fitting 10 distributions: 100%|█| 10/10 [00:00<00:00, 29.96it\n"
     ]
    },
    {
     "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>sumsquare_error</th>\n",
       "      <th>aic</th>\n",
       "      <th>bic</th>\n",
       "      <th>kl_div</th>\n",
       "      <th>ks_statistic</th>\n",
       "      <th>ks_pvalue</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>norm</th>\n",
       "      <td>62.494042</td>\n",
       "      <td>445.292821</td>\n",
       "      <td>16.673888</td>\n",
       "      <td>inf</td>\n",
       "      <td>0.148212</td>\n",
       "      <td>0.176081</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>rayleigh</th>\n",
       "      <td>63.176997</td>\n",
       "      <td>inf</td>\n",
       "      <td>17.249947</td>\n",
       "      <td>inf</td>\n",
       "      <td>0.133943</td>\n",
       "      <td>0.272504</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>gamma</th>\n",
       "      <td>63.467576</td>\n",
       "      <td>352.535206</td>\n",
       "      <td>21.463450</td>\n",
       "      <td>inf</td>\n",
       "      <td>0.134092</td>\n",
       "      <td>0.271326</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>lognorm</th>\n",
       "      <td>63.523706</td>\n",
       "      <td>344.823594</td>\n",
       "      <td>21.510302</td>\n",
       "      <td>inf</td>\n",
       "      <td>0.130770</td>\n",
       "      <td>0.298382</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>cauchy</th>\n",
       "      <td>70.967112</td>\n",
       "      <td>297.308600</td>\n",
       "      <td>23.412590</td>\n",
       "      <td>inf</td>\n",
       "      <td>0.132246</td>\n",
       "      <td>0.286136</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "          sumsquare_error         aic        bic  kl_div  ks_statistic  \\\n",
       "norm            62.494042  445.292821  16.673888     inf      0.148212   \n",
       "rayleigh        63.176997         inf  17.249947     inf      0.133943   \n",
       "gamma           63.467576  352.535206  21.463450     inf      0.134092   \n",
       "lognorm         63.523706  344.823594  21.510302     inf      0.130770   \n",
       "cauchy          70.967112  297.308600  23.412590     inf      0.132246   \n",
       "\n",
       "          ks_pvalue  \n",
       "norm       0.176081  \n",
       "rayleigh   0.272504  \n",
       "gamma      0.271326  \n",
       "lognorm    0.298382  \n",
       "cauchy     0.286136  "
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "[encoded data, 28544 characters]\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "f = Fitter(X_NC, distributions = get_common_distributions())\n",
    "f.fit()\n",
    "f.summary()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "5c50d9de",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Fitting 106 distributions:   8%| | 8/106 [00:01<00:13,  7.51iWARNING:root:SKIPPED kstwo distribution (taking more than 30 seconds)\n",
      "Fitting 106 distributions:  18%|▏| 19/106 [00:01<00:04, 17.84WARNING:root:SKIPPED rv_continuous distribution (taking more than 30 seconds)\n",
      "Fitting 106 distributions:  21%|▏| 22/106 [00:01<00:04, 18.82WARNING:root:SKIPPED rv_histogram distribution (taking more than 30 seconds)\n",
      "Fitting 106 distributions:  96%|▉| 102/106 [00:25<00:09,  2.2/home/marija/.conda/envs/pytorch/lib/python3.7/site-packages/scipy/integrate/quadpack.py:880: IntegrationWarning: The maximum number of subdivisions (50) has been achieved.\n",
      "  If increasing the limit yields no improvement it is advised to analyze \n",
      "  the integrand in order to determine the difficulties.  If the position of a \n",
      "  local difficulty can be determined (singularity, discontinuity) one will \n",
      "  probably gain from splitting up the interval and calling the integrator \n",
      "  on the subranges.  Perhaps a special-purpose integrator should be used.\n",
      "  **opt)\n",
      "Fitting 106 distributions:  97%|▉| 103/106 [00:26<00:05,  1.9WARNING:root:SKIPPED levy_stable distribution (taking more than 30 seconds)\n",
      "Fitting 106 distributions:  98%|▉| 104/106 [00:31<00:05,  2.6WARNING:root:SKIPPED studentized_range distribution (taking more than 30 seconds)\n",
      "Fitting 106 distributions:  99%|▉| 105/106 [00:32<00:02,  2.1WARNING:root:SKIPPED vonmises distribution (taking more than 30 seconds)\n",
      "Fitting 106 distributions: 100%|█| 106/106 [00:33<00:00,  3.1\n"
     ]
    },
    {
     "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>sumsquare_error</th>\n",
       "      <th>aic</th>\n",
       "      <th>bic</th>\n",
       "      <th>kl_div</th>\n",
       "      <th>ks_statistic</th>\n",
       "      <th>ks_pvalue</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>exponweib</th>\n",
       "      <td>228.925939</td>\n",
       "      <td>440.014005</td>\n",
       "      <td>25.557555</td>\n",
       "      <td>inf</td>\n",
       "      <td>0.403842</td>\n",
       "      <td>0.298813</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>exponpow</th>\n",
       "      <td>229.805636</td>\n",
       "      <td>394.721026</td>\n",
       "      <td>23.967294</td>\n",
       "      <td>inf</td>\n",
       "      <td>0.388485</td>\n",
       "      <td>0.340837</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>fisk</th>\n",
       "      <td>231.478144</td>\n",
       "      <td>503.287303</td>\n",
       "      <td>24.003551</td>\n",
       "      <td>inf</td>\n",
       "      <td>0.367344</td>\n",
       "      <td>0.408087</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>gamma</th>\n",
       "      <td>234.918930</td>\n",
       "      <td>449.229349</td>\n",
       "      <td>24.077327</td>\n",
       "      <td>inf</td>\n",
       "      <td>0.530632</td>\n",
       "      <td>0.076795</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>powerlognorm</th>\n",
       "      <td>235.582727</td>\n",
       "      <td>876.615438</td>\n",
       "      <td>25.700873</td>\n",
       "      <td>inf</td>\n",
       "      <td>0.761559</td>\n",
       "      <td>0.001558</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "              sumsquare_error         aic        bic  kl_div  ks_statistic  \\\n",
       "exponweib          228.925939  440.014005  25.557555     inf      0.403842   \n",
       "exponpow           229.805636  394.721026  23.967294     inf      0.388485   \n",
       "fisk               231.478144  503.287303  24.003551     inf      0.367344   \n",
       "gamma              234.918930  449.229349  24.077327     inf      0.530632   \n",
       "powerlognorm       235.582727  876.615438  25.700873     inf      0.761559   \n",
       "\n",
       "              ks_pvalue  \n",
       "exponweib      0.298813  \n",
       "exponpow       0.340837  \n",
       "fisk           0.408087  \n",
       "gamma          0.076795  \n",
       "powerlognorm   0.001558  "
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/home/marija/.conda/envs/pytorch/lib/python3.7/site-packages/scipy/integrate/quadpack.py:880: IntegrationWarning: The integral is probably divergent, or slowly convergent.\n",
      "  **opt)\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 20312 characters]\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "f = Fitter(X_AE)\n",
    "f.fit()\n",
    "f.summary()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "4048b123",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "PYTORCH",
   "language": "python",
   "name": "pytorch"
  },
  "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.7.13"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
