From ea487340a9dcce33ace5d443d1469406be4faf88 Mon Sep 17 00:00:00 2001 From: andressa Date: Sun, 15 Feb 2026 15:27:14 +0000 Subject: [PATCH] lab.probability --- lab-intro-probability.ipynb | 225 ++++++++++++++++++++++++++++++++---- 1 file changed, 201 insertions(+), 24 deletions(-) diff --git a/lab-intro-probability.ipynb b/lab-intro-probability.ipynb index 5893fc1..4a3acd6 100644 --- a/lab-intro-probability.ipynb +++ b/lab-intro-probability.ipynb @@ -38,11 +38,35 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 1, "metadata": {}, "outputs": [], "source": [ - "#code here" + "from scipy.stats import binom\n" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "np.float64(0.8844772466215439)" + ] + }, + "execution_count": 6, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "n = 460\n", + "p = 0.03\n", + "\n", + "binom_dist = binom(n,p)\n", + "1- binom_dist.cdf(9)" ] }, { @@ -72,11 +96,24 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 7, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The probability is 0.9409\n" + ] + } + ], "source": [ - "#code here" + "from scipy.stats import geom\n", + "\n", + "p = 0.03\n", + "geom_dist = geom(p)\n", + "\n", + "print(f\"The probability is {1 - geom_dist.cdf(2):.4f}\")\n" ] }, { @@ -107,11 +144,26 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": null, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The probability that the call center becames overwhelmed is 0.01289822084039205\n" + ] + } + ], "source": [ - "#code here" + "from scipy.stats import poisson\n", + "\n", + "mu = 500\n", + "poisson_dist = poisson(mu)\n", + "\n", + "p = 1 - poisson_dist.cdf(550)\n", + "\n", + "print(\"The probability that becames overwhelmed is \", p)\n" ] }, { @@ -123,11 +175,63 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": null, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "np.float64(0.987101779159608)" + ] + }, + "execution_count": 17, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "p\n", + "p_sucess = 1 - p\n", + "p_sucess\n" + ] + }, + { + "cell_type": "code", + "execution_count": 18, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "0.9013541807778029" + ] + }, + "execution_count": 18, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "0.987101779159608**8" + ] + }, + { + "cell_type": "code", + "execution_count": 22, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The probability of being overwhelmed in 8 hours is 0.9013541807778032\n" + ] + } + ], "source": [ - "#code here" + "binom_dist = binom(8, p)\n", + "\n", + "print(\"The probability of being overwhelmed in 8 hours is \",binom_dist.pmf(0))" ] }, { @@ -157,10 +261,29 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 23, "metadata": {}, - "outputs": [], - "source": [] + "outputs": [ + { + "data": { + "text/plain": [ + "np.float64(0.3934693402873666)" + ] + }, + "execution_count": 23, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "from scipy.stats import expon\n", + "\n", + "\n", + "mu = 10\n", + "expon_dist = expon(scale = mu)\n", + "\n", + "expon_dist.cdf(5)" + ] }, { "cell_type": "markdown", @@ -173,10 +296,25 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 24, "metadata": {}, - "outputs": [], - "source": [] + "outputs": [ + { + "data": { + "text/plain": [ + "np.float64(0.30695937991355843)" + ] + }, + "execution_count": 24, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "mu = 15\n", + "expon_dist = expon(scale = 15)\n", + "expon_dist.cdf(5.5)" + ] }, { "cell_type": "markdown", @@ -196,11 +334,36 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 30, "metadata": {}, "outputs": [], "source": [ - "#code here" + "from scipy.stats import norm\n", + "\n", + "loc = 150\n", + "scale = 10\n", + "\n", + "norm_dist = norm(loc=loc, scale=scale)" + ] + }, + { + "cell_type": "code", + "execution_count": 32, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "np.float64(0.6826894921370859)" + ] + }, + "execution_count": 32, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "norm_dist.cdf(160) - norm_dist.cdf(140)" ] }, { @@ -219,17 +382,31 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 33, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "np.float64(0.4511883639059735)" + ] + }, + "execution_count": 33, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "#code here" + "mu = 50\n", + "\n", + "expon_dist = expon(scale=mu)\n", + "expon_dist.cdf(30)" ] } ], "metadata": { "kernelspec": { - "display_name": "Python 3", + "display_name": "base", "language": "python", "name": "python3" }, @@ -243,7 +420,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.9" + "version": "3.13.9" } }, "nbformat": 4,