Ask Your Question

Integration of Gamma PDF fails

asked 2021-05-05 11:47:24 +0200

I'm new to Sage and, as a simple example, I'm trying to integrate the (unnormalised) gamma distribution pdf:

f(x,a,b) = x^(a-1)*ℯ^(-b*x)
assume(b>0,'real', a>0,'real' ,x>0,'real')

fint = f.integrate(x,0,infinity)

This throws

    ValueError: Computation failed since Maxima requested additional constraints; using the 'assume' command before evaluation *may* help (example of legal syntax is 'assume(a>0)', see `assume?` for more details)
Is a an integer?

What am I doing wrong here?

edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted

answered 2021-05-05 16:55:21 +0200

Emmanuel Charpentier gravatar image

WoksForMe(TM) on 9.3.rc5 ... provided you provide the right information :

sage: var("x, alpha, beta", domain="positive")                                  
(x, alpha, beta)
sage: assume(alpha,"noninteger")                                                
sage: integrate(x^(alpha-1)*e^(-beta*x),x,0,oo)                                 

From sage.symbolic.assumptions? :

Here is the list of acceptable features::

    sage: maxima('features')

As far as I recall, one of the examples of assuming uses the integration of the gamma distribution to illustrate how to (temporarily) assume alpha being noninteger.

edit flag offensive delete link more

answered 2021-05-05 14:27:48 +0200

slelievre gravatar image

This might only partially answer your question, but hopefully it helps.

Declaring a and b to be positive integers:

sage: a, b = SR.var('a, b', domain='positive')
sage: assume("a, b, 'integer'")

sage: assumptions()
[b > 0, a > 0, a is integer, b is integer]

and declaring f as a function of a single variable

sage: f(x) = x^(a - 1) * e^(-b*x)

we get:

sage: f.integrate(x, 0, oo)
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2021-05-05 11:47:24 +0200

Seen: 65 times

Last updated: May 05 '21