Ask Your Question

Revision history [back]

product of functions

Hello I just started using Sagemath and I am trying to do something simple but I cannot figure it out.

i have a Gaussian function

mu, sigma, x, N=var('mu','sigma','x','N')

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

and I want to calculate the product of N such functions.

I tried

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

and I got the error: TypeError: unable to convert N to an integer

I works if I choose N to be some number, but I would like to get a symbolic expression output.

Can anyone help please?

Thanks

product of functions

Hello I just started using Sagemath SageMath and I am trying to do something simple simple but I cannot figure it out.

i I have a Gaussian function function

mu, sigma, x, N=var('mu','sigma','x','N')

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

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

and I want to calculate the product of N such functions.

I tried

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

range(1, N)]) f(x, N)

and I got the error: error:

TypeError: unable to convert N to an integer

integer

I works if I choose N N to be some number, but I would like to get a symbolic expression output.

Can anyone help please?

Thanks