c5tpap.py

Created by manuel-eleve-tle-techno-indice2020

Created on July 09, 2020

752 Bytes


from random import *



def est_dope(p):

    if random() < p:

        return 1

    else:

        return 0



def test_positif(dope):

    if dope == 1:

        if random() < 0.94:

            return 1

    else:

        if random() < 0.04:

            return 1

    return 0



def simulations(p):

    nb_dopes = 0

    nb_tests_positifs = 0

    nb_dopes_positifs = 0

    

    for sportif in range(2500):

        dope = est_dope(p)

        positif = test_positif(dope)

        dope_positif = dope*positif

        

        nb_dopes = nb_dopes + dope

        nb_tests_positifs = nb_tests_positifs + positif

        nb_dopes_positifs = nb_dopes_positifs + dope*positif

    

    return nb_dopes_positifs/nb_tests_positifs

During your visit to our site, NumWorks needs to install "cookies" or use other technologies to collect data about you in order to:

With the exception of Cookies essential to the operation of the site, NumWorks leaves you the choice: you can accept Cookies for audience measurement by clicking on the "Accept and continue" button, or refuse these Cookies by clicking on the "Continue without accepting" button or by continuing your browsing. You can update your choice at any time by clicking on the link "Manage my cookies" at the bottom of the page. For more information, please consult our cookies policy.