samedi 22 février 2020

Python - Coin flip experiment

I have a python code of a coin flip game played 1000 times. And it show the financial result for a 100$ bet.

I would like to simulate 100 times this game of 1000 coins flip. In order to print the maximum amount I would won. And the maximum amount I would lose playing 1000 coins flip 100 times.

Any idea how to do it ?

import numpy as np
game = np.random.binomial(1, 0.5, size=1000)
print("Result: ", np.count_nonzero(game == 1)*100-np.count_nonzero(game == 0)*100)



Aucun commentaire:

Enregistrer un commentaire