s-news
[Top] [All Lists]

summary: integrate() for function with vector arguments

To: "Splus Users List" <s-news@lists.biostat.wustl.edu>
Subject: summary: integrate() for function with vector arguments
From: "Victoria Landsman" <msvika@cc.huji.ac.il>
Date: Wed, 30 Oct 2002 20:13:06 +0200
Importance: Normal
Dear Splus Users!
A few weeks ago I've posted a number of questions regarding numerical
integration with Splus for function which should be evaluated at vectors of
data and fixed parameters as well. My special thanks to Patrick Burns whose
immediate replies and suggestions helped me to solve my problem.

I searched archives but did not find a comprehensive summary for similar
problem there. This lead me to post this summary which (I hope) will be
useful for others.
Below is a simple example of function jj.myfun
which is function of x; cvr1 and cvr2 are vectors of data; b is a fixed
number(scalar).

jj.myfun_function(x,cvr1, cvr2, b)
{b*x+cvr1*x+exp(cvr2)}

jj.int_function(s, b)
{cons_integrate(jj.myfun,0,2,cvr1=s[1], cvr2=s2[2], b=b)$integral
cons
}

s_cbind(s1,s2)
apply(s,2,jj.int,b=5)

When working with large amounts of data and more complicated functions it
may  be useful to try the function "line.integral" proposed by Patrick Burns
in Spoetry, Ch14. I've found this function to be appropriate for my case
which enabled me to save a significant portion of running time.

With best regards, Vicky.




<Prev in Thread] Current Thread [Next in Thread>
  • summary: integrate() for function with vector arguments, Victoria Landsman <=