Ask Your Question
1

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
0

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)
gamma(a)/b^a
edit flag offensive delete link more
0

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)                                 
gamma(alpha)/beta^alpha

From sage.symbolic.assumptions? :

Here is the list of acceptable features::

    sage: maxima('features')
    [integer,noninteger,even,odd,rational,irrational,real,imaginary,complex,analytic,increasing,decreasing,oddfun,evenfun,posfun,constant,commutative,lassociative,rassociative,symmetric,antisymmetric,integervalued]

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

Your Answer

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

Add Answer

Question Tools

Stats

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

Seen: 190 times

Last updated: May 05 '21