• We are pleased to announce that the winner of our Feedback Prize Draw for the Winter 2024-25 session and winning £150 of gift vouchers is Zhao Liang Tay. Congratulations to Zhao Liang. If you fancy winning £150 worth of gift vouchers (from a major UK store) for the Summer 2025 exam sitting for just a few minutes of your time throughout the session, please see our website at https://www.acted.co.uk/further-info.html?pat=feedback#feedback-prize for more information on how you can make sure your name is included in the draw at the end of the session.
  • Please be advised that the SP1, SP5 and SP7 X1 deadline is the 14th July and not the 17th June as first stated. Please accept out apologies for any confusion caused.

Integration in R

R

r_v.s

Member
I really dint know where this question should have been posted!

Is it possible to evaluate an integral in R when one of the limits is a variable?
The integration with constant limits works! If R wont do this, would you suggest a software package that would??
 
I really dint know where this question should have been posted!

Is it possible to evaluate an integral in R when one of the limits is a variable?
The integration with constant limits works! If R wont do this, would you suggest a software package that would??

Do you mean like below? If so, MATLAB can do it.

>> syms x y
>> f = y^3 - y^2 + 1

f = y^3 - y^2 + 1

>> int(f,y,1,x)

ans = x*(x^2*(x/4 - 1/3) + 1) - 11/12
 
Yes. infact, the expression is complicated
It is a joint distribution function so, but the limits are from -infinity to x.
 
The specific code would help. I suspect it will just need a tweak to get the correct behaviour.
 
library(cubature)

k = 0.618079
rho = 0.402193
k1 = (1+s^2/4)^2.5
k2 = 4*(1-rho)^0.5

f1 = function(r,s)
{
(k*k1*(1+(r^2)/4)^2.5*(1+(s^2-2*rho*s*r+r^2)/k2)^-2.5
}
##I need to integrate the above twice from (-inf , qt(0.75,4)) wrt s and (-inf , qt(v,4)) wrt r.
Finally i require an expression in v, which i then need to integrate from (0,1).

I'd be glad of any help!
 
library(cubature)

k = 0.618079
rho = 0.402193
k1 = (1+s^2/4)^2.5
k2 = 4*(1-rho)^0.5

f1 = function(r,s)
{
(k*k1*(1+(r^2)/4)^2.5*(1+(s^2-2*rho*s*r+r^2)/k2)^-2.5
}
##I need to integrate the above twice from (-inf , qt(0.75,4)) wrt s and (-inf , qt(v,4)) wrt r.
Finally i require an expression in v, which i then need to integrate from (0,1).

I'd be glad of any help!

What's qt(0.75,4)?
 
k1 = (1+s^2/4)^2.5
k2 = 4*(1-rho)^0.5

These, I think, are your problem. I think you want to define k1, k2 as functions of s, as at the moment k1, k2 will just become vectors containing whatever values of s are currently in memory.
 
qt is the quantile function in r.
i just used k1 and k2 for convenience,
i've tried it with the constants plugged in, in the
equation, and was still unable to do it.
 
Is the Euler Math Toolbox a good substitute for matlab??
Any idea if it would help me??
 
Back
Top