Skip to content

Instantly share code, notes, and snippets.

View adpoe's full-sized avatar
🎯
makin' the codes.

Tony Poerio adpoe

🎯
makin' the codes.
View GitHub Profile
@adpoe
adpoe / lcg_example.py
Created March 23, 2016 16:05
LCG Example
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 March 14, 2016 18:17
Geometric Distribution for Carry On Items in Airport Simulation
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 March 14, 2016 03:09
Sample Serve for Python Simulation
###########################
##### 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 March 14, 2016 03:04
A Queue Class for Python Simulation
##########################
#### 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