Bug 40759

Summary: GAMMADIST(0,1,b,0) must not be always 0
Product: LibreOffice Reporter: Luca Bruno <lethalman88>
Component: CalcAssignee: wope <wope>
Status: CLOSED FIXED    
Severity: normal CC: wope
Priority: medium    
Version: 3.3.2 release   
Hardware: Other   
OS: All   
Whiteboard:
Crash report or crash signature: Regression By:

Description Luca Bruno 2011-09-10 13:20:02 UTC
Hello,
the gamma distribution must be equivalent to an exponential for alpha=1 so the pdf for x=0 must be equal to 1/beta not 0.
Comment 1 wope 2011-09-10 13:45:09 UTC
To the definition of the GAMMADIST function, GAMMADIST(0;alpha,beta,0) is always zero.
Comment 2 Luca Bruno 2011-09-10 14:19:41 UTC
Please let core developers close bug. This is not invalid as being 0 will break several assumptions.
Comment 3 Norbert Thiebaud 2011-09-10 15:03:29 UTC
references in support of defining 0^0=1 rather than 'undefined' (note that no references suggest to _define_ 0^0=0, every time lim 0^x x->0 is used is to argue for undefined, not to argue for 0^0=0

http://www.mathforum.org/dr.math/faq/faq.0.to.0.power.html
http://en.wikipedia.org/wiki/Exponentiation#Zero_to_the_zero_power
http://www.faqs.org/faqs/sci-math-faq/specialnumbers/0to0/

and of course, in these days and age google is the ultimate reference :-)

http://www.google.com/search?q=0^0&btnG=Search

bc agrees:
$ echo "0^0" | bc
1


Furthermore the claim that
"To the definition of the GAMMADIST function, GAMMADIST(0;alpha,beta,0) is
always zero."

need a bit more substantiation. based on the behavior of the function one could argue for undefined in the name of purity or 1 in the name of prolongation by continuity. 

Note: ODFF says:  If Cumulative is FALSE(), GAMMADIST returns 0 if x < 0 and the value

(1/(beta^alpha).gamma(alpha))).(x^(alpha-1)).exp(-(x/beta))

so if the above function is to be defined for x=0, extending by continuation for x -> 0 we have to have GAMMADIST(0,1,1,0) = 1
Comment 4 wope 2011-09-10 16:12:41 UTC
Sorry, i must accuse me, you are right. I'm wrong, In 3.5 I'll correct this
Comment 5 wope 2011-09-11 07:44:39 UTC
in interpre6.cxx we must pay attention to the case x=0. 
For alpha < 1 -> #div/0
for alpha = 1 -> 1/beta
for alpha > 1 -> 0

I'll implement this for 3.5.0

@Luca, is this correct.
Comment 6 Luca Bruno 2011-09-11 07:59:13 UTC
(In reply to comment #5)
> in interpre6.cxx we must pay attention to the case x=0. 
> For alpha < 1 -> #div/0
> for alpha = 1 -> 1/beta
> for alpha > 1 -> 0
> 
> I'll implement this for 3.5.0
> 
> @Luca, is this correct.

That should be fine, thanks.
Comment 7 Norbert Thiebaud 2011-09-12 03:37:53 UTC
fixed in master with commit 9f397368cce0b94f76d4f1d74150ccc75c498e8b
Comment 8 Caolán McNamara 2011-10-03 03:12:51 UTC
closing