Skip to content
Open
Show file tree
Hide file tree
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
58 changes: 27 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,54 +1,50 @@
![logo_ironhack_blue 7](https://user-images.githubusercontent.com/23629340/40541063-a07a0a8a-601a-11e8-91b5-2f13e4e6b441.png)

# Lab | Introduction to Probability
# Laboratorio | Introducción a la Probabilidad

<details>
<summary>
<h2>Learning Goals</h2>
</summary>
<summary>
<h2>Objetivos de Aprendizaje</h2>
</summary>

This exercise allows you to practice and apply the concepts and techniques taught in class.
Este ejercicio te permite practicar y aplicar los conceptos y técnicas enseñados en clase.

Upon completion of this exercise, you will be able to:

- Identify different probabilities distributions.
- Calculate pmf/cdf for given problems.

<br>
<hr>
Al completar este ejercicio, podrás:

</details>

<details>
<summary>
<h2>Prerequisites</h2>
</summary>
Before this starting this lab, you should have learnt about:

- Basic Probabilities concepts.
- Understand difference between distributions and where/how to apply them in a business context.
- Identificar diferentes distribuciones de probabilidad.
- Calcular pmf/cdf para problemas dados.

<br>
<hr>
<br>
<hr>

</details>

## Introduction
<details>
<summary>
<h2>Requisitos Previos</h2>
</summary>
Antes de comenzar este laboratorio, deberías haber aprendido sobre:

In this exercise, you will have the opportunity to dive into one of the fundamental of probability.
- Conceptos básicos de probabilidad.
- Entender la diferencia entre distribuciones y dónde/cómo aplicarlas en un contexto empresarial.

<br>
<hr>

**Happy coding!** :heart:
</details>

## Introducción

En este ejercicio, tendrás la oportunidad de profundizar en uno de los fundamentos de la probabilidad.

<br>

## Getting Started
**¡Feliz programación!** :heart:

Complete the challenges in the notebook. Follow the instructions and add your code and explanations as necessary.
## Comenzando

Completa los desafíos en el cuaderno. Sigue las instrucciones y agrega tu código y explicaciones según sea necesario.

## Submission
## Entrega

- Submit your solutions in the Student Portal.
- Envía tus soluciones en el Portal del Estudiante.
186 changes: 161 additions & 25 deletions lab-intro-probability.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,39 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 1,
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/plain": [
"(np.float64(0.884477246621543), np.float64(88.4477246621543))"
]
},
"execution_count": 1,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"#code here"
"from scipy.stats import binom\n",
"\n",
"n = 460 # tickets vendidos\n",
"p = 0.03 # prob. de no presentarse\n",
"\n",
"# P(X >= 10) donde X ~ Bin(n, p)\n",
"prob_seats_for_all = binom.sf(9, n, p) # sf(9) = P(X > 9) = P(X >= 10)\n",
"\n",
"prob_seats_for_all, prob_seats_for_all*100\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"✅ Si venden 460 tickets, hay ~88.45% de chances de que al menos 10 no se presenten, y entonces entran todos en los 450 asientos.\n",
"\n",
"✅ El riesgo de overbooking real sería el complemento: 1 − 0.8844772466 = 0.1155227534 → 11.55%."
]
},
{
Expand Down Expand Up @@ -72,11 +100,24 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 2,
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/plain": [
"(0.48999999999999994, 48.99999999999999)"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"#code here"
"p = 0.3\n",
"prob_at_least_3_attempts = (1 - p)**2\n",
"prob_at_least_3_attempts, prob_at_least_3_attempts*100\n"
]
},
{
Expand Down Expand Up @@ -107,11 +148,29 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 3,
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/plain": [
"(np.float64(0.012898220840392027), np.float64(1.2898220840392027))"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"#code here"
"from scipy.stats import poisson\n",
"\n",
"lam = 500\n",
"\n",
"# P(X > 550) = sf(550)\n",
"p_overwhelmed_1h = poisson.sf(550, lam)\n",
"\n",
"p_overwhelmed_1h, p_overwhelmed_1h*100\n"
]
},
{
Expand All @@ -123,11 +182,24 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 4,
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/plain": [
"(np.float64(0.2677043869515715), np.float64(26.77043869515715))"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"#code here"
"p_overwhelmed_day = 1 - (1 - p_overwhelmed_1h)**24\n",
"\n",
"p_overwhelmed_day, p_overwhelmed_day*100\n"
]
},
{
Expand Down Expand Up @@ -157,10 +229,30 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": []
"outputs": [
{
"data": {
"text/plain": [
"(0.3934693402873666, 39.346934028736655)"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import math\n",
"\n",
"lam = 1/10 # tasa por minuto\n",
"t = 5\n",
"\n",
"p_within_5 = 1 - math.exp(-lam*t)\n",
"\n",
"p_within_5, p_within_5*100\n"
]
},
{
"cell_type": "markdown",
Expand All @@ -173,10 +265,27 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 7,
"metadata": {},
"outputs": [],
"source": []
"outputs": [
{
"data": {
"text/plain": [
"(0.22313016014842982, 22.313016014842983)"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"t = 15\n",
"\n",
"p_break = math.exp(-lam*t)\n",
"\n",
"p_break, p_break*100\n"
]
},
{
"cell_type": "markdown",
Expand All @@ -196,11 +305,26 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 8,
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/plain": [
"292201338"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"#code here"
"import math\n",
"\n",
"total_combinations = math.comb(69, 5) * math.comb(26, 1)\n",
"\n",
"total_combinations\n"
]
},
{
Expand All @@ -219,11 +343,23 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 9,
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/plain": [
"(3.4222978130237033e-09, 3.4222978130237034e-07)"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"#code here"
"prob_win = 1 / total_combinations\n",
"prob_win, prob_win*100\n"
]
}
],
Expand All @@ -243,7 +379,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.9"
"version": "3.14.0"
}
},
"nbformat": 4,
Expand Down