On 01.02.19 10:00, Martin Maechler wrote: >> f <- function(x) sum( log(diff(x)^2+.01) + (x[1]-1)^2 ) >> opt <- nlminb(rep(0, 10), f, lower=-1, upper=3) >> str(opt) > List of 6 > $ par : num [1:10] 1 1 1 1 1 ... > $ objective : num -41.4 > $ convergence: int 0 > $ iterations : int 66 > $ evaluations: Named int [1:2] 96 830 > ..- attr(*, "names")= chr [1:2] "function" "gradient" > $ message : chr "relative convergence (4)" >> xhat <- rep(1, 10) >> all.equal(opt$par, xhat, tol=0) # good: 5.53 e-7 > [1] "Mean relative difference: 5.534757e-07" >> all.equal(opt$objective, f(xhat), tol=0) # good: 1.8 e-12 > [1] "Mean relative difference: 1.816536e-12" >> abs( opt$objective - f(xhat) ) < 1e-4 ## Must be TRUE > [1] TRUE >> > > for me. Maybe others can quickly run the above 7 lines and report ?
Similar but not equal results for me: > f <- function(x) sum( log(diff(x)^2+.01) + (x[1]-1)^2 ) > opt <- nlminb(rep(0, 10), f, lower=-1, upper=3) > str(opt) List of 6 $ par : num [1:10] 1 1 1 1 1 ... $ objective : num -41.4 $ convergence: int 0 $ iterations : int 66 $ evaluations: Named int [1:2] 96 830 ..- attr(*, "names")= chr [1:2] "function" "gradient" $ message : chr "relative convergence (4)" > xhat <- rep(1, 10) > all.equal(opt$par, xhat, tol=0) # good: 5.53 e-7 [1] "Mean relative difference: 3.266165e-07" > all.equal(opt$objective, f(xhat), tol=0) # good: 1.8 e-12 [1] "Mean relative difference: 6.722005e-13" > abs( opt$objective - f(xhat) ) < 1e-4 ## Must be TRUE [1] TRUE Setup: * Debian Stable with gcc 6.2 * R 3.5.2 from CRAN repository * OpenBLAS Greetings Ralf -- Ralf Stubner Senior Software Engineer / Trainer daqana GmbH Dortustraße 48 14467 Potsdam T: +49 331 23 61 93 11 F: +49 331 23 61 93 90 M: +49 162 20 91 196 Mail: ralf.stub...@daqana.com Sitz: Potsdam Register: AG Potsdam HRB 27966 Ust.-IdNr.: DE300072622 Geschäftsführer: Dr.-Ing. Stefan Knirsch, Prof. Dr. Dr. Karl-Kuno Kunze
signature.asc
Description: OpenPGP digital signature
______________________________________________ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel