Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
makin' the codes.

Tony Poerio adpoe

🎯
makin' the codes.
  • Pittsburgh
View GitHub Profile
View lcg_example.py
def generate_lcg( num_iterations ):
"""
LCG - generates as many random numbers as requested by user, using a Linear Congruential Generator
LCG uses the formula: X_(i+1) = (aX_i + c) mod m
:param num_iterations: int - the number of random numbers requested
:return: void
"""
# Initialize variables
@adpoe
adpoe / carry-on.py
Created Mar 14, 2016
Geometric Distribution for Carry On Items in Airport Simulation
View carry-on.py
def gen_number_of_carry_on_items__for_COMMUTER_passenger():
"""
Number of bags a passenger carries is determined using a GEOMETRIC DISTIBUTION
BERNOULLI TRIAL with success bias %p = chance of passenger bringing bags
Bernoulli with 80% chance
P = 0.80 for international
:return: Number of bags a commuter passenger has carried on
"""
# Count number of iterations until a success
@adpoe
adpoe / simulation_server.py
Created Mar 14, 2016
Sample Serve for Python Simulation
View simulation_server.py
###########################
##### AIRPORT SERVERS #####
###########################
class CheckInServer:
""" Class used to model a server at the Check-in terminal
"""
def __init__(self):
""" Initialize the class variables
"""
self.service_time = 0.0
@adpoe
adpoe / sim_queue.py
Created Mar 14, 2016
A Queue Class for Python Simulation
View sim_queue.py
##########################
#### CHECK-IN QUEUES #####
##########################
class CheckInQueue:
""" Class used to model a check-in line Queue
"""
def __init__(self):
self.queue = q.Queue()
self.customers_added = 0