From bf071fd178eab4db039f3aab62ca32495c53c380 Mon Sep 17 00:00:00 2001 From: dathomasss Date: Wed, 8 Jan 2025 21:44:02 +0100 Subject: [PATCH] week5 lab3 done --- lab-intro-probability.ipynb | 186 ++++++++++++++++++++++++++++++------ 1 file changed, 159 insertions(+), 27 deletions(-) diff --git a/lab-intro-probability.ipynb b/lab-intro-probability.ipynb index 5893fc1..88cca79 100644 --- a/lab-intro-probability.ipynb +++ b/lab-intro-probability.ipynb @@ -38,11 +38,27 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 12, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "0.8844772466215431" + ] + }, + "execution_count": 12, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "#code here" + "from scipy.stats import binom, norm\n", + "n = 460\n", + "p = 0.97\n", + "binom_ = binom(n, p)\n", + "proba = binom_.cdf(450)\n", + "\n" ] }, { @@ -72,11 +88,29 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 24, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "0.49" + ] + }, + "execution_count": 24, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "#code here" + "from scipy.stats import geom\n", + "\n", + "p = 0.3\n", + "geom_p = geom(p)\n", + "proba = 1 - (geom_p.cdf(2))\n", + "proba\n", + "\n", + "\n" ] }, { @@ -107,11 +141,28 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 30, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "0.01289822084039205" + ] + }, + "execution_count": 30, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "#code here" + "from scipy.stats import poisson\n", + "#p(x > 550)\n", + "\n", + "m = 500\n", + "poiss = poisson(m)\n", + "proba = 1 - poiss.cdf(550)\n", + "proba" ] }, { @@ -123,11 +174,27 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 38, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "1.0" + ] + }, + "execution_count": 38, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "#code here" + "from scipy.stats import expon\n", + "\n", + "lambda_ = 500 * 24\n", + "poiss = poisson(lambda_)\n", + "proba_result = 1 - poiss.cdf(550)\n", + "proba_result" ] }, { @@ -157,10 +224,26 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 42, "metadata": {}, - "outputs": [], - "source": [] + "outputs": [ + { + "data": { + "text/plain": [ + "0.3934693402873666" + ] + }, + "execution_count": 42, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "lambdda = 0.1\n", + "la = expon(scale= 1/lambdda)\n", + "result = la.cdf(5)\n", + "result" + ] }, { "cell_type": "markdown", @@ -173,10 +256,26 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 44, "metadata": {}, - "outputs": [], - "source": [] + "outputs": [ + { + "data": { + "text/plain": [ + "0.7768698398515702" + ] + }, + "execution_count": 44, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "lambdda = 0.1\n", + "la = expon(scale= 1/lambdda)\n", + "result = la.cdf(15)\n", + "result" + ] }, { "cell_type": "markdown", @@ -196,11 +295,27 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 46, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "0.6826894921370859" + ] + }, + "execution_count": 46, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "#code here" + "mean = 150\n", + "std = 10\n", + "\n", + "norm_dist = norm(loc=mean,scale=std)\n", + "proba = norm_dist.cdf(160) - norm_dist.cdf(140)\n", + "proba" ] }, { @@ -219,17 +334,34 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 50, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "0.4511883639059735" + ] + }, + "execution_count": 50, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "#code here" + "mean_during = 50\n", + "panne = 30\n", + "\n", + "lambda2 = 1 / mean_during\n", + "lambda2_inv = expon(scale= 1/lambda2)\n", + "lambda2_inv.cdf(30)\n", + "\n" ] } ], "metadata": { "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -243,9 +375,9 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.9" + "version": "3.12.7" } }, "nbformat": 4, - "nbformat_minor": 2 + "nbformat_minor": 4 }