This file contains hidden or 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
# Make all the imports needed | |
import pandas as pd | |
from itertools import product | |
from random import randint, choice | |
import matplotlib.pyplot as plt | |
import seaborn as sns | |
df = pd.DataFrame(data=[[1,2,3,'model_A'],[5,6,7,'model_B']], columns=[['slot', 'port', 'client_qty', 'model']]) | |
df |
This file contains hidden or 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
olt = OLT() | |
df = olt.create_olt_and_populate(max_client_qty=64) | |
df |
This file contains hidden or 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
olt_qty = 150 | |
max_client_qty = 64 | |
concat_df = pd.concat([OLT().create_olt_and_populate(max_client_qty) for olt in range(olt_qty)]) | |
concat_df |
This file contains hidden or 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
plt.rcParams.update({'font.size':14, 'figure.figsize': (25,20)}) | |
grouped_olts = concat_df.groupby(['port', 'slot', 'model'])['client_qty'].mean().reset_index() | |
grouped_olts.sort_values(by='model', inplace=True) | |
models = list(concat_df['model'].unique()) | |
olts = [] | |
for model in models: | |
o = grouped_olts[grouped_olts['model']==model] | |
olts.append(o) |
This file contains hidden or 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
class OLT: | |
""" Define a class OLT that have the following attributes: | |
- An "int" Board quantity (slot_qty) which represent the maximun slot count that the OLT has. | |
- An "int" Port quantity per slot (port_per_slot) which represent the maximun port count per slot that the OLT has. | |
- An "int" Maximun client quantity per pon port (max_client_qty) which represent the maximun client count per port per slot that the OLT has. """ | |
def __init__(self, slot_qty=16, port_per_slot=16): | |
self.slot_qty = slot_qty | |
self.port_per_slot = port_per_slot |
This file contains hidden or 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
class OLT: | |
""" Define a class OLT that have the following attributes: | |
- An "int" Board quantity (slot_qty) which represent the maximun slot count that the OLT has. | |
- An "int" Port quantity per slot (port_per_slot) which represent the maximun port count per slot that the OLT has. | |
- An "int" Maximun client quantity per pon port (max_client_qty) which represent the maximun client count per port per slot that the OLT has. """ | |
def __init__(self, slot_qty=16, port_per_slot=16): | |
self.slot_qty = slot_qty | |
self.port_per_slot = port_per_slot |
This file contains hidden or 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
olt_qty = 350 | |
max_client_qty = 64 | |
speeds = np.arange(10, 20, 0.1) | |
concat_df = pd.concat([OLT().create_olt_and_populate(max_client_qty, speeds) for olt in range(olt_qty)]) | |
concat_df |
This file contains hidden or 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 matplotlib.pyplot import annotate | |
plt.rcParams.update({'font.size':25, 'figure.figsize': (30,10)}) | |
# Calculate the mean of ocupation, and the x axis of the text | |
mean = concat_df['ocupation_%'].mean() | |
text_x = concat_df['client_qty'].max() / 10 | |
# Create the scatter plot, the horizontal line, and the text | |
ax = concat_df.plot(kind='scatter', x='client_qty', y='ocupation_%', color='blue') | |
ax.axhline(mean, lw=8, color='green', label='Mean') |
This file contains hidden or 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
# Make all the imports needed | |
import pandas as pd | |
import numpy as np | |
import matplotlib.pyplot as plt | |
from scipy.stats import skewnorm, norm |
This file contains hidden or 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
a = 3 | |
loc = 4500 | |
scale = 6500 | |
size = 350 | |
client_qty = skewnorm.rvs(a, loc, scale, size, random_state=28) | |
plt.hist(np.sort(client_qty)) | |
plt.show() |
OlderNewer