[R] multiple summation
Giovanni Petris
GPetris at uark.edu
Tue Mar 16 15:32:01 CET 2004
sum, I guess, as in
> x <- seq(0,2*pi,length=10)
> y <- x <- seq(0,2*pi,length=10)
> X <- cbind(x,y)
> sum(sapply(1:NROW(X), function(i) sin(X[i,1])*cos(X[i,2])))
[1] 1.991599e-16
There may be more efficient ways to deal with the `sapply' part,
especially if your function is vectorized.
HTH,
Giovanni
> Date: Tue, 16 Mar 2004 11:12:03 +0100
> From: Paolo Bulla <paolo.bulla at unibocconi.it>
> Sender: r-help-bounces at stat.math.ethz.ch
> Cc:
> Precedence: list
> User-Agent: Internet Messaging Program (IMP) 3.2.1
>
>
> Hello,
> I have to compute a multiple summation (not an integration because the
> independent variables a
> are discrete) for all the values of a function of several variables f
> (x_1,...,x_n), that is
>
> sum ... sum f(x_1,...,x_n)
> x_1 x_n
>
> have you some suggestion? Is it possible?
> I know that for multiple integration there is the function adapt, but it has at
> most n=20. In my case n depends on the dimension of the dataset and, hence, it
> could be bigger.
>
> Thank you,
> Paolo
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>
>
--
__________________________________________________
[ ]
[ Giovanni Petris GPetris at uark.edu ]
[ Department of Mathematical Sciences ]
[ University of Arkansas - Fayetteville, AR 72701 ]
[ Ph: (479) 575-6324, 575-8630 (fax) ]
[ http://definetti.uark.edu/~gpetris/ ]
[__________________________________________________]
More information about the R-help
mailing list