Last active
November 28, 2015 04:09
-
-
Save erikbern/ff37331eec49078ea116 to your computer and use it in GitHub Desktop.
This file contains 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
# Simple models of two competing firms bidding on employees | |
# Each employee is described in terms of k factors | |
# Company X knows about the x first factors | |
# Company Y knows about the y first factors | |
import numpy | |
from matplotlib import pyplot | |
n = 10000 | |
k, x, y = 10, 5, 3 | |
M = numpy.random.randn(n, k) | |
Mk = numpy.sum(M[:,:], axis=1) / k # Real value | |
Mx = numpy.sum(M[:,:x], axis=1) / x # How much is x willing to pay | |
My = numpy.sum(M[:,:y], axis=1) / y # How much is y willing to pay | |
cost = numpy.minimum(Mx, My) # How much was paid for each employee, because of auction | |
value = Mk | |
color = [['#aa2244', '#2244aa'][int(r)] for r in Mx > My] # blue if x won, red if y won | |
pyplot.figure(figsize=(10, 10)) | |
pyplot.scatter(cost, value, marker='x', c=color, alpha=0.5) | |
pyplot.xlabel('Cost of hiring employee') | |
pyplot.ylabel('Value from employee') | |
pyplot.grid() | |
pyplot.xlim(-2, 2) | |
pyplot.ylim(-2, 2) | |
pyplot.savefig('there_is_no_trick.png', transparent=True) | |
print 'total value for x:', numpy.dot(Mx > My, value - cost) | |
print 'total value for y:', numpy.dot(My > Mx, value - cost) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment