Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
176 changes: 150 additions & 26 deletions lab-intro-probability.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,28 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 6,
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/plain": [
"np.float64(0.8844772466215431)"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"#code here"
"from scipy.stats import binom\n",
"n = 460 \n",
"p = 0.97\n",
"\n",
"binom_dist = binom(n,p)\n",
"\n",
"binom_dist.cdf(450)"
]
},
{
Expand Down Expand Up @@ -72,11 +89,27 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 9,
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/plain": [
"np.float64(0.49)"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"#code here"
"from scipy.stats import geom\n",
"p = 0.3\n",
"geom_dist = geom(p)\n",
"\n",
"1 - geom_dist.cdf(2)\n",
"\n"
]
},
{
Expand Down Expand Up @@ -107,11 +140,24 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 13,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"0.01289822084039205\n"
]
}
],
"source": [
"#code here"
"from scipy.stats import poisson\n",
"\n",
"mu = 500\n",
"poisson_dist = poisson(mu)\n",
"probability = 1 - poisson_dist.cdf(550)\n",
"print(probability)"
]
},
{
Expand All @@ -123,11 +169,21 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 15,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"0.2677043869515713\n"
]
}
],
"source": [
"#code here"
"binom_dist = binom(24, probability)\n",
"probability_day = 1 - binom_dist.pmf(0)\n",
"print(probability_day)"
]
},
{
Expand Down Expand Up @@ -157,10 +213,28 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 17,
"metadata": {},
"outputs": [],
"source": []
"outputs": [
{
"data": {
"text/plain": [
"np.float64(0.3934693402873666)"
]
},
"execution_count": 17,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"from scipy.stats import expon\n",
"\n",
"mu = 10 \n",
"expon_dist = expon(scale = mu)\n",
"\n",
"expon_dist.cdf(5)"
]
},
{
"cell_type": "markdown",
Expand All @@ -173,10 +247,24 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 20,
"metadata": {},
"outputs": [],
"source": []
"outputs": [
{
"data": {
"text/plain": [
"np.float64(0.2231301601484298)"
]
},
"execution_count": 20,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"prob_break = 1 - expon_dist.cdf(15)\n",
"prob_break"
]
},
{
"cell_type": "markdown",
Expand All @@ -196,11 +284,27 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 24,
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/plain": [
"np.float64(0.6826894921370859)"
]
},
"execution_count": 24,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"#code here"
"from scipy.stats import norm \n",
"loc = 150\n",
"scale = 10\n",
"\n",
"norm_dist = norm(loc=loc, scale = scale)\n",
"norm_dist.cdf(160) - norm_dist.cdf(140) \n"
]
},
{
Expand All @@ -219,17 +323,37 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 28,
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/plain": [
"np.float64(0.4511883639059735)"
]
},
"execution_count": 28,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"#code here"
"scale = 50\n",
"expon_dist = expon(scale=scale)\n",
"expon_dist.cdf(30)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"display_name": "base",
"language": "python",
"name": "python3"
},
Expand All @@ -243,7 +367,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.9"
"version": "3.13.9"
}
},
"nbformat": 4,
Expand Down