From 85823e5e3f6ef7f9d19a678530b5398e452928b3 Mon Sep 17 00:00:00 2001 From: Hladu357 Date: Sat, 19 Oct 2024 21:05:37 +0200 Subject: [PATCH] ukol 4 --- ukol.ipynb | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/ukol.ipynb b/ukol.ipynb index d4f3bdb..43947ed 100644 --- a/ukol.ipynb +++ b/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",