probas.py

Created by alain-busser

Created on May 27, 2019

173 Bytes

Calcul d’un évènement puis de sa probabilité. L’univers doit être une variable globale. Par exemple pour un dé à 6 faces, U=set(range(1,7)). On note E.intersection(F) l’intersection de E et F, et E.union(F) leur réunion. Le contraire de l’évènement E s’obtient par U.difference(E) où U est l’univers.


def proba_conditionnelle(A,B):
  return len(A.intersection(B))/len(B)

def proba(E):
  global U
  return proba_conditionnelle(E,U)

def P(E):
  return proba(E)