[R] maxima

Thomas Petzoldt thpe at hhbio.wasser.tu-dresden.de
Tue Mar 9 11:31:28 CET 2004


Z P wrote:
> Dear all,
> 
> suppose I have a bi-variate function f(x,y), I want to find the maxima. 
> I define x and y vector, and get matrix z=f(x,y). how can I get which 
> (x0,y0) makes z become the maxima?

If you have function values as matrix, you may simply use:

which(z==max(z), arr.ind=TRUE)

or you can consider to use an optimization algorithm directly on your 
function, see ?optim or ?nlm.

Hope it helps

Thomas P.




More information about the R-help mailing list