This function is a vectorized alternative to integrate:
CumIntegrate <- function(f, a = 0, b = 1, nintervals = 5, ...){
# Cumulative integral. f is a function, a and b are endpoints
# return list(x,y) of two vectors,
# where x = seq(a, b, length = nintervals)
# and y = \int_a^{x} f(
On Tuesday 22 January 2008 13:52:29 Thomas Steiner wrote:
> Thank you very much Duncan for your quick answers.
>
> > You're not passing a function as myfunk1, you're passing mf, which is
> > the result of evaluating myfun1, so it's a numeric vector.
>
> Yes, this is exacty my problem.
> If I leave
Dear Duncan,
thanks a lot for your answer. I was think a was distracted by the FED
rate cut ;)
Now it works.
Have a nice day
Thomas
myfun1<-function(x,pa) {
return(pa[1]*x^2+pa[2]*x+pa[3])
}
myfun2<-function(x,param,myfunk1,pa) {
return(param[1]*myfunk1(x,pa)+param[2]*myfunk1(-x,pa))
}
test<-
On 1/22/2008 7:52 AM, Thomas Steiner wrote:
> Thank you very much Duncan for your quick answers.
>
>> You're not passing a function as myfunk1, you're passing mf, which is
>> the result of evaluating myfun1, so it's a numeric vector.
>
> Yes, this is exacty my problem.
> If I leave it away, the p
Thank you very much Duncan for your quick answers.
> You're not passing a function as myfunk1, you're passing mf, which is
> the result of evaluating myfun1, so it's a numeric vector.
Yes, this is exacty my problem.
If I leave it away, the problem will not be resolved (it needs pa or not)
myfun1
On 22/01/2008 6:51 AM, Thomas Steiner wrote:
> Okay, let me try to better say what I meant:
>
> myfun1<-function(x=5,pa) {
> return(pa[1]*x^2+pa[2]*x+pa[3])
> }
> myfun2<-function(x=5,param,myfunk1) {
> return(param[1]*myfunk1(x)+param[2]*myfunk1(x))
> }
> test<-function(pars1,pars2,lo,up){
>
On 22/01/2008 5:30 AM, Thomas Steiner wrote:
> I want to use a function as an argument to ingtegrate it twice.
> See the following (senseless) example of a double integration:
>
> test<-function(sf,lo,up,rest) {
> innerFkn<-function(sf,lo) {
> inte=integrate(f=sf,lower=lo,upper=4)
> retu
Okay, let me try to better say what I meant:
myfun1<-function(x=5,pa) {
return(pa[1]*x^2+pa[2]*x+pa[3])
}
myfun2<-function(x=5,param,myfunk1) {
return(param[1]*myfunk1(x)+param[2]*myfunk1(x))
}
test<-function(pars1,pars2,lo,up){
mf=myfun1(x=2,pa=8*pars1)
integ=integrate(f=myfun2,lower=lo,u
I want to use a function as an argument to ingtegrate it twice.
See the following (senseless) example of a double integration:
test<-function(sf,lo,up,rest) {
innerFkn<-function(sf,lo) {
inte=integrate(f=sf,lower=lo,upper=4)
return( inte$value )
}
integral=integrate(f=innerFkn,lower=
9 matches
Mail list logo