Displaying 3 results from an estimated 3 matches for "t1bes1".
Did you mean:
bes1
2010 Feb 09
1
how to adjust the output
...on.
integrand <- function(z)
{ alp <- 2.0165
rho <- 0.868
# simplified expressions
a <- alp-0.5
c1 <- sqrt(pi)/(gamma(alp)*(1-rho)^alp)
c2 <- sqrt(rho)/(1-rho)
t1 <- exp(-z/(1-rho))
t2 <- (z/(2*c2))^a
bes1 <- besselI(z*c2,a)
t1bes1 <- t1*bes1
c1*t1bes1*t2
}
z1 <- 20
cdf <- integrate(integrand, lower = 0, upper = z1,abs.tol = FALSE)
r <- runif(1)
## Newton iteration
z2 <- z1 - (cdf - r)/integrand(z1)
Output
> z1 <- 20
> cdf <- integrate(integrand, lower = 0, upper = z1)
> r ...
2010 Feb 10
1
looping problem
...mDeriv)
fprime <- function(z)
{ alp <- 2.0165;
rho <- 0.868;
# simplified expressions
a <- alp-0.5
c1 <- sqrt(pi)/(gamma(alp)*(1-rho)^alp)
c2 <- sqrt(rho)/(1-rho)
t1 <- exp(-z/(1-rho))
t2 <- (z/(2*c2))^a
bes1 <- besselI(z*c2,a)
t1bes1 <- t1*bes1
c1*t1bes1*t2
}
## Newton iteration
newton_gam <- function(z)
{ n <- length(z)
r <- runif(n)
tol <- 1E-6
cdf <- vector(length=n, mode="numeric")
for (i in 1:1000)
{ # numerical intergration to find the cdf
cdf <- integrate(fprime, lo...
2010 Feb 09
0
For and while in looping
...iv)
fprime <- function(z)
{ alp <- 2.0165;
rho <- 0.868;
# simplified expressions
a <- alp-0.5
c1 <- sqrt(pi)/(gamma(alp)*(1-rho)^alp)
c2 <- sqrt(rho)/(1-rho)
t1 <- exp(-z/(1-rho))
t2 <- (z/(2*c2))^a
bes1 <- besselI(z*c2,a)
t1bes1 <- t1*bes1
c1*t1bes1*t2
}
## Newton iteration
newton_gam <- function(z)
{ n <- length(z)
r <- runif(n)
tol <- 1E-6
for (i in 1:n)
{ # numerical intergration to find the cdf
cdf[i] <- integrate(fprime, lower = 0, upper = z[i])$val
# Newton method...