Ask Your Question

Revision history [back]

Instead of

f = lambda x, N: prod([P for x in range(1, N)])

use

f = lambda x, N: product(P, k, 1, N)

Also, maybe you want

P(x) = 1/sqrt((2*pi*sigma^2))*exp(-((x-mu)/sigma)^2/2)

Instead In Sage, sum serves both for Python sums and for symbolic sums, but for products we have prod and product.

Declare an extra symbolic variable k, and instead of

f = lambda x, N: prod([P for x in range(1, N)])

use

f = lambda x, N: product(P, k, 1, N)

Also, maybe check your expression for P. Maybe you wantwant this instead:

P(x) = 1/sqrt((2*pi*sigma^2))*exp(-((x-mu)/sigma)^2/2)