Dear Sir,

Thank you for your prompt advice. Some comments below :

Le vendredi 21 décembre 2012 15:03:45 UTC+1, kcrisman a écrit :
>
>
>> 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 :
>>
>>
>>
> You might want to see what "max(0,-d)" does.    The function 
> "max_symbolic" should do what you want, though I don't know whether your 
> integration will work.  Hopefully it would.
>

It does, at least in this special case :

integrate(dbeta(t,1,1)*dbeta(t+d,1,1),t,max_symbolic(0, -d), 
min_symbolic(1,1-d))

==>

-max(0, -d) + min(1, -d + 1)


But why do we have to use max_symbolic ? As far as I can tell, max, like 
many other functions in Sage, could be overloaded to call max_symbolic when 
used with a symbolic argument, no ? After all, we don't have to write 
plus_symbolic(a,b) instead of a+b... 

>
>  
>
>> 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)
>>
>>
>>
>
> I'm also not sure what the := notation would mean here in Sage; that's 
> Maxima style, right?
>

That's one way to define a function in Maxima (the other being define())
 

> 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
>>
>>
>
> You would get this even with
>
> db2(x) = Piecewise([[(0,1),x^2]])
>
> because piecewise functions do not accept this construction.  
>
> db2 = Piecewise([[(0,1),x^2]])
>

Hmm...

db3=Piecewise([[(0,1),dbeta(t,a,b)]],var=t)
db3

==>

Piecewise defined function with 1 parts, [[(0, 1), t |--> (-t + 1)^(b - 1)*t^(a 
- 1)/beta(a, b)]]

 
Not so good : db3 is a function of one variable, with no second or third 
argument.

>
> works.  Unfortunately, I'm not so sure the three-variable equivalent is 
> much better here, as this (now very old) class was designed for 
> single-variable constructs (though it does support convolution in that 
> context).  You may want to use pw.mac inside Maxima for this, I'm not sure. 
>  Or there might be a way to trick a lambda function to make this work.
>
> I'm sorry that our piecewise support is not the greatest.  It's a 
> longstanding annoyance.
>

I saw a ticket relating to it. I wanted to comment, but was unable to find 
*how* to comment a ticket (or open another, by the way).

In my exploration of tickets about symbolics, I found also 
http://trac.sagemath.org/sage_trac/ticket/3745, which I wanted to comment. 
The reported problem still stands in maxima 5.26, current with Sage, but is 
slightly alleviated in maxima 5.29. Further exploration also showed 
workarounds in current Sage. Please let me know how to comment a ticket, 
and I will report this.

>
> - kcrisman
>
>

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


Reply via email to