Diferenças
Aqui você vê as diferenças entre duas revisões dessa página.
Ambos lados da revisão anteriorRevisão anterior | |||
disciplinas:ce709-2010 [2010/10/20 21:55] – peccin | disciplinas:ce709-2010 [2010/10/20 21:58] (atual) – peccin | ||
---|---|---|---|
Linha 118: | Linha 118: | ||
[[disciplinas: | [[disciplinas: | ||
- | |||
- | |||
- | dados | ||
- | plot(conc~dist) | ||
- | |||
- | c0 <- 600 | ||
- | u <- 0.017 | ||
- | d <- 0.255 | ||
- | k <- 0.0002 | ||
- | |||
- | curve(c0*(exp((u*x/ | ||
- | |||
- | # exemplo de uso da optim() | ||
- | cy=(c0*(exp((u*x/ | ||
- | |||
- | |||
- | # | ||
- | # definição da função objetivo | ||
- | |||
- | fun.objetivo <- function(theta, | ||
- | sum((conc-(theta[1]*(exp((theta[2]*dist/ | ||
- | } | ||
- | |||
- | |||
- | # | ||
- | # escolha de valores iniciais | ||
- | |||
- | start <- c(600, | ||
- | start <- c(577, | ||
- | start <- c(300, | ||
- | |||
- | # | ||
- | # optimização da função objetivo | ||
- | |||
- | opt <- optim(start, | ||
- | opt | ||
- | |||
- | curve(opt$par[1]*(exp((opt$par[2]*x/ | ||
- | |||
- | |||
- | |||
- | opt$value | ||
- | |||
- | |||
- | # | ||
- | # usando outra função objetivo | ||
- | |||
- | fun.objetivo <- function(theta, | ||
- | n <- length(conc) | ||
- | -(-n/ | ||
- | - sum(((conc-(theta[1]*(exp((theta[2]*dist/ | ||
- | } | ||
- | |||
- | |||
- | |||
- | # | ||
- | # os chutes | ||
- | start <- c(577, | ||
- | start <- c(3, | ||
- | |||
- | # | ||
- | # optimização | ||
- | |||
- | opt <- optim(start, | ||
- | opt | ||
- | |||
- | curve(opt$par[1]*(exp((opt$par[2]*x/ | ||
- | |||
- | # | ||
- | |||
- | UTILIZANDO O NLS | ||
- | |||
- | mod=nls(conc~(c0*(exp((u*dist/ | ||
- | |||
- | |||
- | |||