diff --git a/lab-intro-probability.ipynb b/lab-intro-probability.ipynb index 5893fc1..a2d4d65 100644 --- a/lab-intro-probability.ipynb +++ b/lab-intro-probability.ipynb @@ -38,11 +38,26 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 1, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "0.8844772466215431\n" + ] + } + ], "source": [ - "#code here" + "from scipy.stats import binom\n", + "\n", + "n = 460\n", + "p = 0.97\n", + "\n", + "prob = binom.cdf(450, n, p)\n", + "\n", + "print(prob)" ] }, { @@ -72,11 +87,26 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 2, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "0.49\n" + ] + } + ], "source": [ - "#code here" + "from scipy.stats import geom\n", + "\n", + "p = 0.3\n", + "\n", + "# P(X >= 3) = 1 - P(X <= 2)\n", + "prob = 1 - geom.cdf(2, p)\n", + "\n", + "print(prob)" ] }, { @@ -107,11 +137,26 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 3, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "0.01289822084039205\n" + ] + } + ], "source": [ - "#code here" + "from scipy.stats import poisson\n", + "\n", + "lam = 500\n", + "\n", + "# P(X > 550) = 1 - P(X ≤ 550)\n", + "prob = 1 - poisson.cdf(550, lam)\n", + "\n", + "print(prob)" ] }, { @@ -157,10 +202,27 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 6, "metadata": {}, - "outputs": [], - "source": [] + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "0.3934693402873666\n" + ] + } + ], + "source": [ + "import numpy as np\n", + "\n", + "lam = 1/10\n", + "t = 5\n", + "\n", + "prob = 1 - np.exp(-lam * t)\n", + "\n", + "print(prob)" + ] }, { "cell_type": "markdown", @@ -173,10 +235,27 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 7, "metadata": {}, - "outputs": [], - "source": [] + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "0.22313016014842982\n" + ] + } + ], + "source": [ + "import numpy as np\n", + "\n", + "lam = 1/10 \n", + "t = 15\n", + "\n", + "prob = np.exp(-lam * t)\n", + "\n", + "print(prob)" + ] }, { "cell_type": "markdown", @@ -196,11 +275,26 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 8, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "0.6826894921370859\n" + ] + } + ], "source": [ - "#code here" + "from scipy.stats import norm\n", + "\n", + "mu = 150\n", + "sigma = 10\n", + "\n", + "prob = norm.cdf(160, mu, sigma) - norm.cdf(140, mu, sigma)\n", + "\n", + "print(prob)" ] }, { @@ -219,17 +313,39 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 9, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "0.4511883639059735\n" + ] + } + ], "source": [ - "#code here" + "import numpy as np\n", + "\n", + "lam = 1/50 \n", + "t = 30\n", + "\n", + "prob = 1 - np.exp(-lam * t)\n", + "\n", + "print(prob)" ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] } ], "metadata": { "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -243,9 +359,9 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.9" + "version": "3.13.9" } }, "nbformat": 4, - "nbformat_minor": 2 + "nbformat_minor": 4 }