[R] Need help with function that includes 2 summation

Romain Francois
2007-10-17T12:35:49Z

Zack Darnell wrote:
> I am relatively new to R, so this may be a much simpler question than
> it seems to me. I am trying to create a function that includes two
> summations, and can't figure out how. I am attaching the equation as a
> pdf file. This function will then be optimized over a chosen range of
> values, but right now I just need help with the function. Thank you.
> Zack Darnell
> Duke University
Hi,

I'm a bit unsure of what you call double summation, I only see the i
index in here, you can almost translate the latex code into R:

R> sqrt( sum(cos(k*theta))^2 + sum(sin(k*theta))^2  ) / n

theta being a vector containing all your theta_i, for i in 1 to n.

Cheers,

Romain

--
Mango Solutions
data analysis that delivers

Tel:  +44(0) 1249 467 467
Fax:  +44(0) 1249 467 468
Mob:  +44(0) 7813 526 123