[R] Got it--Re:A question on summation of functions

From: Liqiu Jiang <liqiunews_at_yahoo.com>
Date: Sat 07 Jan 2006 - 08:01:34 EST

Dear Rers,
 It seems the usual sum function can work. Anyway, I appreciate your time on this.

Best wishes,

Dear Rers,
 I am trying to do a 2 dimmensional intergration for a function. the function is summation of another function evaluated at a series of vector values. I have difficulty to code this function.  

For example: I have function f which is a bivariate normal density function:

#define some constants

times<-seq(0, m-1)
sig.w<- sqrt(m*err)

#bivariate normal density

f<-function(x, y, u.x, u.y)


I would like to have a function g which is defined as

uw = 1:n
uwt = (n+1):2n

g = function(x, y) f(x,y, uw[1], uw[1])+f(x,y, uw[2], uwt[2])+
...+f(x,y, uw[n], uwt[n])

if n is very large, I am not able to write all them down, How can I code the function g. Thank you for your consideration.

Best wishes,

R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Sat Jan 07 08:07:52 2006

This archive was generated by hypermail 2.1.8 : Sat 07 Jan 2006 - 14:08:32 EST