ukol 4
This commit is contained in:
parent
3362635612
commit
85823e5e3f
34
ukol.ipynb
34
ukol.ipynb
|
@ -272,7 +272,7 @@
|
|||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"show_distribution(survived)x, p_exp\n",
|
||||
"show_distribution(survived)\n",
|
||||
"show_distribution(perished)"
|
||||
]
|
||||
},
|
||||
|
@ -294,6 +294,38 @@
|
|||
"Porovnejte histogram simulovaných hodnot s pozorovanými daty."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "85df4788-b10c-48cd-aa08-10398d9c124a",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"def showRandomData(mean, std, dataset, title):\n",
|
||||
" data = np.random.normal(mean, std, 100)\n",
|
||||
" plt.figure(figsize=(10, 6))\n",
|
||||
" x = np.linspace(data.min() - 5, data.max() + 5, 100)\n",
|
||||
" p_norm = norm.pdf(x, mean, std)\n",
|
||||
" plt.plot(x, p_norm, 'black', linewidth = 2)\n",
|
||||
" plt.hist(data, bins = 10, color = \"blue\", alpha=0.5 , density = True)\n",
|
||||
" #plt.set_title(\"Náhodné hodnoty z normálního rozdělení\")\n",
|
||||
" plt.hist(dataset, bins = 10, color = \"green\", alpha=0.5, density = True)\n",
|
||||
" plt.show()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "c4466cb2-863a-4c61-8338-0f6a25014c6c",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"mean_survived, std_survived = norm.fit(survived)\n",
|
||||
"showRandomData(mean_survived, std_survived, survived, \"survived\")\n",
|
||||
"mean_perished, std_perished = norm.fit(perished)\n",
|
||||
"showRandomData(mean_perished, std_perished, survived, \"perished\")"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "d43bff73",
|
||||
|
|
Loading…
Reference in New Issue