# Integration of Gamma PDF fails

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 close merge delete

Sort by » oldest newest most voted

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.

more

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

more