Skip to content

Instantly share code, notes, and snippets.

@jobliz
Created January 8, 2013 23:11
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 jobliz/4488927 to your computer and use it in GitHub Desktop.
Save jobliz/4488927 to your computer and use it in GitHub Desktop.
demand_dist = (0.30, 0.45, 0.25) # [0]high, [1]medium, [2]low
positions = ( 36, 48, 60, 72, 84, 96)
high_demand = (0.05, 0.10, 0.25, 0.30, 0.20, 0.10)
med_demand = (0.10, 0.20, 0.30, 0.25, 0.10, 0.05)
low_demand = (0.15, 0.25, 0.35, 0.15, 0.05, 0.05)
demand_type = position_generator(demand_dist)
# be careful with order!
demand_amount = [
position_generator(high_demand),
position_generator(med_demand),
position_generator(low_demand)
]
n = 10000
for supply in positions:
count = 0
total = 0
for x in xrange(n):
demand = positions[demand_amount[demand_type.next()].next()]
total += profit(supply, demand)
count += 1
print supply, total * 1.0 / count
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment