I want to solve the following in R:
& int; 0 H [? ( t ) & int; t H A ( x ) dx] dt
Where & pi; (t) is the preceding, and A (x) is the function A defined below.
prior <- function(t) dbeta(t, 1, 24) A <- function(x) dbeta(x, 1, 4) expected_loss <- function(H){ integrand <- function(t) prior(t) * integrate(A, lower = t, upper = H)$value loss <- integrate(integrand, lower = 0, upper = H)$value return(loss) }
Since & pi; (t), A (x)> 0, expected_loss (.5) must be less than expected_loss (1). But this is not what I get:
> expected_loss(.5) [1] 0.2380371 > expected_loss(1) [1] 0.0625
I'm not sure what I'm doing wrong.
source share