Re: [R] double summation

2015-10-14 Thread David Winsemius
On Oct 14, 2015, at 1:29 PM, Sherouk Moawad via R-help wrote: > Σi=02 Σj=01(exp(xi+xj)), i>j if (i>0 and j>0) I want to write this > summation which has a condition on numerator(j0 and j>0I tried on this > code That comes across as only barely comprehensible. > sum(sapply(0:2, function(i){

[R] double summation

2015-10-14 Thread Sherouk Moawad via R-help
Σi=02 Σj=01(exp(xi+xj)), i>j if (i>0 and j>0)  I want to write this summation which has a condition on numerator(j0 and j>0I tried on this code sum(sapply(0:2, function(i){sum(sapply(0:1, function(j){if (i>0&j>0){i>j}{exp(x[i]+x[j])}))}))But it didn't work Any help please [[alternative H

Re: [R] Double summation limits

2009-05-01 Thread David Winsemius
On May 2, 2009, at 12:18 AM, RON70 wrote: Can anyone please explain me why it is not coming? I have done following : j=1 i=0:j; sum( choose(i+j,i) ) [1] 3 j=2 i=0:j; sum( choose(i+j,i) ) [1] 10 j=3 i=0:j; sum( choose(i+j,i) ) [1] 35 j=0:3; i=0:j; sum( choose(i+j,i) ) Warning messag

Re: [R] Double summation limits

2009-05-01 Thread RON70
Can anyone please explain me why it is not coming? I have done following : > j=1 > i=0:j; sum( choose(i+j,i) ) [1] 3 > j=2 > i=0:j; sum( choose(i+j,i) ) [1] 10 > j=3 > i=0:j; sum( choose(i+j,i) ) [1] 35 > j=0:3; i=0:j; sum( choose(i+j,i) ) Warning message: In 0:j : numerical expression has 4 elem

Re: [R] Double summation limits

2009-05-01 Thread David Winsemius
Perhaps: SSCxy <- function(z) {tail(sapply(0:z, function (x) sum(sapply(0:x, function(y) sum(choose(x+y, y), 1) } > SSCxy(5) [1] 462 See also: http://www.research.att.com/~njas/sequences/?q=1%2C3%2C10%2C35%2C126%2C462&sort=0&fmt=0&language=english&go=Search On May 1, 2009, at 3:45 PM

[R] Double summation limits

2009-05-01 Thread Orestis Chrysafis
Dear R experts I need to write a function that incorporates double summation, the problem being that the upper limit of the second summation is the index of the first summation, i.e: sum_{j=0}^{x} sum_{i=0}^{j} choose(i+j, i) where x variable or constant, doesn't matter. The following code obviou