Valid Probability Model Practice Problem
This data science coding problem helps you practice Probability Fundamentals, valid probability model, and implementation skills. Read the problem statement, write your solution, and strengthen your understanding of Probability Fundamentals.
- Problem ID: 226
- Problem key: 226-valid-probability-model
- URL: https://datacrack.app/solve/226-valid-probability-model
- Difficulty: easy
- Topic: Probability Fundamentals
- Module: Probability
Problem Statement
# 🧩 Valid Probability Model
---
### 🎯 Goal
Decide whether a list of probabilities forms a valid probability model.
---
### 📖 Introduction
A probability model assigns probabilities to all possible outcomes.
For a probability model to be valid, it must satisfy the basic probability axioms:
1. Every probability must be between 0 and 1:
$$
0 \leq P(A) \leq 1
$$
2. The probability of the entire sample space must be 1:
$$
P(\Omega)=1
$$
So if we assign probabilities to every possible outcome, they must add up to 1.
3. Probabilities of mutually exclusive outcomes can be added.
For this problem, we mainly use the first two rules to check whether a list of probabilities forms a valid model.
An empty list is not a valid probability model because it does not describe any possible outcomes.
So this is valid:
```python
[0.2, 0.3, 0.5]
```
because every probability is between 0 and 1 and:
$$
0.2+0.3+0.5=1
$$
This is not valid:
```python
[0.2, 0.5, 0.6]
```
because the probabilities add up to 1.3.
---
### 📥 Input
- `probabilities`: a list of probability values.
### 📤 Output
- Return `True` if the list is a valid probability model.
- Return `False` otherwise.
---
### 💻 Task
Implement `is_valid_probability_model(probabilities)`.
---
### 🧩 Starter Code
```python
def is_valid_probability_model(probabilities):
pass
```
---
### 💡 Example
```python
is_valid_probability_model([0.2, 0.3, 0.5])
```
Expected output:
```python
True
```
---
### ⚠️ Common Mistakes
- Checking only that the sum is 1 but ignoring negative values.
- Checking only that values are positive but ignoring the total.
- Requiring exact floating-point equality without tolerance.
Starter Code
def is_valid_probability_model(probabilities):
pass