From maechler at stat.math.ethz.ch  Mon Jan  9 08:56:47 2006
From: maechler at stat.math.ethz.ch (Martin Maechler)
Date: Mon, 9 Jan 2006 08:56:47 +0100
Subject: [Rd] prod(numeric(0)) surprise
In-Reply-To: <43C1CD05.2030504@zoo.ufl.edu>
References: <43C1C973.8080702@zoo.ufl.edu> <43C1CBB9.7090307@stats.uwo.ca>
	<43C1CD05.2030504@zoo.ufl.edu>
Message-ID: <17346.5951.435355.767827@stat.math.ethz.ch>

>>>>> "Ben" == Ben Bolker <bolker at zoo.ufl.edu>
>>>>>     on Sun, 08 Jan 2006 21:40:05 -0500 writes:

    Ben> Duncan Murdoch wrote:
    >> On 1/8/2006 9:24 PM, Ben Bolker wrote:
    >> 
    >>> It surprised me that prod(numeric(0)) is 1.  I guess if
    >>> you say (operation(nothing) == identity element) this
    >>> makes sense, but ??
    >> 
    >> 
    >> What value were you expecting, or were you expecting an
    >> error?  I can't think how any other value could be
    >> justified, and throwing an error would make a lot of
    >> formulas more complicated.
    >> 
    >>>
    >> 
    >> 
    >> That's a fairly standard mathematical convention, which
    >> is presumably why sum and prod work that way.
    >> 
    >> Duncan Murdoch

    Ben>    OK.  I guess I was expecting NaN/NA (as opposed to
    Ben> an error), but I take the "this makes everything else
    Ben> more complicated" point.  Should this be documented or
    Ben> is it just too obvious ... ?  (Funny -- I'm willing to
    Ben> take gamma(1)==1 without any argument or suggestion
    Ben> that it should be documented ...)

see?  so it looks to me as if you have finally convinced
yourself that '1' is the most reasonable result.. ;-)

Anyway, I've added a sentence to help(prod)  {which matches
the sentence in help(sum), BTW}.

Martin



[Rd] prod(numeric(0)) surprise
Martin Maechler