Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

TypeError: range() integer end argument expected, got sage.symbolic.expression.Expression.

I am trying to generate some plots using the following function definition

var('p N M W C') assume(C,'integer') pc(p,W) = 1 - (1-p)^W prc(p,M,W,C) = 1 - sum(binomial(M,i)pc(p,W)^i(1-pc(p,W))^(M-i) for i in range(C)) pcol(p,N,M,W,C) = 1 - (1-prc(p,M,W,C))^N plot(pcol(p/2.0^33,2^20,2^10,8,1),p,0,1000)

However, I get range TypeError even when I have declared that C is integer type. See error listing below:

Traceback (most recent call last): File "<stdin>", line 1, in <module> File "_sage_input_34.py", line 10, in <module> exec compile(u'open("___code___.py","w").write("# -- coding: utf-8 --\n" + _support_.preparse_worksheet_cell(base64.b64decode("dmFyKCdwIE4gTSBXIEMnKQphc3N1bWUoQywnaW50ZWdlcicpCnBjKHAsVykgPSAxIC0gKDEtcCleVwpwcmMocCxNLFcsQykgPSAxIC0gc3VtKGJpbm9taWFsKE0saSkqcGMocCxXKV5pKigxLXBjKHAsVykpXihNLWkpIGZvciBpIGluIHJhbmdlKEMpKQpwY29sKHAsTixNLFcsQykgPSAxIC0gKDEtcHJjKHAsTSxXLEMpKV5OCnBsb3QocGNvbChwLzIuMF4zMywyXjIwLDJeMTAsOCwxKSxwLDAsMTAwMCk="),globals())+"\n"); execfile(os.path.abspath("___code___.py")) File "", line 1, in <module>

File "/private/var/folders/04/ymgbq2r15hx_q1knz7jxlqzc0000gn/T/tmpcfnMcC/___code___.py", line 6, in <module> __tmp__=var("p,M,W,C"); prc = symbolic_expression(_sage_const_1 - sum(binomial(M,i)pc(p,W)i(_sage_const_1 -pc(p,W))(M-i) for i in range(C))).function(p,M,W,C) TypeError: range() integer end argument expected, got sage.symbolic.expression.Expression.

click to hide/show revision 2
indent code block

TypeError: range() integer end argument expected, got sage.symbolic.expression.Expression.

I am trying to generate some plots using the following function definition

var('p N M W C')
assume(C,'integer')
pc(p,W) = 1 - (1-p)^W
prc(p,M,W,C) = 1 - sum(binomial(M,i)pc(p,W)^i(1-pc(p,W))^(M-i) sum(binomial(M,i)*pc(p,W)^i*(1-pc(p,W))^(M-i) for i in range(C))
pcol(p,N,M,W,C) = 1 - (1-prc(p,M,W,C))^N
plot(pcol(p/2.0^33,2^20,2^10,8,1),p,0,1000)

plot(pcol(p/2.0^33,2^20,2^10,8,1),p,0,1000)

However, I get range TypeError even when I have declared that C is integer type. See error listing below:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "_sage_input_34.py", line 10, in <module>
    exec compile(u'open("___code___.py","w").write("# -- -*- coding: utf-8 --\n" -*-\\n" + _support_.preparse_worksheet_cell(base64.b64decode("dmFyKCdwIE4gTSBXIEMnKQphc3N1bWUoQywnaW50ZWdlcicpCnBjKHAsVykgPSAxIC0gKDEtcCleVwpwcmMocCxNLFcsQykgPSAxIC0gc3VtKGJpbm9taWFsKE0saSkqcGMocCxXKV5pKigxLXBjKHAsVykpXihNLWkpIGZvciBpIGluIHJhbmdlKEMpKQpwY29sKHAsTixNLFcsQykgPSAxIC0gKDEtcHJjKHAsTSxXLEMpKV5OCnBsb3QocGNvbChwLzIuMF4zMywyXjIwLDJeMTAsOCwxKSxwLDAsMTAwMCk="),globals())+"\n"); _support_.preparse_worksheet_cell(base64.b64decode("dmFyKCdwIE4gTSBXIEMnKQphc3N1bWUoQywnaW50ZWdlcicpCnBjKHAsVykgPSAxIC0gKDEtcCleVwpwcmMocCxNLFcsQykgPSAxIC0gc3VtKGJpbm9taWFsKE0saSkqcGMocCxXKV5pKigxLXBjKHAsVykpXihNLWkpIGZvciBpIGluIHJhbmdlKEMpKQpwY29sKHAsTixNLFcsQykgPSAxIC0gKDEtcHJjKHAsTSxXLEMpKV5OCnBsb3QocGNvbChwLzIuMF4zMywyXjIwLDJeMTAsOCwxKSxwLDAsMTAwMCk="),globals())+"\\n"); execfile(os.path.abspath("___code___.py"))
  File "", line 1, in <module>

<module>

File "/private/var/folders/04/ymgbq2r15hx_q1knz7jxlqzc0000gn/T/tmpcfnMcC/___code___.py", line 6, in <module> __tmp__=var("p,M,W,C"); prc = symbolic_expression(_sage_const_1 - sum(binomial(M,i)pc(p,W)i(_sage_const_1 -pc(p,W))(M-i) sum(binomial(M,i)*pc(p,W)**i*(_sage_const_1 -pc(p,W))**(M-i) for i in range(C))).function(p,M,W,C) TypeError: range() integer end argument expected, got sage.symbolic.expression.Expression.

sage.symbolic.expression.Expression.

TypeError: range() integer end argument expected, got sage.symbolic.expression.Expression.

I am trying to generate some plots using the following function definition

var('p N M W C')
assume(C,'integer')
pc(p,W) = 1 - (1-p)^W
prc(p,M,W,C) = 1 - sum(binomial(M,i)*pc(p,W)^i*(1-pc(p,W))^(M-i) for i in range(C))
pcol(p,N,M,W,C) = 1 - (1-prc(p,M,W,C))^N
plot(pcol(p/2.0^33,2^20,2^10,8,1),p,0,1000)

However, I get range TypeError even when I have declared that C is integer type. See error listing below:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "_sage_input_34.py", line 10, in <module>
    exec compile(u'open("___code___.py","w").write("# -*- coding: utf-8 -*-\\n" + _support_.preparse_worksheet_cell(base64.b64decode("dmFyKCdwIE4gTSBXIEMnKQphc3N1bWUoQywnaW50ZWdlcicpCnBjKHAsVykgPSAxIC0gKDEtcCleVwpwcmMocCxNLFcsQykgPSAxIC0gc3VtKGJpbm9taWFsKE0saSkqcGMocCxXKV5pKigxLXBjKHAsVykpXihNLWkpIGZvciBpIGluIHJhbmdlKEMpKQpwY29sKHAsTixNLFcsQykgPSAxIC0gKDEtcHJjKHAsTSxXLEMpKV5OCnBsb3QocGNvbChwLzIuMF4zMywyXjIwLDJeMTAsOCwxKSxwLDAsMTAwMCk="),globals())+"\\n"); execfile(os.path.abspath("___code___.py"))
  File "", line 1, in <module>

  File "/private/var/folders/04/ymgbq2r15hx_q1knz7jxlqzc0000gn/T/tmpcfnMcC/___code___.py", line 6, in <module>
    __tmp__=var("p,M,W,C"); prc = symbolic_expression(_sage_const_1  - sum(binomial(M,i)*pc(p,W)**i*(_sage_const_1 -pc(p,W))**(M-i) for i in range(C))).function(p,M,W,C)
TypeError: range() integer end argument expected, got sage.symbolic.expression.Expression.