Last active
October 24, 2015 20:35
-
-
Save FluxLemur/1f4dc2ce6eb9c9cabba0 to your computer and use it in GitHub Desktop.
Exploring a model of team availability. You must assemble a group of N people from a team of T people, each of which is available with a certain probability.
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
from pylab import * | |
from scipy.misc import comb | |
def diff_simp(p): | |
return 7*3*(p**5)*(1-p)**2 + 7*(p**6)*(1-p) + p**7 - p**3 | |
# the probability of a assembling [n] of [t] people, each being available with | |
# probability [p] | |
def availability(p,n,t): | |
return sum([comb(t,ni)*p**ni*(1-p)**(t-ni) for ni in range(n,t+1)]) | |
# generalized difference, n1/t1 vs. n2/t2 people | |
def diff(p, n1, t1, n2, t2): | |
p1 = availability(p,n1,t1) | |
p2 = availability(p,n2,t2) | |
return p1 - p2 | |
xs = linspace(0,1,100) | |
ys = [diff_simp(i) for i in xs] | |
ys2 = [diff(i,5,7,3,3) for i in xs] # for different configurations, | |
# change 5/7 3/3 | |
plot(xs,ys) | |
plot(xs,ys2) # note these plots are the same | |
title('Diff in Prob between assembling a team of 5/7 people and 3/3 people') | |
xlabel('Probability of availability') | |
ylabel('Difference in Probabilities') | |
show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment