Skip to content

Instantly share code, notes, and snippets.

@yostane
Created September 10, 2018 20:07
Show Gist options
  • Select an option

  • Save yostane/6ca193723bee06c21dc30e9ef35daafc to your computer and use it in GitHub Desktop.

Select an option

Save yostane/6ca193723bee06c21dc30e9ef35daafc to your computer and use it in GitHub Desktop.
Exercice 2.4 sur les files d'attente
# coding=utf-8
import math
import decimal
def B(s, a):
denom = 0
for i in range(0, s+1):
denom += float(decimal.Decimal(pow(a, i)) /
decimal.Decimal(math.factorial(i)))
numerateur = float(decimal.Decimal(pow(a, s)) /
decimal.Decimal(math.factorial(s)))
resultat = numerateur / denom
return resultat
def estimaerN(a, seuil):
N = 0
while True:
N += 1
Fn = B(N, a)
if Fn <= seuil:
break
return N
N = estimaerN(6.0, 0.01)
print("le nombre de personnes pour que la proba qu'elles soient toutes occupées est <= 0.01 est", N)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment