2024-10-18 18:42:33 +02:00
{
"cells": [
2024-10-19 13:46:09 +02:00
{
"cell_type": "markdown",
"id": "c88902ee",
"metadata": {},
"source": [
"# Úkol: BI-PST\n"
]
},
{
"cell_type": "markdown",
"id": "91241ee8",
"metadata": {},
"source": [
"Spolupracovali:\n",
" * Ondřej Hladůvka (reprezentant)\n",
" * Tomáš Kaňka"
]
},
2024-10-18 18:42:33 +02:00
{
"cell_type": "code",
2024-10-19 13:46:09 +02:00
"execution_count": 70,
"id": "334be38a",
2024-10-18 18:42:33 +02:00
"metadata": {},
"outputs": [],
2024-10-18 21:02:29 +02:00
"source": [
"#import csv\n",
"#import math\n",
"#import numpy as np\n",
2024-10-19 13:46:09 +02:00
"import matplotlib.pyplot as plt\n",
2024-10-18 21:02:29 +02:00
"import pandas as pd\n",
"#np.set_printoptions(precision=3)\n",
"#from sympy import *\n",
"#from scipy.stats import norm, uniform, expon, t\n",
"#from scipy.optimize import minimize"
]
},
{
"cell_type": "code",
2024-10-19 13:46:09 +02:00
"execution_count": 4,
2024-10-18 21:02:29 +02:00
"id": "7c90184c-5f76-4277-b0ad-aeec2ac37d30",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"10\n"
]
}
],
"source": [
"K = 28\n",
"L = 8\n",
"M = (((K + L) * 47) % 11) + 1\n",
"print(M)"
]
},
2024-10-19 13:46:09 +02:00
{
"cell_type": "markdown",
"id": "129f8693",
"metadata": {},
"source": [
"## Úloha č. 1"
]
},
2024-10-18 21:02:29 +02:00
{
"cell_type": "markdown",
"id": "503f77b6-1c9d-4406-8b30-ec3b792267e7",
"metadata": {},
"source": [
"(1b) Načtěte datový soubor a rozdělte sledovanou proměnnou na příslušné dvě pozorované skupiny.\n",
"Stručně popište data a zkoumaný problém. Pro každou skupinu zvlášť odhadněte střední hodnotu, rozptyl a medián příslušného rozdělení."
]
},
{
"cell_type": "code",
2024-10-19 13:46:09 +02:00
"execution_count": 58,
2024-10-18 21:02:29 +02:00
"id": "b80d5cec-db0c-42e7-a3b9-296803242269",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
2024-10-19 13:46:09 +02:00
"Prvních 5 řádků:\n",
" Weight Status\n",
"0 24.500000 survived\n",
"1 26.900000 survived\n",
"2 26.900000 survived\n",
"3 24.299999 survived\n",
"4 24.100000 survived\n",
"Info\n",
"Počet řádků: 59\n",
"Datové typy sloupců: Weight float64\n",
"Status object\n",
"dtype: object\n"
2024-10-18 21:02:29 +02:00
]
}
],
"source": [
2024-10-19 13:46:09 +02:00
"# načtení dat\n",
"df = pd.read_csv(\"/data.csv\")\n",
"df = df.drop(df.columns[0], axis=1)\n",
"# informace\n",
"print(\"Prvních 5 řádků:\")\n",
"print(df.head())\n",
"print(\"Info\")\n",
"print(\"Počet řádků:\", df.shape[0])\n",
"print(\"Datové typy sloupců:\",df.dtypes)\n",
"\n"
]
},
{
"cell_type": "markdown",
"id": "41e43831",
"metadata": {},
"source": [
"Tento datový soubor zkoumá, zda hmotnost dospělých samců vrabců hraje roli v jejich přežití během extrémních klimatických podmínek. Cílem je zjistit, zda vrabci, kteří přežili, měli významně jinou průměrnou hmotnost ve srovnání se vrabci, kteří zahynuli. \n",
"\n",
"Tabulak má dva sloupce weight a status, kde\n",
"**weight** udává hmotnost dospělých samců vrabců v gramech a\n",
"**status** udává, zda vrabec přežil nebo zahynul během zimní bouře. Může mít hodnoty \"survived\" (přežil) nebo \"perished\" (zahynul).\n"
]
},
{
"cell_type": "code",
"execution_count": 59,
"id": "717d3775",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Index(['Weight', 'Status'], dtype='object')\n",
" Status mean var median\n",
"0 perished 26.275000 2.168043 26.000000\n",
"1 survived 25.462857 1.584756 25.700001\n"
]
}
],
"source": [
"# Zobrazení názvů sloupců\n",
"print(df.columns)\n",
"\n",
"groups = df.groupby('Status')\n",
"summary_stats = groups['Weight'].agg(['mean', 'var', 'median']).reset_index()\n",
"\n",
"# Zobrazení výsledků\n",
"print(summary_stats)"
]
},
{
"cell_type": "markdown",
"id": "b370bf22",
"metadata": {},
"source": [
"## Úloha č. 2"
2024-10-18 21:02:29 +02:00
]
},
{
"cell_type": "markdown",
"id": "29eef015-c103-4e7f-89e8-2b59526f4b1e",
"metadata": {},
"source": [
"(1b) Pro každou skupinu zvlášť odhadněte hustotu a distribuční funkci pomocí histogramu a empirické distribuční funkce."
]
},
2024-10-19 13:46:09 +02:00
{
"cell_type": "code",
"execution_count": 72,
"id": "9c8f12d3",
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA04AAAIjCAYAAAA0vUuxAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8hTgPZAAAACXBIWXMAAA9hAAAPYQGoP6dpAACHv0lEQVR4nOzdd3xT9f7H8Xe6aUspu4xKQfZeMmUoGwRBrnBxsEREQNYVEZUlIooyRJaKiFzhxxIQFZGyhwzZogxBluwhFFo6aM7vj9wGSluahpTTtK/n49EHyfeMvJNvUvLp95zvsRiGYQgAAAAAkCIPswMAAAAAQEZH4QQAAAAAqaBwAgAAAIBUUDgBAAAAQCoonAAAAAAgFRROAAAAAJAKCicAAAAASAWFEwAAAACkgsIJAAAAAFJB4QQAgBO6du2qwMDAh/6469evl8Vi0fr16x/6Y2cUFotFI0eOTNM2DRs2VPny5dMn0D2cyQcg46NwApDhzZ49WxaLRTt37kx2eXp/IZo3b54mTZrk9PZRUVEaOXJkhv2iu3TpUrVo0UJ58uSRj4+PChYsqA4dOmjt2rX2dRK+rCf8+Pr6Kn/+/GrYsKHef/99Xbp0Kcl+E/otuZ8333zzYT5FAAAemJfZAQAgo5s3b54OHDigAQMGOLV9VFSURo0aJclW5GUUhmGoe/fumj17tqpUqaJBgwYpJCRE586d09KlS9WoUSNt2bJFderUsW/Tr18/PfbYY4qPj9elS5f0yy+/aMSIE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wcHavn27zp49m+ZtV6xYoZCQEHXq1Mne5u3trX79+unmzZvasGFDqvu4e1QiOjpaly9fVq1atSQp2cOM7ubp6WmfIMBqterq1au6ffu2qlevnuq2CYeyZc+ePdWMjgoMDNSNGzeStCfXb47w8vLSK6+8Yr/v4+OjV155RRcvXtSuXbsSrdulS5dEr+XOnTt18eJF9e7dO9H5MK1atVLp0qX1448/3vexg4OD9fvvv+vPP/9MNee6devUrFkzNWrUSEuWLJGvr69Dzy85BQsWVLt27ez3g4KC1LlzZ+3Zs0fnz5+/77aBgYF64YUX7Pd9fHxUo0YN/fXXX05ladiwoQzDcHhabUf6a9GiRSpTpoxKly6ty5cv238SJhW59zDTBg0aqGzZsqk+tqOfY0deI0czrlixQpJtwpS7OTuJDICMj0P1ALiNGjVqJDvJQM6cOR06DyM548aNU5cuXRQaGqpq1aqpZcuW6ty5s4oVK5bqtidPnlSJEiWSTEJQpkwZ+/LUXL16VaNGjdL8+fN18eLFRMuuX7+e6vZff/21xo8fr0OHDiU6ZPHeWezuFRQUJEnJFjrOunnzZrKFWEr9lpqCBQsqICAgUVvJkiUl2c4dSygwpaTPN+G1L1WqVJL9li5dWps3b77vY7/77rt6+umnVbJkSZUvX17NmzfXiy++mKRIj46OVqtWrVStWjUtXLjwgWd6K168eJLDM+9+ziEhISluW7hw4STb5syZU/v373+gTI5ypL/+/PNPHTx40H7e373u/Qyk9j5O4Ojn2JHXyNGMJ0+elIeHhx599NFEy5N7zwHIHCicAGQ6KZ0XFB8fn6StQ4cOqlevnpYuXapVq1bpo48+0ocffqglS5Y4dV5IWnXo0EG//PKLBg8erMqVKyswMFBWq1XNmzeX1Wq977bffPONunbtqrZt22rw4MHKly+fPD09NXbsWB07duy+25YuXVqS9Ntvv6lt27YP/Dzi4uJ05MgR06YZd+Z8ovupX7++jh07pu+++06rVq3SzJkzNXHiRM2YMUM9evSwr+fr66uWLVvqu+++08qVK/X
"text/plain": [
"<Figure size 1000x600 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
"--- Výsledky pro skupinu: perished ---\n",
" Weight CDF\n",
"0 24.600000 0.041667\n",
"1 24.600000 0.083333\n",
"2 24.900000 0.125000\n",
"3 25.000000 0.166667\n",
"4 25.000000 0.208333\n",
"5 25.100000 0.250000\n",
"6 25.500000 0.291667\n",
"7 25.600000 0.333333\n",
"8 25.600000 0.375000\n",
"9 25.799999 0.416667\n",
"10 25.900000 0.458333\n",
"11 26.000000 0.500000\n",
"12 26.000000 0.541667\n",
"13 26.000000 0.583333\n",
"14 26.000000 0.625000\n",
"15 26.100000 0.666667\n",
"16 26.500000 0.708333\n",
"17 26.500000 0.750000\n",
"18 27.100000 0.791667\n",
"19 27.500000 0.833333\n",
"20 27.600000 0.875000\n",
"21 28.299999 0.916667\n",
"22 28.299999 0.958333\n",
"23 31.100000 1.000000\n"
]
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA04AAAIjCAYAAAA0vUuxAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8hTgPZAAAACXBIWXMAAA9hAAAPYQGoP6dpAACLE0lEQVR4nOzdeZxN9R/H8fed3TbGPkZjkDXMEBGyZd+JCFlLKbtfKmWXaCE7RUjITsq+RhElS7JnbBl7DMbs5/fHbS7XzJiZ6457Z7yej8c83PM92+fe+53rfub7PZ9jMgzDEAAAAAAgUS6ODgAAAAAAnB2JEwAAAAAkgcQJAAAAAJJA4gQAAAAASSBxAgAAAIAkkDgBAAAAQBJInAAAAAAgCSROAAAAAJAEEicAAAAASAKJEwAANujcubMyZ8782M+7bds2mUwmbdu27bGfO63o3LmzChQo4JBzm0wmDRs2zCHnBpC6SJwAOL05c+bIZDLp999/T3B9jRo1VKpUqVQ7/4IFCzR+/Hib9w8LC9OwYcOc9ovuihUr1KBBA+XMmVMeHh7y8/NT69attWXLFss2cV/W4348PT2VJ08e1ahRQx9//LGuXLkS77hx71tCP++///7jfIoAADwyN0cHAADObsGCBTp06JD69u1r0/5hYWEaPny4JHOS5ywMw1DXrl01Z84clS1bVv3795evr69CQkK0YsUK1apVS7/88osqV65s2ad379567rnnFBMToytXrmjnzp0aOnSoxo0bp8WLF+vFF1+Md54RI0aoYMGCVm2pmeimd9WqVdPdu3fl4eHh6FCc1owZMxQbG+voMACkMyROAPCEGjt2rObMmaO+fftq3LhxMplMlnUffvihvv32W7m5Wf83UbVqVbVq1cqq7cCBA6pbt65atmypw4cPK2/evFbrGzRooPLly6feE3lAeHi4PDw85OKSPidVuLi4yMvLy9FhPFZ37txRpkyZkr29u7t7KkYD4EmVPv9XAfBEO336tEwmk+bMmRNv3YPXH9y6dUt9+/ZVgQIF5Onpqdy5c6tOnTr6448/JJlHiFavXq0zZ85Yppndf+3E5cuX9dprrylPnjzy8vJSUFCQvvnmG6tYcuXKJUkaPny45RhxMRw8eFCdO3dWoUKF5OXlJV9fX3Xt2lXXrl1L8nlGRkZqyJAhKleunLJmzapMmTKpatWq2rp1a5L73r17V6NHj1bx4sX1+eefWyVNcTp06KAKFSokeaygoCCNHz9eN27c0OTJk5PcPjnipl/u3btXlStXVoYMGVSwYEFNnz7daru4KYQLFy7UoEGDlC9fPmXMmFGhoaGSpCVLlqhcuXLKkCGDcubMqVdffVX//PNPkuePiorS8OHDVaRIEXl5eSlHjhx64YUXtHHjxofut3//fuXKlUs1atTQ7du3NWzYsARf27hpjKdPn7a0FShQQI0bN9aGDRtUpkwZeXl56ZlnntHy5csTfM73T/2Me70OHz6smjVrKmPGjMqXL58+/fTTJM+b2DHDwsJ09OhRXb169eEvlqQTJ06oZcuW8vX1lZeXl5566im98sorunnzpqSU/U7GvWaHDx9Wu3btlC1bNr3wwguWfnrmzJl4xxg4cKA8PDz077//SrK+xikqKkrZs2dXly5d4u0XGhoqLy8vvfPOO5a2iIgIDR06VIULF5anp6f8/f317rvvKiIiwmrfiIgI9evXT7ly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XzJkzlTNnTtWrV09TpkxJVv9N6rgPevnll+Xi4mJJgAzD0JIlS9SgQQNLn06Im5ubWrZsqe+//95yrdLy5csVFRVllTidOHFCf/31l3LlymX1E/ceXL58WZK
"text/plain": [
"<Figure size 1000x600 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
"--- Výsledky pro skupinu: survived ---\n",
" Weight CDF\n",
"0 23.200001 0.028571\n",
"1 23.600000 0.057143\n",
"2 23.700001 0.085714\n",
"3 23.799999 0.114286\n",
"4 23.900000 0.142857\n",
"5 24.100000 0.171429\n",
"6 24.200001 0.200000\n",
"7 24.299999 0.228571\n",
"8 24.299999 0.257143\n",
"9 24.500000 0.285714\n",
"10 24.600000 0.314286\n",
"11 24.700001 0.342857\n",
"12 24.700001 0.371429\n",
"13 24.799999 0.400000\n",
"14 24.900000 0.428571\n",
"15 25.400000 0.457143\n",
"16 25.600000 0.485714\n",
"17 25.700001 0.514286\n",
"18 25.700001 0.542857\n",
"19 25.700001 0.571429\n",
"20 25.700001 0.600000\n",
"21 25.900000 0.628571\n",
"22 26.200001 0.657143\n",
"23 26.200001 0.685714\n",
"24 26.299999 0.714286\n",
"25 26.299999 0.742857\n",
"26 26.500000 0.771429\n",
"27 26.600000 0.800000\n",
"28 26.700001 0.828571\n",
"29 26.700001 0.857143\n",
"30 26.900000 0.885714\n",
"31 26.900000 0.914286\n",
"32 27.000000 0.942857\n",
"33 27.900000 0.971429\n",
"34 28.000000 1.000000\n"
]
}
],
"source": [
"# Funkce pro výpočet hustoty a CDF\n",
"def calculate_density_cdf(group):\n",
" sorted_weights = group.sort_values('Weight')\n",
" \n",
" # Výpočet CDF\n",
" cdf = pd.Series(range(1, len(sorted_weights) + 1)) / len(sorted_weights)\n",
" \n",
" # Přidání CDF k seřazeným váhám\n",
" results = pd.DataFrame({'Weight': sorted_weights['Weight'].values, 'CDF': cdf.values})\n",
" \n",
" return results\n",
"\n",
"# Vytvoření hustoty a CDF pro každou skupinu\n",
"groups = df.groupby('Status')\n",
"density_cdf_results = {}\n",
"\n",
"for name, group in groups:\n",
" density_cdf_results[name] = calculate_density_cdf(group)\n",
"\n",
"# Zobrazení výsledků\n",
"for name, results in density_cdf_results.items():\n",
" plt.figure(figsize=(10, 6))\n",
" plt.hist(df[df['Status'] == name]['Weight'], bins=20, density=True, alpha=0.5, label=f'Hustota {name}')\n",
" \n",
" # CDF\n",
" plt.plot(results['Weight'], results['CDF'], label=f'CDF {name}', color='red')\n",
" \n",
" # Nastavení g\n",
" plt.title(f'Hustota a CDF pro skupinu: {name}')\n",
" plt.xlabel('Hmotnost')\n",
" plt.ylabel('Hustota / Kumulativní pravděpodobnost (CDF)')\n",
" plt.legend()\n",
" plt.grid()\n",
" plt.show()\n",
" print(f\"\\n--- Výsledky pro skupinu: {name} ---\")\n",
" print(results)\n",
"\n",
"\n"
]
},
{
"cell_type": "markdown",
"id": "f98f6ad6",
"metadata": {},
"source": [
"Vytvořili jsme funkci calculate_density_cdf, která seřadila data podle hmotnosti a spočítala kumulativní distribuční funkci. Tato funkce vrátila DataFrame se seřazenými hmotnostmi a odpovídajícími hodnotami CDF."
]
},
{
"cell_type": "markdown",
"id": "9f9b7946",
"metadata": {},
"source": [
"## Úloha č. 3"
]
},
2024-10-18 21:02:29 +02:00
{
"cell_type": "markdown",
"id": "626d8bce-65af-4659-96e9-c1fbe4ccb3cc",
"metadata": {},
"source": [
"(3b) Pro každou skupinu zvlášť najděte nejbližší rozdělení: \n",
"Odhadněte parametry normálního, exponenciálního a rovnoměrného rozdělení.\n",
"Zaneste příslušné hustoty s odhadnutými parametry do grafů histogramu. Diskutujte, které z rozdělení odpovídá pozorovaným datům nejlépe."
]
},
2024-10-19 13:46:09 +02:00
{
"cell_type": "markdown",
"id": "424b6dc3",
"metadata": {},
"source": [
"## Úloha č. 4"
]
},
2024-10-18 21:02:29 +02:00
{
"cell_type": "markdown",
"id": "6226456c-fdf3-4537-830c-05f8ee7022c5",
"metadata": {},
"source": [
"(1b) Pro každou skupinu zvlášť vygenerujte náhodný výběr o 100 hodnotách z rozdělení, \n",
"které jste zvolili jako nejbližší, s parametry odhadnutými v předchozím bodě.\n",
"Porovnejte histogram simulovaných hodnot s pozorovanými daty."
]
},
2024-10-19 13:46:09 +02:00
{
"cell_type": "markdown",
"id": "d43bff73",
"metadata": {},
"source": [
"## Úloha č. 5"
]
},
2024-10-18 21:02:29 +02:00
{
"cell_type": "markdown",
"id": "1c5f7d31-ca21-42b4-9a23-1111bbf599b9",
"metadata": {},
"source": [
"(1b) Pro každou skupinu zvlášť spočítejte oboustranný 95% konfidenční interval pro střední hodnotu."
]
},
2024-10-19 13:46:09 +02:00
{
"cell_type": "markdown",
"id": "1c7cf77b",
"metadata": {},
"source": [
"## Úloha č. 6"
]
},
2024-10-18 21:02:29 +02:00
{
"cell_type": "markdown",
"id": "53a61e4f-fc67-4237-ab38-f5f9fb7767c5",
"metadata": {},
"source": [
"(1b) Pro každou skupinu zvlášť otestujte na hladině významnosti 5 % hypotézu,\n",
"zda je střední hodnota rovná hodnotě K (parametr úlohy), proti oboustranné alternativě.\n",
"Můžete použít buď výsledek z předešlého bodu, nebo výstup z příslušné vestavěné funkce vašeho softwaru."
]
},
2024-10-19 13:46:09 +02:00
{
"cell_type": "markdown",
"id": "617cf82f",
"metadata": {},
"source": [
"## Úloha č. 7"
]
},
2024-10-18 21:02:29 +02:00
{
"cell_type": "markdown",
"id": "7007c195-97a3-4cd4-8427-dcc8417eedf8",
"metadata": {},
"source": [
"(2b) Na hladině významnosti 5 % otestujte, jestli mají pozorované skupiny stejnou střední hodnotu.\n",
"Typ testu a alternativy stanovte tak, aby vaše volba nejlépe korespondovala s povahou zkoumaného problému."
]
2024-10-18 18:42:33 +02:00
}
],
"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.15"
}
},
"nbformat": 4,
"nbformat_minor": 5
}