1 | initial version |
The range
function needs an actual integer, not a symbolic expression with an additional attribute assigned by the assume
function. Is there a reason you need to be working with symbolic expressions at all instead of Python functions? Consider the following:
def pc(p,W):
return 1-(1-p)^W
def prc(p,M,W,C):
return 1 - sum(binomial(M,i)*pc(p,W)^i*(1-pc(p,W))^(M-i) for i in range(C))
def pcol(p,N,M,W,C):
return 1 - (1-prc(p,M,W,C))^N
These are Python functions, so you don't need to declare the variables. The return
expressions will be evaluated when you supply actual numbers for the arguments (as is done by the plot
function). One difference is that
print pcol
will return
<function pcol at 0x4325500>
instead of a symbolic expression indicating the arithmetic the function performs. But I don't see why this would matter if you just want to plot a graph. On that note, to plot the graph you just need to declare the variable that you're plotting:
var('p')
plot(pcol(p/2.0^33,2^20,2^10,8,1),p,0,1000)