Use Python or Matlab to produce the solution for the following problems. Calculate the probability that individual has at least two violations. Calculate the expected value and variance of number of violations. Suppose an individual with X violations incurs a surcharge of $30X+$50. Calculate the expected amount of the surcharge, and the variance
Use Python or Matlab to produce the solution for the following problems.
- Calculate the probability that individual has at least two violations.
- Calculate the expected value and variance of number of violations.
- Suppose an individual with X violations incurs a surcharge of $30X+$50. Calculate the expected amount of the surcharge, and the variance.
1. Initialize the probabilities list with the given probabilities: [0.2, 0.2, 0.2, 0.2, 0.2].
2. Problem 1: Calculate the probability that the individual has at least two violations:
- Set prob_at_least_two_violations as the sum of probabilities from index 2 to 4 (inclusive).
- Output prob_at_least_two_violations.
3. Problem 2: Calculate the expected value and variance of the number of violations:
- Set expected_value as the sum of (i * probabilities[i]) for each index i from 0 to 4.
- Set variance as the sum of (((i - expected_value) ** 2) * probabilities[i]) for each index i from 0 to 4.
- Output expected_value and variance.
4. Problem 3: Calculate the expected amount of the surcharge and the variance:
- Set expected_surcharge as the sum of ((30 * i + 50) * probabilities[i]) for each index i from 0 to 4.
- Set variance_surcharge as the sum of ((((30 * i + 50) - expected_surcharge) ** 2) * probabilities[i]) for each index i from 0 to 4.
- Output expected_surcharge and variance_surcharge.
5. End.
Step by step
Solved in 4 steps with 2 images