Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- funk <- function(x,b) { 10^b * exp(-x/10) }
- lambda <- function(y,k) { exp(-k*y) }
- funk1 <- function(y,x,xb,b,k) {
- funk(x-xb-y,b) *exp(- integrate(lambda, lower=0, upper = y, k=k)$value) }
- funk2 <-function(x,xb,b,k) {
- integrate(funk1, lower= 0, upper=x-xb, x=x,xb=xb, b=b,k=k)$value }
- funk2_vc <- Vectorize(funk2)
- optim_funk2 <- function(param,x,xb) {
- b <-param[1]
- k <- param[2]
- R1 <- sum((y - funk2_vc(xx,xb,b,k))^2)
- -log(R1) }
- fit <- optim(par=c(5, 0.05), fn=optim_funk2)
- xx <- seq(0,500,5)
- xb <- seq(0,100,1)
- y <- seq(1000,0,-10)
Add Comment
Please, Sign In to add comment