[R] Optimize function in R: unable to find maximum of logistic function
Rui Barradas
ruipbarradas at sapo.pt
Mon Oct 28 21:49:29 CET 2013
Hello,
This seems like a bug, removing 'maximum = TRUE' has no effect except
that the returned value says it's a minimum, not a maximum.
Rui Barradas
Em 28-10-2013 17:00, Shantanu MULLICK escreveu:
> Hello Everyone,
>
> I want to perform a 1-D optimization by using the optimize() function. I
> want to find the maximum value of a "logistic" function. The optimize()
> function gives the wrong result.
>
> My code:
> f= function (k) {
> T_s = 20
> result = (2- 2/(1+ exp(-2*T_s*k)))
> return(result)
> }
> optimize(f, c(0, 5), tol = 0.0000000000001, maximum= TRUE)
>
> The maximum value for the function happens at k=0, and the maximum value is
> 1. Yet the optimise function, says that the maximum value happens at k=
> 4.9995, and the maximum value is 0.
>
> Thanks in advance!
>
> Warm Regards,
> Shantanu
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
More information about the R-help
mailing list