1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
| from numpy import random
import math
import numpy as np
import matplotlib.pyplot as plt
from numpy import sqrt
from numpy import abs
######
def partie2():
#Simule le déroulement d'une partie d'un joueur et renvoie le gain du casino
n1=random.randint(1,37) # numéros du croupier
n2=random.randint(1,37) # numéros possibles de mise
g=mise()
if n1==n2:
g1=-35*g
else:
g1= g
return g1
partie2()
###
def attente():
#Simule le temps quil faut attendre à un instant donné avant quun joueur ne joue une partie
lamda=600 # nombre de parties jouées en une heure en moyenne
temps=-math.log(random.rand())/lamda
return temps
attente()
###
def p_min_1():
K=[]
e=0
t=0
duree_s=8
while t<duree_s:
t=t+attente()
e=e+partie2()
if e<0:
K.append(e)
else:
K=[0]
return abs(min(K))
p_min_1()
N=100
M=[p_min_1() for i in range(N)]
print("M: ",M)
L=[]
moy= sum(M)/len(M)
print("moyenne: ", moy)
for j in (M):
j=j**2
L.append(j)
print("carré: ", L)
moy_c=sum(L)/len(L)
print("moyenne:",moy_c)
var2= moy_c-moy**2
print("variance: ",var2)
b_inf=moy-((1.96*sqrt(var2))/sqrt(N))
print(b_inf)
b_sup=moy+((1.96*sqrt(var2))/sqrt(N))
print(b_sup)
ec_type=sqrt(var2)
print("La provision minimale adéquate pour que la banque ne saute pas se trouve dans cet intervalle [",b_inf,";",b_sup,"]") |
Partager