Challenge: Solving Task Using Exponential Distribution
Tehtävä
Swipe to start coding
The average waiting time for a passing car on a rural road is 10
minutes. What is the probability of waiting more than 15
minutes for the next car if you have just seen another car?
We can solve this task using an exponential distribution. You have to:
- Calculate the probability of waiting less than
15
minutes. - Calculate the probability of waiting for the car for more than
15
minutes, taking into account the fact that the sum of the probabilities of all elementary outcomes is always equal to 1.
Ratkaisu
99
1
2
3
4
5
6
7
8
9
10
11
12
from scipy.stats import expon
# Mean waiting time
mean_waiting_time = 10
# Probability of waiting LESS then 15 minutes
proba_less = expon.cdf(15, scale=mean_waiting_time) - expon.cdf(0, scale=mean_waiting_time)
# Probability of waiting MORE then 15 minutes
probability = 1 - proba_less
# Print the probability
print(f'The probability of waiting more than 15 minutes is {probability:.4f}')
Oliko kaikki selvää?
Kiitos palautteestasi!
Osio 4. Luku 3
99
1
2
3
4
5
6
7
8
9
10
11
12
from scipy.stats import expon
# Mean waiting time
mean_waiting_time = 10
# Probability of waiting LESS then 15 minutes
proba_less = expon.___(15, scale=mean_waiting_time) - expon.cdf(0, scale=___)
# Probability of waiting MORE then 15 minutes
probability = ___ - proba_less
# Print the probability
print(f'The probability of waiting more than 15 minutes is {probability:.4f}')
Kysy tekoälyä
Kysy mitä tahansa tai kokeile jotakin ehdotetuista kysymyksistä aloittaaksesi keskustelumme