{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "1af8b99c",
   "metadata": {},
   "source": [
    "# Fitting distribution\n",
    "\n",
    "Author: Marija Delic, 2023"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "11453582",
   "metadata": {},
   "outputs": [],
   "source": [
    "from fitter import Fitter\n",
    "from scipy import io"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "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": 3,
   "id": "af1f1ae9",
   "metadata": {},
   "outputs": [],
   "source": [
    "suv_filename = \"../data/suv_percentilesSLOthenUWM.mat\"\n",
    "flags_filename=\"../data/flags_combined.mat\"\n",
    "normal_range_filename =\"../data/normal_range.mat\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "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": 5,
   "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": 6,
   "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": 7,
   "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": 8,
   "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": 9,
   "id": "d2df8bf7",
   "metadata": {},
   "outputs": [],
   "source": [
    "X_NC = X[flags == 0]\n",
    "X_AE = X[flags == 1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "29b7c7f6",
   "metadata": {},
   "outputs": [],
   "source": [
    "import matplotlib.pyplot as plt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "0a4f215e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.legend.Legend at 0x7be835f5b3e0>"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "[encoded data, 15584 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "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": 12,
   "id": "b64ee380",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "2025-03-14 20:33:19.475 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted anglit distribution with error=64.147876)\n",
      "2025-03-14 20:33:19.562 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted arcsine distribution with error=117.749167)\n",
      "2025-03-14 20:33:19.600 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted argus distribution with error=103.851466)\n",
      "2025-03-14 20:33:19.736 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted cauchy distribution with error=70.967112)\n",
      "2025-03-14 20:33:19.754 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted burr distribution with error=61.891249)\n",
      "2025-03-14 20:33:19.763 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted burr12 distribution with error=62.131548)\n",
      "2025-03-14 20:33:19.811 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted chi distribution with error=63.407239)\n",
      "2025-03-14 20:33:19.814 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted bradford distribution with error=95.091169)\n",
      "2025-03-14 20:33:19.891 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted cosine distribution with error=132.880897)\n",
      "2025-03-14 20:33:19.900 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted betaprime distribution with error=63.047044)\n",
      "2025-03-14 20:33:19.904 | WARNING  | fitter.fitter:_fit_single_distribution:337 - SKIPPED _fit distribution (taking more than 30 seconds)\n",
      "2025-03-14 20:33:19.910 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted beta distribution with error=63.641649)\n",
      "2025-03-14 20:33:19.913 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted chi2 distribution with error=125.592492)\n",
      "2025-03-14 20:33:19.940 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted dweibull distribution with error=59.582768)\n",
      "2025-03-14 20:33:19.951 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted dgamma distribution with error=57.25687)\n",
      "2025-03-14 20:33:19.956 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted expon distribution with error=100.995868)\n",
      "2025-03-14 20:33:19.991 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted exponnorm distribution with error=62.329817)\n",
      "2025-03-14 20:33:20.015 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted erlang distribution with error=63.46758)\n",
      "2025-03-14 20:33:20.043 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted alpha distribution with error=63.551371)\n",
      "2025-03-14 20:33:20.068 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted fatiguelife distribution with error=63.49226)\n",
      "2025-03-14 20:33:20.138 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted foldcauchy distribution with error=71.006471)\n",
      "2025-03-14 20:33:20.146 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted foldnorm distribution with error=63.075166)\n",
      "2025-03-14 20:33:20.167 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted crystalball distribution with error=62.494043)\n",
      "2025-03-14 20:33:20.183 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted fisk distribution with error=62.373276)\n",
      "2025-03-14 20:33:20.201 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted f distribution with error=63.533486)\n",
      "2025-03-14 20:33:20.226 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted gamma distribution with error=63.467576)\n",
      "2025-03-14 20:33:20.252 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted exponpow distribution with error=74.722514)\n",
      "2025-03-14 20:33:20.269 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted genhalflogistic distribution with error=112.93178)\n",
      "2025-03-14 20:33:20.304 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted genextreme distribution with error=64.825608)\n",
      "2025-03-14 20:33:20.314 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted genlogistic distribution with error=61.962151)\n",
      "2025-03-14 20:33:20.333 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted gennorm distribution with error=65.216291)\n",
      "2025-03-14 20:33:20.366 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted gibrat distribution with error=91.576204)\n",
      "2025-03-14 20:33:20.435 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted exponweib distribution with error=63.849318)\n",
      "2025-03-14 20:33:20.449 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted gumbel_l distribution with error=78.674518)\n",
      "2025-03-14 20:33:20.464 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted gumbel_r distribution with error=66.371286)\n",
      "2025-03-14 20:33:20.475 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted halfcauchy distribution with error=97.060677)\n",
      "2025-03-14 20:33:20.488 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted gengamma distribution with error=63.723087)\n",
      "2025-03-14 20:33:20.498 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted halflogistic distribution with error=90.270268)\n",
      "2025-03-14 20:33:20.506 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted genpareto distribution with error=89.583493)\n",
      "2025-03-14 20:33:20.510 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted halfnorm distribution with error=87.364496)\n",
      "2025-03-14 20:33:20.526 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted hypsecant distribution with error=62.754794)\n",
      "2025-03-14 20:33:20.557 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted genhyperbolic distribution with error=62.424139)\n",
      "2025-03-14 20:33:20.557 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted geninvgauss distribution with error=63.558485)\n",
      "2025-03-14 20:33:20.563 | WARNING  | fitter.fitter:_fit_single_distribution:337 - SKIPPED irwinhall distribution (taking more than 30 seconds)\n",
      "2025-03-14 20:33:20.580 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted invgamma distribution with error=63.538562)\n",
      "2025-03-14 20:33:20.605 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted gompertz distribution with error=82.367909)\n",
      "2025-03-14 20:33:20.646 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted invgauss distribution with error=63.503425)\n",
      "2025-03-14 20:33:20.654 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted genexpon distribution with error=68.913661)\n",
      "2025-03-14 20:33:20.658 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted johnsonsu distribution with error=62.564347)\n",
      "2025-03-14 20:33:20.678 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted gausshyper distribution with error=94.289833)\n",
      "2025-03-14 20:33:20.710 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted ksone distribution with error=101.864313)\n",
      "2025-03-14 20:33:20.736 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted kappa3 distribution with error=75.523347)\n",
      "2025-03-14 20:33:20.746 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted laplace distribution with error=70.136116)\n",
      "2025-03-14 20:33:20.747 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted invweibull distribution with error=66.377578)\n",
      "2025-03-14 20:33:20.758 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted kstwo distribution with error=135.865512)\n",
      "2025-03-14 20:33:20.760 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted halfgennorm distribution with error=81.25525)\n",
      "2025-03-14 20:33:20.777 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted levy_l distribution with error=120.059332)\n",
      "2025-03-14 20:33:20.786 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted levy distribution with error=103.345517)\n",
      "2025-03-14 20:33:20.799 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted logistic distribution with error=61.387552)\n",
      "2025-03-14 20:33:20.803 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted jf_skew_t distribution with error=63.664289)\n",
      "2025-03-14 20:33:20.813 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted lognorm distribution with error=63.524129)\n",
      "2025-03-14 20:33:20.817 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted laplace_asymmetric distribution with error=64.678523)\n",
      "2025-03-14 20:33:20.862 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted loglaplace distribution with error=70.584247)\n",
      "2025-03-14 20:33:20.884 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted loguniform distribution with error=87.289922)\n",
      "2025-03-14 20:33:20.889 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted lomax distribution with error=101.463778)\n",
      "2025-03-14 20:33:20.897 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted loggamma distribution with error=63.282334)\n",
      "2025-03-14 20:33:20.899 | WARNING  | fitter.fitter:_fit_single_distribution:337 - SKIPPED multivariate_normal distribution (taking more than 30 seconds)\n",
      "2025-03-14 20:33:20.902 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted maxwell distribution with error=64.551249)\n",
      "2025-03-14 20:33:20.943 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted moyal distribution with error=70.172314)\n",
      "2025-03-14 20:33:20.949 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted nakagami distribution with error=63.858936)\n",
      "2025-03-14 20:33:21.085 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted mielke distribution with error=61.068543)\n",
      "2025-03-14 20:33:21.097 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted kstwobign distribution with error=68.071393)\n",
      "2025-03-14 20:33:21.104 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted johnsonsb distribution with error=63.570136)\n",
      "2025-03-14 20:33:21.112 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted norm distribution with error=62.494042)\n",
      "2025-03-14 20:33:21.124 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted pareto distribution with error=100.995868)\n",
      "2025-03-14 20:33:21.140 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted powerlaw distribution with error=114.111038)\n",
      "2025-03-14 20:33:21.156 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted ncf distribution with error=63.667487)\n",
      "2025-03-14 20:33:21.221 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted pearson3 distribution with error=63.467929)\n",
      "2025-03-14 20:33:21.259 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted norminvgauss distribution with error=62.774409)\n",
      "2025-03-14 20:33:21.321 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted reciprocal distribution with error=87.289922)\n",
      "2025-03-14 20:33:21.352 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted rdist distribution with error=105.633376)\n",
      "2025-03-14 20:33:21.408 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted powernorm distribution with error=63.706962)\n",
      "2025-03-14 20:33:21.410 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted rel_breitwigner distribution with error=64.676165)\n",
      "2025-03-14 20:33:21.420 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted rayleigh distribution with error=68.650651)\n",
      "2025-03-14 20:33:21.424 | WARNING  | fitter.fitter:_fit_single_distribution:337 - SKIPPED rv_histogram distribution (taking more than 30 seconds)\n",
      "2025-03-14 20:33:21.443 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted semicircular distribution with error=96.900468)\n",
      "2025-03-14 20:33:21.473 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted rice distribution with error=63.95261)\n",
      "2025-03-14 20:33:21.476 | WARNING  | fitter.fitter:_fit_single_distribution:337 - SKIPPED rv_continuous distribution (taking more than 30 seconds)\n",
      "2025-03-14 20:33:21.496 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted skewcauchy distribution with error=68.089104)\n",
      "2025-03-14 20:33:21.512 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted ncx2 distribution with error=116.466509)\n",
      "2025-03-14 20:33:21.558 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted nct distribution with error=62.190382)\n",
      "2025-03-14 20:33:21.597 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted skewnorm distribution with error=63.198772)\n",
      "2025-03-14 20:33:21.597 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted kappa4 distribution with error=98.227243)\n",
      "2025-03-14 20:33:21.619 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted trapezoid distribution with error=123.620771)\n",
      "2025-03-14 20:33:21.694 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted triang distribution with error=77.610454)\n",
      "2025-03-14 20:33:21.701 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted trapz distribution with error=123.620771)\n",
      "2025-03-14 20:33:21.740 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted uniform distribution with error=100.978125)\n",
      "2025-03-14 20:33:21.767 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted powerlognorm distribution with error=63.418964)\n",
      "2025-03-14 20:33:21.768 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted vonmises distribution with error=62.002246)\n",
      "2025-03-14 20:33:21.778 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted truncexpon distribution with error=92.437831)\n",
      "2025-03-14 20:33:21.778 | WARNING  | fitter.fitter:_fit_single_distribution:337 - SKIPPED vonmises_fisher distribution (taking more than 30 seconds)\n",
      "2025-03-14 20:33:21.800 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted wald distribution with error=89.680928)\n",
      "2025-03-14 20:33:21.820 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted truncweibull_min distribution with error=92.278674)\n",
      "2025-03-14 20:33:21.839 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted levy_stable distribution with error=60.595428)\n",
      "2025-03-14 20:33:21.840 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted truncnorm distribution with error=92.068708)\n",
      "2025-03-14 20:33:21.862 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted weibull_max distribution with error=64.825475)\n",
      "2025-03-14 20:33:21.867 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted weibull_min distribution with error=67.786048)\n",
      "2025-03-14 20:33:21.884 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted wrapcauchy distribution with error=101.064515)\n",
      "2025-03-14 20:33:21.976 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted truncpareto distribution with error=97.748045)\n",
      "2025-03-14 20:33:22.007 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted tukeylambda distribution with error=112.153074)\n",
      "2025-03-14 20:33:22.612 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted vonmises_line distribution with error=132.880897)\n",
      "2025-03-14 20:33:24.545 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted recipinvgauss distribution with error=63.487826)\n",
      "/home/horvat/venvs/base/lib/python3.12/site-packages/scipy/integrate/_quadpack_py.py:1260: 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",
      "  quad_r = quad(f, low, high, args=args, full_output=self.full_output,\n",
      "/home/horvat/venvs/base/lib/python3.12/site-packages/scipy/integrate/_quadpack_py.py:1260: IntegrationWarning: The integral is probably divergent, or slowly convergent.\n",
      "  quad_r = quad(f, low, high, args=args, full_output=self.full_output,\n",
      "2025-03-14 20:33:51.512 | WARNING  | fitter.fitter:_fit_single_distribution:337 - SKIPPED studentized_range distribution (taking more than 30 seconds)\n",
      "2025-03-14 20:33:52.409 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted t distribution with error=62.430767)\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>431.436950</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>420.248761</td>\n",
       "      <td>inf</td>\n",
       "      <td>0.098857</td>\n",
       "      <td>0.642004</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>levy_stable</th>\n",
       "      <td>60.595428</td>\n",
       "      <td>646.645060</td>\n",
       "      <td>654.526228</td>\n",
       "      <td>inf</td>\n",
       "      <td>0.095316</td>\n",
       "      <td>0.685610</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>mielke</th>\n",
       "      <td>61.068543</td>\n",
       "      <td>389.794907</td>\n",
       "      <td>397.676075</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>410.670420</td>\n",
       "      <td>inf</td>\n",
       "      <td>0.100015</td>\n",
       "      <td>0.627755</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  431.436950     inf      0.096016   \n",
       "dweibull           59.582768  414.337885  420.248761     inf      0.098857   \n",
       "levy_stable        60.595428  646.645060  654.526228     inf      0.095316   \n",
       "mielke             61.068543  389.794907  397.676075     inf      0.092708   \n",
       "logistic           61.387552  406.729837  410.670420     inf      0.100015   \n",
       "\n",
       "             ks_pvalue  \n",
       "dgamma        0.677014  \n",
       "dweibull      0.642004  \n",
       "levy_stable   0.685610  \n",
       "mielke        0.717457  \n",
       "logistic      0.627755  "
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "[encoded data, 47560 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "f = Fitter(X_NC)\n",
    "f.fit()\n",
    "f.summary()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "1c87fdec",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "2025-03-14 20:33:53.065 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted lognorm distribution with error=63.524129)\n",
      "2025-03-14 20:33:53.082 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted norm distribution with error=62.494042)\n",
      "2025-03-14 20:33:53.142 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted gamma distribution with error=63.467576)\n",
      "2025-03-14 20:33:53.231 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted burr distribution with error=61.891249)\n",
      "2025-03-14 20:33:53.270 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted beta distribution with error=63.641649)\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>379.176368</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>449.233404</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>358.446082</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.524129</td>\n",
       "      <td>344.814300</td>\n",
       "      <td>350.725175</td>\n",
       "      <td>inf</td>\n",
       "      <td>0.130771</td>\n",
       "      <td>0.298377</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>beta</th>\n",
       "      <td>63.641649</td>\n",
       "      <td>348.827907</td>\n",
       "      <td>356.709074</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  379.176368     inf      0.099767   \n",
       "norm           62.494042  445.292821  449.233404     inf      0.148212   \n",
       "gamma          63.467576  352.535206  358.446082     inf      0.134092   \n",
       "lognorm        63.524129  344.814300  350.725175     inf      0.130771   \n",
       "beta           63.641649  348.827907  356.709074     inf      0.135396   \n",
       "\n",
       "         ks_pvalue  \n",
       "burr      0.630798  \n",
       "norm      0.176081  \n",
       "gamma     0.271326  \n",
       "lognorm   0.298377  \n",
       "beta      0.261207  "
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "[encoded data, 46472 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "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": 14,
   "id": "e6a1a7ad",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "2025-03-14 20:33:54.040 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted norm distribution with error=62.494042)\n",
      "2025-03-14 20:33:54.041 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted cauchy distribution with error=70.967112)\n",
      "2025-03-14 20:33:54.043 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted lognorm distribution with error=63.524129)\n",
      "2025-03-14 20:33:54.053 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted powerlaw distribution with error=114.111038)\n",
      "2025-03-14 20:33:54.059 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted uniform distribution with error=100.978125)\n",
      "2025-03-14 20:33:54.061 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted rayleigh distribution with error=68.650651)\n",
      "2025-03-14 20:33:54.110 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted gamma distribution with error=63.467576)\n",
      "2025-03-14 20:33:54.155 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted chi2 distribution with error=125.592492)\n",
      "2025-03-14 20:33:54.170 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted expon distribution with error=100.995868)\n",
      "2025-03-14 20:33:54.249 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted exponpow distribution with error=74.722514)\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>449.233404</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>358.446082</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.524129</td>\n",
       "      <td>344.814300</td>\n",
       "      <td>350.725175</td>\n",
       "      <td>inf</td>\n",
       "      <td>0.130771</td>\n",
       "      <td>0.298377</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>rayleigh</th>\n",
       "      <td>68.650651</td>\n",
       "      <td>294.459176</td>\n",
       "      <td>298.399759</td>\n",
       "      <td>inf</td>\n",
       "      <td>0.155178</td>\n",
       "      <td>0.139927</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>cauchy</th>\n",
       "      <td>70.967112</td>\n",
       "      <td>297.308600</td>\n",
       "      <td>301.249184</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  449.233404     inf      0.148212   \n",
       "gamma           63.467576  352.535206  358.446082     inf      0.134092   \n",
       "lognorm         63.524129  344.814300  350.725175     inf      0.130771   \n",
       "rayleigh        68.650651  294.459176  298.399759     inf      0.155178   \n",
       "cauchy          70.967112  297.308600  301.249184     inf      0.132246   \n",
       "\n",
       "          ks_pvalue  \n",
       "norm       0.176081  \n",
       "gamma      0.271326  \n",
       "lognorm    0.298377  \n",
       "rayleigh   0.139927  \n",
       "cauchy     0.286136  "
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "[encoded data, 55492 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "f = Fitter(X_NC, distributions = get_common_distributions())\n",
    "f.fit()\n",
    "f.summary()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "5c50d9de",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "2025-03-14 20:33:55.051 | WARNING  | fitter.fitter:_fit_single_distribution:337 - SKIPPED _fit distribution (taking more than 30 seconds)\n",
      "2025-03-14 20:33:55.077 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted anglit distribution with error=266.75092)\n",
      "2025-03-14 20:33:55.121 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted argus distribution with error=268.707736)\n",
      "2025-03-14 20:33:55.145 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted arcsine distribution with error=241.001093)\n",
      "2025-03-14 20:33:55.168 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted alpha distribution with error=257.364705)\n",
      "2025-03-14 20:33:55.172 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted cauchy distribution with error=250.337238)\n",
      "2025-03-14 20:33:55.210 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted beta distribution with error=241.722912)\n",
      "2025-03-14 20:33:55.215 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted cosine distribution with error=266.21987)\n",
      "2025-03-14 20:33:55.333 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted bradford distribution with error=251.268831)\n",
      "2025-03-14 20:33:55.347 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted burr12 distribution with error=241.650093)\n",
      "2025-03-14 20:33:55.358 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted chi distribution with error=238.764954)\n",
      "2025-03-14 20:33:55.363 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted expon distribution with error=254.404064)\n",
      "2025-03-14 20:33:55.380 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted chi2 distribution with error=237.348868)\n",
      "2025-03-14 20:33:55.411 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted dgamma distribution with error=248.000469)\n",
      "2025-03-14 20:33:55.502 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted betaprime distribution with error=257.694481)\n",
      "2025-03-14 20:33:55.538 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted dweibull distribution with error=246.666009)\n",
      "2025-03-14 20:33:55.581 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted exponnorm distribution with error=254.407014)\n",
      "2025-03-14 20:33:55.666 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted crystalball distribution with error=264.747351)\n",
      "2025-03-14 20:33:55.717 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted foldnorm distribution with error=259.753435)\n",
      "2025-03-14 20:33:55.749 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted f distribution with error=257.500771)\n",
      "2025-03-14 20:33:55.798 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted burr distribution with error=257.521037)\n",
      "2025-03-14 20:33:55.834 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted erlang distribution with error=240.029394)\n",
      "2025-03-14 20:33:55.949 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted genextreme distribution with error=257.672109)\n",
      "2025-03-14 20:33:55.958 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted fisk distribution with error=231.478144)\n",
      "2025-03-14 20:33:55.977 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted exponpow distribution with error=229.805636)\n",
      "2025-03-14 20:33:56.062 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted genhalflogistic distribution with error=267.838794)\n",
      "2025-03-14 20:33:56.072 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted fatiguelife distribution with error=251.184445)\n",
      "2025-03-14 20:33:56.237 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted gennorm distribution with error=237.73208)\n",
      "2025-03-14 20:33:56.310 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted gamma distribution with error=234.91893)\n",
      "2025-03-14 20:33:56.353 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted foldcauchy distribution with error=249.70505)\n",
      "2025-03-14 20:33:56.373 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted gumbel_l distribution with error=268.620083)\n",
      "2025-03-14 20:33:56.391 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted gumbel_r distribution with error=258.554032)\n",
      "2025-03-14 20:33:56.406 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted geninvgauss distribution with error=239.582352)\n",
      "2025-03-14 20:33:56.423 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted halfcauchy distribution with error=255.71737)\n",
      "2025-03-14 20:33:56.435 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted gausshyper distribution with error=245.12087)\n",
      "2025-03-14 20:33:56.533 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted gibrat distribution with error=257.61481)\n",
      "/home/horvat/venvs/base/lib/python3.12/site-packages/scipy/stats/_continuous_distns.py:3935: IntegrationWarning: The integral is probably divergent, or slowly convergent.\n",
      "  intgrl = integrate.quad(llc, x0, x1,\n",
      "/home/horvat/venvs/base/lib/python3.12/site-packages/scipy/stats/_continuous_distns.py:3930: IntegrationWarning: The occurrence of roundoff error is detected, which prevents \n",
      "  the requested tolerance from being achieved.  The error may be \n",
      "  underestimated.\n",
      "  intgrl = (integrate.quad(llc, x0, mean,\n",
      "/home/horvat/venvs/base/lib/python3.12/site-packages/scipy/stats/_continuous_distns.py:3932: IntegrationWarning: The occurrence of roundoff error is detected, which prevents \n",
      "  the requested tolerance from being achieved.  The error may be \n",
      "  underestimated.\n",
      "  + integrate.quad(llc, mean, x1,\n",
      "2025-03-14 20:33:56.575 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted genhyperbolic distribution with error=245.164678)\n",
      "2025-03-14 20:33:56.602 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted halflogistic distribution with error=256.245072)\n",
      "2025-03-14 20:33:56.622 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted halfnorm distribution with error=258.5619)\n",
      "2025-03-14 20:33:56.669 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted hypsecant distribution with error=258.762999)\n",
      "2025-03-14 20:33:56.693 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted gengamma distribution with error=235.771945)\n",
      "2025-03-14 20:33:56.703 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted genpareto distribution with error=252.761329)\n",
      "2025-03-14 20:33:56.719 | WARNING  | fitter.fitter:_fit_single_distribution:337 - SKIPPED irwinhall distribution (taking more than 30 seconds)\n",
      "2025-03-14 20:33:56.744 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted genlogistic distribution with error=258.528863)\n",
      "2025-03-14 20:33:56.760 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted invgauss distribution with error=257.7781)\n",
      "2025-03-14 20:33:56.826 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted invweibull distribution with error=257.67325)\n",
      "2025-03-14 20:33:56.845 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted exponweib distribution with error=228.925939)\n",
      "2025-03-14 20:33:56.874 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted invgamma distribution with error=257.694761)\n",
      "2025-03-14 20:33:56.944 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted ksone distribution with error=264.198258)\n",
      "2025-03-14 20:33:56.990 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted halfgennorm distribution with error=252.407016)\n",
      "2025-03-14 20:33:57.065 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted kstwo distribution with error=273.936953)\n",
      "2025-03-14 20:33:57.105 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted laplace_asymmetric distribution with error=255.626631)\n",
      "2025-03-14 20:33:57.109 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted kappa3 distribution with error=263.816447)\n",
      "2025-03-14 20:33:57.132 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted levy_l distribution with error=270.854567)\n",
      "2025-03-14 20:33:57.144 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted jf_skew_t distribution with error=258.245018)\n",
      "2025-03-14 20:33:57.202 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted levy distribution with error=254.846367)\n",
      "2025-03-14 20:33:57.263 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted genexpon distribution with error=254.403929)\n",
      "2025-03-14 20:33:57.418 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted loggamma distribution with error=264.87209)\n",
      "2025-03-14 20:33:57.433 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted loguniform distribution with error=266.196831)\n",
      "2025-03-14 20:33:57.448 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted logistic distribution with error=261.415646)\n",
      "2025-03-14 20:33:57.500 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted maxwell distribution with error=262.830979)\n",
      "2025-03-14 20:33:57.543 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted loglaplace distribution with error=242.991951)\n",
      "2025-03-14 20:33:57.590 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted lognorm distribution with error=250.31023)\n",
      "2025-03-14 20:33:57.622 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted lomax distribution with error=254.283898)\n",
      "2025-03-14 20:33:57.665 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted moyal distribution with error=257.467214)\n",
      "2025-03-14 20:33:57.671 | WARNING  | fitter.fitter:_fit_single_distribution:337 - SKIPPED multivariate_normal distribution (taking more than 30 seconds)\n",
      "2025-03-14 20:33:57.781 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted kstwobign distribution with error=260.075598)\n",
      "2025-03-14 20:33:57.811 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted laplace distribution with error=255.026964)\n",
      "2025-03-14 20:33:57.831 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted norm distribution with error=264.747351)\n",
      "2025-03-14 20:33:57.884 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted nakagami distribution with error=235.680341)\n",
      "2025-03-14 20:33:57.934 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted mielke distribution with error=nan)\n",
      "2025-03-14 20:33:57.958 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted pareto distribution with error=253.999418)\n",
      "2025-03-14 20:33:58.028 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted johnsonsb distribution with error=247.967691)\n",
      "2025-03-14 20:33:58.074 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted norminvgauss distribution with error=252.821428)\n",
      "2025-03-14 20:33:58.113 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted powerlaw distribution with error=228.788255)\n",
      "2025-03-14 20:33:58.159 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted nct distribution with error=257.954933)\n",
      "2025-03-14 20:33:58.186 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted gompertz distribution with error=254.421467)\n",
      "2025-03-14 20:33:58.303 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted ncf distribution with error=259.757905)\n",
      "2025-03-14 20:33:58.437 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted johnsonsu distribution with error=257.60842)\n",
      "2025-03-14 20:33:58.487 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted pearson3 distribution with error=244.808457)\n",
      "2025-03-14 20:33:58.529 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted rdist distribution with error=265.747431)\n",
      "2025-03-14 20:33:58.577 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted reciprocal distribution with error=266.196831)\n",
      "2025-03-14 20:33:58.650 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted rice distribution with error=262.279322)\n",
      "2025-03-14 20:33:58.724 | WARNING  | fitter.fitter:_fit_single_distribution:337 - SKIPPED rv_continuous distribution (taking more than 30 seconds)\n",
      "2025-03-14 20:33:58.780 | WARNING  | fitter.fitter:_fit_single_distribution:337 - SKIPPED rv_histogram distribution (taking more than 30 seconds)\n",
      "2025-03-14 20:33:58.877 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted semicircular distribution with error=266.89682)\n",
      "2025-03-14 20:33:59.046 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted skewcauchy distribution with error=251.481887)\n",
      "2025-03-14 20:33:59.102 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted rel_breitwigner distribution with error=253.6705)\n",
      "2025-03-14 20:33:59.247 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted ncx2 distribution with error=243.782815)\n",
      "2025-03-14 20:33:59.301 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted kappa4 distribution with error=259.128948)\n",
      "2025-03-14 20:33:59.439 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted trapezoid distribution with error=273.102494)\n",
      "2025-03-14 20:33:59.505 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted skewnorm distribution with error=258.562341)\n",
      "2025-03-14 20:33:59.654 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted trapz distribution with error=273.102494)\n",
      "2025-03-14 20:33:59.673 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted powerlognorm distribution with error=235.582727)\n",
      "2025-03-14 20:33:59.699 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted uniform distribution with error=263.812567)\n",
      "2025-03-14 20:33:59.702 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted triang distribution with error=268.866815)\n",
      "2025-03-14 20:33:59.723 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted vonmises distribution with error=261.471366)\n",
      "2025-03-14 20:33:59.773 | WARNING  | fitter.fitter:_fit_single_distribution:337 - SKIPPED vonmises_fisher distribution (taking more than 30 seconds)\n",
      "2025-03-14 20:33:59.794 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted truncexpon distribution with error=259.128135)\n",
      "2025-03-14 20:33:59.842 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted wald distribution with error=257.730732)\n",
      "2025-03-14 20:33:59.943 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted truncnorm distribution with error=254.956151)\n",
      "2025-03-14 20:33:59.952 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted powernorm distribution with error=nan)\n",
      "2025-03-14 20:34:00.059 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted truncweibull_min distribution with error=254.473922)\n",
      "2025-03-14 20:34:00.145 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted truncpareto distribution with error=254.8769)\n",
      "2025-03-14 20:34:00.154 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted weibull_max distribution with error=259.075908)\n",
      "2025-03-14 20:34:00.165 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted rayleigh distribution with error=262.279322)\n",
      "2025-03-14 20:34:00.224 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted tukeylambda distribution with error=265.227373)\n",
      "2025-03-14 20:34:00.249 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted wrapcauchy distribution with error=254.180823)\n",
      "2025-03-14 20:34:00.372 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted weibull_min distribution with error=237.323195)\n",
      "2025-03-14 20:34:02.073 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted vonmises_line distribution with error=259.263683)\n",
      "2025-03-14 20:34:03.383 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted levy_stable distribution with error=251.281979)\n",
      "2025-03-14 20:34:05.811 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted recipinvgauss distribution with error=236.175895)\n",
      "/home/horvat/venvs/base/lib/python3.12/site-packages/scipy/integrate/_quadpack_py.py:1260: 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",
      "  quad_r = quad(f, low, high, args=args, full_output=self.full_output,\n",
      "/home/horvat/venvs/base/lib/python3.12/site-packages/scipy/integrate/_quadpack_py.py:1260: IntegrationWarning: The integral is probably divergent, or slowly convergent.\n",
      "  quad_r = quad(f, low, high, args=args, full_output=self.full_output,\n",
      "2025-03-14 20:34:29.136 | WARNING  | fitter.fitter:_fit_single_distribution:337 - SKIPPED studentized_range distribution (taking more than 30 seconds)\n",
      "2025-03-14 20:34:30.736 | INFO     | fitter.fitter:_fit_single_distribution:333 - Fitted t distribution with error=264.747349)\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>powerlaw</th>\n",
       "      <td>228.788255</td>\n",
       "      <td>452.604830</td>\n",
       "      <td>451.433144</td>\n",
       "      <td>inf</td>\n",
       "      <td>0.599354</td>\n",
       "      <td>0.030360</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>exponweib</th>\n",
       "      <td>228.925939</td>\n",
       "      <td>440.014005</td>\n",
       "      <td>438.451757</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>393.549340</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>502.115617</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>448.057662</td>\n",
       "      <td>inf</td>\n",
       "      <td>0.530632</td>\n",
       "      <td>0.076795</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "           sumsquare_error         aic         bic  kl_div  ks_statistic  \\\n",
       "powerlaw        228.788255  452.604830  451.433144     inf      0.599354   \n",
       "exponweib       228.925939  440.014005  438.451757     inf      0.403842   \n",
       "exponpow        229.805636  394.721026  393.549340     inf      0.388485   \n",
       "fisk            231.478144  503.287303  502.115617     inf      0.367344   \n",
       "gamma           234.918930  449.229349  448.057662     inf      0.530632   \n",
       "\n",
       "           ks_pvalue  \n",
       "powerlaw    0.030360  \n",
       "exponweib   0.298813  \n",
       "exponpow    0.340837  \n",
       "fisk        0.408087  \n",
       "gamma       0.076795  "
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "[encoded data, 35228 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "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": "base",
   "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.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
