Guest User

Untitled

a guest
Aug 28th, 2016
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. funk <- function(x,b) { 10^b * exp(-x/10) }
  2.  
  3. lambda <- function(y,k) { exp(-k*y) }
  4.  
  5. funk1 <- function(y,x,xb,b,k) {
  6. funk(x-xb-y,b) *exp(- integrate(lambda, lower=0, upper = y, k=k)$value) }
  7.  
  8. funk2 <-function(x,xb,b,k) {
  9. integrate(funk1, lower= 0, upper=x-xb, x=x,xb=xb, b=b,k=k)$value }
  10.  
  11. funk2_vc <- Vectorize(funk2)
  12.  
  13. optim_funk2 <- function(param,x,xb) {
  14. b <-param[1]
  15. k <- param[2]
  16. R1 <- sum((y - funk2_vc(xx,xb,b,k))^2)
  17. -log(R1) }
  18.  
  19. fit <- optim(par=c(5, 0.05), fn=optim_funk2)
  20.  
  21. xx <- seq(0,500,5)
  22. xb <- seq(0,100,1)
  23. y <- seq(1000,0,-10)
Add Comment
Please, Sign In to add comment