I am in the process of learning Sage, coming from Maxima (and Mathematica, 
which I do not like much...).
Cut'n'pastes from a notebook running on sagenb.org
version()

version()

==>

'Sage Version 5.4, Release Date: 2012-11-09'

var('t,a,b,d')
## beta density
dbeta(t,a,b)=t^(a-1)*(1-t)^(b-1)/beta(a,b)
## density of the *difference* of two independent beta(1,1)-distributed RVs
## (yes, I mean uniforms(0 1)...)
integrate(dbeta(t,1,1)*dbeta(t+d,1,1),t,max(0, -d), min(1,1-d))

==>

1

Huh ?? This is seriously whacky :


dbeta(t,a,b):=t^(a-1)*(1-t)^(b-1)/beta(a,b)
integrate(dbeta(t,1,1)*dbeta(t+d,1,1),t,max(0,-d),min(1,1-d))

==>

dbeta(t,a,b):=t^(a-1)*(1-t)^(b-1)/beta(a,b)
min(1,1-d)-max(0,-d)


The problem appears to lie with integrate() :


integrate(1,t,max(0,-d),min(1,1-d))

==>

1


integrate(t,t,max(0,-d),min(1,1-d))

==>

1/2


But another one : i tried to give dbeta a proper definition, i. e. with a 
domain of definition, therefore allowing convolutions :


db2(t,a,b)=Piecewise([[(0,1),t^(a-1)*(1-t)^(b-1)/beta(a,b)]])
db2

==>

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "_sage_input_7.py", line 10, in <module>
    exec compile(u'open("___code___.py","w").write("# -*- coding: utf-8 -*-\\n" 
+ 
_support_.preparse_worksheet_cell(base64.b64decode("ZGIyKHQsYSxiKT1QaWVjZXdpc2UoW1soMCwxKSx0XihhLTEpKigxLXQpXihiLTEpL2JldGEoYSxiKV1dKQpkYjI="),globals())+"\\n");
 execfile(os.path.abspath("___code___.py"))
  File "", line 1, in <module>
    
  File "/tmp/tmpzOS0Jf/___code___.py", line 3, in <module>
    __tmp__=var("t,a,b"); db2 = symbolic_expression(Piecewise([[(_sage_const_0 
,_sage_const_1 ),t**(a-_sage_const_1 )*(_sage_const_1 -t)**(b-_sage_const_1 
)/beta(a,b)]])).function(t,a,b)
  File 
"/sagenb/sage_install/sage-5.4-sage.math.washington.edu-x86_64-Linux/local/lib/python2.7/site-packages/sage/calculus/all.py",
 line 96, in symbolic_expression
    return SR(x)
  File "parent.pyx", line 804, in sage.structure.parent.Parent.__call__ 
(sage/structure/parent.c:7228)
  File "coerce_maps.pyx", line 82, in 
sage.structure.coerce_maps.DefaultConvertMap_unique._call_ 
(sage/structure/coerce_maps.c:3547)
  File "coerce_maps.pyx", line 77, in 
sage.structure.coerce_maps.DefaultConvertMap_unique._call_ 
(sage/structure/coerce_maps.c:3449)
  File "ring.pyx", line 284, in 
sage.symbolic.ring.SymbolicRing._element_constructor_ 
(sage/symbolic/ring.cpp:4846)
TypeError


Threfore, whackiness might lie with a more general problem.


Where am I goofing ?

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To post to this group, send email to sage-support@googlegroups.com.
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-support?hl=en.


Reply via email to