Skip to content

Instantly share code, notes, and snippets.

@samuelgrigolato
Created September 13, 2020 15:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samuelgrigolato/ba8984b9be4f9963ab9c42e0a83d1e83 to your computer and use it in GitHub Desktop.
Save samuelgrigolato/ba8984b9be4f9963ab9c42e0a83d1e83 to your computer and use it in GitHub Desktop.
Simulação de mudança de temperatura para partidas Cosmos
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