1 | initial version |
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)
2 | No.2 Revision |
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)