Skip to content

Instantly share code, notes, and snippets.

@viniciuspereiras
Created September 28, 2021 05:07
Show Gist options
  • Save viniciuspereiras/67063369cf2c5480df62007654a60650 to your computer and use it in GitHub Desktop.
Save viniciuspereiras/67063369cf2c5480df62007654a60650 to your computer and use it in GitHub Desktop.
random or not?
import numpy as np
import matplotlib.pyplot as plt
import random
class DataOc:
def __init__(self, number: int):
self.number = number
def _getOccurrences(self):
return self.number
def _addOccurrence(self):
self.number += 1
true = DataOc(1)
false = DataOc(2)
def simple(limit):
for i in range(0, limit):
result = random.randint(0,6)
if result == 1:
true._addOccurrence()
else:
false._addOccurrence()
def complicated(limit):
for i in range(0, limit):
result = random.randint(0,6)
result2 = random.randint(0,6)
if result == result2:
true._addOccurrence()
else:
false._addOccurrence()
complicated(100000)
height = [true._getOccurrences(), false._getOccurrences()]
bars = ('TRUE', 'FALSE')
y_pos = np.arange(len(bars))
plt.bar(y_pos, height)
plt.xticks(y_pos, bars)
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment