Question 2
(ns assignments.hw2.q2
(:require
[assignments.hw2.utils :refer :all]
[fastmath.core :as m]))Consider three types of students: male, wearing glasses, senior in a high school.
2.1) If a principal claims that P(male)=0.45; P(glasses)=0.4; P(senior)=0.24, can that be a legitimate probability assignment? Explain
To determine if this is a legitimate probability assignment, we need to check if the sum of probabilities is less than or equal to 1.
(let [p-male 0.45 p-glasses 0.4 p-senior 0.24
total-prob (+ p-male p-glasses p-senior)]
(answer
(str "Sum of probabilities: " (m/approx total-prob 2))))Sum of probabilities: 1.09
This is not a legitimate probability assignment because:
These events (being male, wearing glasses, and being a senior) are not mutually exclusive. A student can belong to more than one category.
For non-mutually exclusive events, simply adding individual probabilities can result in a sum greater than 1, which is what we see here.
This sum exceeding 1 violates the rule of probability for mutually exclusive events.
2.2) How to assign a probability to students in the high school so that the statement of the principal is valid?
To assign probabilities that make the principal’s statement valid, we need to consider the following:
The given probabilities are for individual characteristics, not mutually exclusive events.
We need to account for overlaps between these characteristics.
We can use the principle of inclusion-exclusion to calculate the probability of a student having at least one of these characteristics
(comment
(defn probability-at-least-one
"Calculate the probability of at least one event occurring using inclusion-exclusion. Assumes independence between events.
Parameters:
probs - A collection of individual probabilities.
Returns:
The probability of at least one event occurring."
[probs]
(let [p-none (reduce * (map #(- 1 %) probs))]
(- 1 p-none))))(let [p-male 0.45 p-glasses 0.4 p-senior 0.24
p-at-least-one (probability-at-least-one [p-male p-glasses p-senior])]
(answer
(str
"P(male OR glasses OR senior) = " (m/approx p-at-least-one 4) "; "
"P(none of the characteristics) = " (m/approx (- 1 p-at-least-one) 4))))P(male OR glasses OR senior) = 0.7492; P(none of the characteristics) = 0.2508
This assignment is valid because:
- It maintains the individual probabilities stated by the principal.
- It accounts for potential overlaps between categories.
- The total probability for all students (with and without these characteristics) equals 1.
To make the principal’s statement valid, we need to interpret these probabilities as the chance of a student having at least one of these characteristics. The probability that a student has none of these characteristics is the complement of the probability calculated above.
Note: This calculation assumes independence between the characteristics, which may not reflect reality. In practice, there could be correlations between these traits that would require more detailed data to model accurately.
source: src/assignments/hw2/q2.clj