From: Tony Plate <tplate_at_acm.org>

Date: Mon 09 Jan 2006 - 22:03:33 GMT

>>If you haven't seen this in your math courses, perhaps this would help:

*>>
*

*>>http://en.wikipedia.org/wiki/Empty_set
*

*>>
*

>>which says, in part:

*>>
*

*>>Operations on the empty set
*

*>>
*

*>>Operations performed on the empty set (as a set of things to be operated
*

*>>upon) can also be confusing. (Such operations are nullary operations.) For
*

*>>example, the sum of the elements of the empty set is zero, but the product
*

*>>of the elements of the empty set is one (see empty product). This may seem
*

*>>odd, since there are no elements of the empty set, so how could it matter
*

*>>whether they are added or multiplied (since "they" do not exist)?
*

*>>Ultimately, the results of these operations say more about the operation in
*

*>>question than about the empty set. For instance, notice that zero is the
*

*>>identity element for addition, and one is the identity element for
*

*>>multiplication.
*

*>>
*

*>>
*

*>>Andy
*

*>>
*

*>>
*

*>>From: Martin Morgan
*

*>>
*

*>>>I guess I have to say yes, I'd exepct
*

*>>>
*

*>>>x <- 1:10
*

*>>>sum(x[x>10]) ==> numeric(0)
*

*>>>
*

*>>>this would be reinforced by recongnizing that numeric(0) is not zero,
*

*>>>but nothing. I guess the summation over an empty set is an empty set,
*

*>>>rather than a set containing the number 0. Certainly these
*

*>>>
*

*>>>exp(x[x>10]) ==> numeric(0)
*

*>>>numeric(0) + 1 ==> numeric(0)
*

*>>>
*

*>>>would give me pause.
*

*>>>
*

*>>>
*

*>>>Gabor Grothendieck <ggrothendieck@gmail.com> writes:
*

*>>>
*

*>>>
*

*>>>>The way to think about it is:
*

*>>>>
*

*>>>> prod(rep(x,n)) == x^n
*

*>>>>
*

*>>>>and that works for n=0 too.
*

*>>>
*

*>>>Hmm, Not sure what to put in for x and n? do you mean x == numeric(0),
*

*>>>n == 0 (0 copies of an empty set), x == ANY n == numeric(0) (an empty
*

*>>>set of ANYthing), x == numeric(0), n == numeric(0) ? For all of these,
*

*>>>x^n evaluates to numeric(0).
*

*>>>
*

*>>>Martin (Morgan)
*

*>>>
*

*>>>Duncan Murdoch <murdoch@stats.uwo.ca> writes:
*

*>>>
*

*>>>
*

*>>>>On 1/9/2006 12:40 PM, Martin Morgan wrote:
*

*>>>>
*

*>>>>>I'm a little confused. I understand that numeric(0) means an empty
*

*>>>>>numeric vector, not the number 0 expressed as numeric. As
*

*>>>
*

*>>>it is now,
*

*>>>
*

*>>>>>prod(numeric(0)) generates something -- a vector of length 1
*

*>>>>>containing the number 1 -- from nothing. I would have expected
*

*>>>>>prod(numeric(0)) ==> numeric(0)
*

*>>>>>this is consistent with
*

*>>>>>numeric(0) ==> numeric(0)
*

*>>>>>numeric(0) * 1 ==> numeric(0)
*

*>>>>>cumprod(numeric(0)) ==> numeric(0)
*

*>>>>>and, because concatenation occus before function evaluation,
*

*>>>>>prod(c(numeric(0),1)) ==> prod( c(1) ) ==> 1
*

*>>>>>I would expect sum() to behave the same way, e.g., sum(numeric(0))
*

*>>>>>==>
*

*>>>>>numeric(0). From below,
*

*>>>>>
*

*>>>>
*

*>>>>I think the code below works as I'd expect. Would you
*

*>>>
*

*>>>really like the
*

*>>>
*

*>>>>last answer to be numeric(0)?
*

*>>>>
*

*>>>> > x <- 1:10
*

*>>>> > sum(x)
*

*>>>>[1] 55
*

*>>>> > sum(x[x>5])
*

*>>>>[1] 40
*

*>>>> > sum(x[x>10])
*

*>>>>[1] 0
*

*>>>>
*

*>>>>Duncan Murdoch
*

*>>>>
*

*>>>>
*

*>>>>>> >>>> consider exp(sum(log(numeric(0)))) ... ?)
*

*>>>>>> >> >> That's a fairly standard mathematical convention,
*

*>>>>>>which
*

*>>>>>> >> is presumably why sum and prod work that way.
*

*>>>>>> >> >> Duncan Murdoch
*

*>>>>>
*

*>>>>>I would have expected numeric(0) as the result (numeric(0) is the
*

*>>>>>result from log(numeric(0)), etc).
*

*>>>>>Martin (Morgan)
*

*>>>>>Martin Maechler <maechler@stat.math.ethz.ch> writes:
*

*>>>>>
*

*>>>>>
*

*>>>>>>>>>>>"Ben" == Ben Bolker <bolker@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.
*

*>>>>>> >> >>>
*

*>>>>>> >> >>>> consider exp(sum(log(numeric(0)))) ... ?)
*

*>>>>>> >> >> 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
*

*>>>>>>
*

*>>>>>>______________________________________________
*

*>>>>>>R-devel@r-project.org mailing list
*

*>>>>>>https://stat.ethz.ch/mailman/listinfo/r-devel
*

*>>>
*

*>>>______________________________________________
*

*>>>R-devel@r-project.org mailing list
*

*>>>https://stat.ethz.ch/mailman/listinfo/r-devel
*

*>>>
*

*>>>
*

*>>
*

*>>
*

*>>------------------------------------------------------------------------------
*

*>>Notice: This e-mail message, together with any attachment...{{dropped}}
*

https://stat.ethz.ch/mailman/listinfo/r-devel Received on Tue Jan 10 09:12:20 2006

Date: Mon 09 Jan 2006 - 22:03:33 GMT

Since the virtue and reliability of Wikis was brought up, I created a R
Wiki page for this at

http://www.sciviews.org/_rgui/wiki/doku.php?id=beginners:surprises:emptysetfuncs
:-)

Anyone: please correct errors and improve it!

Duncan Murdoch wrote:

> On 1/9/2006 1:27 PM, Liaw, Andy wrote: >

>>If you haven't seen this in your math courses, perhaps this would help:

> > > This is what is so great about Wikipedia: it gives certainty where I'd > only call it a fairly standard convention. ;-) > > Duncan Murdoch > > >

>>which says, in part:

> > > ______________________________________________ > R-devel@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel > ______________________________________________R-devel@r-project.org mailing list

https://stat.ethz.ch/mailman/listinfo/r-devel Received on Tue Jan 10 09:12:20 2006

*
This archive was generated by hypermail 2.1.8
: Mon 20 Feb 2006 - 03:21:36 GMT
*