Files
TD-R/TD1/Exercice56.R
Félix MARQUET a19eaf6684 fix: correct probability calculations for bus waiting times
- Corrected the calculation of P(10 <= X <= 15) to use the correct interval length.
- Corrected the calculation of P(25 <= X <= 30) to use the correct interval length.
- Corrected the calculation of P(0 < X < 5) to use the correct interval length.
- Corrected the calculation of P(15 < X < 20) to use the correct interval length.
2024-12-18 11:47:28 +01:00

27 lines
988 B
R
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# A partir de 7heures du matin, les bus passent toutes les quinze minutes à un arrêt
# précis. Un usager se présente à cet arrêt entre 7h et 7h30. On fait lhypothèse que lheure exacte de
# son arrivée, représentée par le nombre de minutes après 7h, est une variable aléatoire uniformément
# répartie sur lintervalle [0,30]. Quelle est la probabilité que lusager attende moins de cinq minutes le
# prochain bus ? Quil lattende plus de dix minutes ?
# Omega = [0;30]
# X(Omega) = [0;15]
temps_total <- 30
# Proba n'importe quel minute
p_min <- 1 / temps_total
# Calcul de P(10 <= X <= 15)
p10_X_15 <- (15-10) * p_min
# Calcul de P(25 <= X <= 30)
p25_X_30 <- (30-25) * p_min
# Calcul p_moins_5_min
p_moins_5_min <- p10_X_15 + p25_X_30
print(p_moins_5_min)
# Calcul de P(0 < X < 5)
p0_X_5 <- (5-(0+1)) * p_min
# Calcul de P(15 < X < 20)
p15_X_20 <- (20-(15+1)) * p_min
# Calcul p_plus_de_10_min
p_plus_de_10_min <- p0_X_5 + p15_X_10
print(p_plus_de_10_min)