
Untitled
By: a guest on
May 8th, 2012 | syntax:
None | size: 0.58 KB | hits: 10 | expires: Never
Plotting the curve of a function with parametric integral using R
n<-3; rho<-0.5;
g<-function(r)
{
integrate(
function(beta)
{
1/(cosh(beta)-rho*r)^(n-1)
}
,lower=0,upper=Inf)
}
curve(g(x),from=0,to=1)
g<-function(r)
{
integrate(
function(beta)
{
1/(cosh(beta)-rho*r)^(n-1)
}
,lower=0,upper=Inf)$value # integrate would return a list otherwise
}
gv <- Vectorize(g)
# Since `g` is not naturally going to handle the vector that `curve` will send
curve(gv(x),from=0,to=1)