Created
September 13, 2020 15:17
-
-
Save samuelgrigolato/ba8984b9be4f9963ab9c42e0a83d1e83 to your computer and use it in GitHub Desktop.
Simulação de mudança de temperatura para partidas Cosmos
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from random import sample | |
from collections import defaultdict | |
RODADAS = 7 | |
EVENTOS = [-2, -1, -1, -1, -1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2] | |
def simular_partida(): | |
eventos_da_partida = sample(EVENTOS, RODADAS) | |
delta_temperatura = sum(eventos_da_partida) | |
return delta_temperatura | |
def calcular_histograma(partidas): | |
histograma = defaultdict(lambda: 0) | |
for _ in range(partidas): | |
delta_temperatura = simular_partida() | |
histograma[delta_temperatura] = histograma[delta_temperatura] + 1 | |
return histograma | |
histograma = calcular_histograma(100000) | |
print(histograma) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment