"""Searing Flames: time to reach 5 stacks (2010-06-10)""" # Copyright (c) 2010 Isoph (US-Scilla) # # Permission to use, copy, modify, and/or distribute this software for any # purpose with or without fee is hereby granted, provided that the above # copyright notice and this permission notice appear in all copies. # # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. from math import factorial as fac # P = sum(i=k..n) ( n! / (i! * (n-i)!) * p^i * (1-p)^(n-i) ) # Formula by Joucifer (US-Illidan) # http://forums.worldofwarcraft.com/thread.html?sid=1&topicId=25171674646&pageNo=4#61 def P(n, p): k = 5 def each(i): return fac(n) / (fac(i) * fac(n-i)) * p**i * (1-p)**(n-i) return sum(each(i) for i in xrange(k, n + 1)) if __name__ == '__main__': from matplotlib import pyplot as plt plt.suptitle(__doc__) x = range(5, 31) for c, i in zip(('red', 'green', 'blue', 'black'), xrange(1, 5)): plt.plot(x, [P(n, i * 0.2) for n in x], c=c, label=("%d/5" % i)) plt.xlabel('Ticks required') plt.xticks(x) plt.ylabel('Probability') plt.yticks([0.05 * i for i in xrange(21)]) plt.grid() plt.legend(loc='lower right', title='Talent points') plt.show()