Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

pdl::opt::simplex(3) [redhat man page]

Simplex(3)						User Contributed Perl Documentation						Simplex(3)

NAME
PDL::Opt::Simplex -- Simplex optimization routines SYNOPSIS
use PDL::Opt::Simplex; ($optimum,$ssize) = simplex($init,$initsize,$minsize, $maxiter, sub {evaluate_func_at($_[0])}, sub {display_simplex($_[0])} ); DESCRIPTION
This package implements the commonly used simplex optimization algorithm. The basic idea of the algorithm is to move a "simplex" of N+1 points in the N-dimensional search space according to certain rules. The main benefit of the algorithm is that you do not need to calculate the derivatives of your function. $init is a 1D vector holding the initial values of the N fitted parameters, $optimum is a vector holding the final solution. $initsize is the size of $init (more...) $minsize is some sort of convergence criterion (more...) - e.g. $minsize = 1e-6 The sub is assumed to understand more than 1 dimensions and threading. Its signature is 'inp(nparams); [ret]out()'. An example would be sub evaluate_func_at { my($xv) = @_; my $x1 = $xv->slice("(0)"); my $x2 = $xv->slice("(1)"); return $x1**4 + ($x2-5)**4 + $x1*$x2; } Here $xv is a vector holding the current values of the parameters being fitted which are then sliced out explicitly as $x1 and $x2. $ssize gives a very very approximate estimate of how close we might be - it might be miles wrong. It is the euclidean distance between the best and the worst vertices. If it is not very small, the algorithm has not converged. FUNCTIONS
simplex Simplex optimization routine ($optimum,$ssize) = simplex($init,$initsize,$minsize, $maxiter, sub {evaluate_func_at($_[0])}, sub {display_simplex($_[0])} ); See module "PDL::Opt::Simplex" for more information. CAVEATS
Do not use the simplex method if your function has local minima. It will not work. Use genetic algorithms or simulated annealing or conju- gate gradient or momentum gradient descent. They will not really work either but they are not guaranteed not to work ;) (if you have infinite time, simulated annealing is guaranteed to work but only after it has visited every point in your space). SEE ALSO
Ron Shaffer's chemometrics web page and references therein: "http://chem1.nrl.navy.mil/~shaffer/chemoweb.html". Numerical Recipes (bla bla bla XXX ref). The demonstration (Examples/Simplex/tsimp.pl and tsimp2.pl). AUTHOR
Copyright(C) 1997 Tuomas J. Lukka. All rights reserved. There is no warranty. You are allowed to redistribute this software / documenta- tion under certain conditions. For details, see the file COPYING in the PDL distribution. If this file is separated from the PDL distribu- tion, the copyright notice should be included in the file. perl v5.8.0 2000-05-30 Simplex(3)

Check Out this Related Man Page

Gaussian(3)						User Contributed Perl Documentation					       Gaussian(3)

NAME
PDL::Gaussian -- Gaussian distributions. SYNOPSIS
$a = new PDL::Gaussian([3],[5]); $a->set_covariance(...) DESCRIPTION
This package provides a set of standard routines to handle sets gaussian distributions. A new set of gaussians is initialized by $a = new PDL::Gaussian(xdims,gdims); Where xdims is a reference to an array containing the dimensions in the space the gaussian is in and gdimslist is a reference to an array containing the dimensionality of the gaussian space. For example, after $a = new PDL::Gaussian([2],[3,4]); $b = new PDL::Gaussian([],[]); The variable $a contains set of 12 (="3*4") 2-Dimensional gaussians and $b is the simplest form: one 1D gaussian. Currently, xdims may containe either zero or one dimensions due to limitations of PDL::PP. To set the distribution parameters, you can use the routines $a->set_covariance($cv); # covariance matrices $a->set_icovariance($icv); # inverse covariance matrices $a->set_mu($mu); # centers The dimensions of $cv and $icv must be "(@xdims,@xdims,@gdims)" and the dimensions of $mu must be "(@xdims,@gdims)". Alternatively you can use the routines $cv = $a->get_covariance(); # cv = reference to covariance matrix ... # Fuzz around with cv $a->upd_covariance(); # update and similarly for "icovariance" (inverse covariance). The last sub call is important to update the other parts of the object. To get a string representation of the gaussians (most useful for debugging) use the routine $string = $a->asstr(); It is possible to calculate the probability or logarithm of probability of each of the distributions at some points. $a->calc_value($x,$p); $a->calc_lnvalue($x,$p); Here, $x must have dimensions "(ndims,...)" and $p must have dimensions "(gdimslist, ...)" where the elipsis represents the same dimensions in both variables. It is usually advisable to work with the logarithms of probabilities to avoid numerical problems. It is possible to generate the parameters for the gaussians from data. The function $a->fromweighteddata($data,$wt,$small_covariance); where $data is of dimensions "(ndims,npoints)" and $wt is of dimensions "(npoints,gdimslist)", analyzes the data statistically and gives a corresponding gaussian distribution. The parameter $small_covariance is the smallest allowed covariance in any direction: if one or more of the eigenvalues of the covariance matrix are smaller than this, they are automatically set to $small_covariance to avoid singularities. BUGS
Stupid interface. Limitation to 1 x-dimensions is questionable (although it's hard to imagine a case when more is needed). Note that this does not mean that you can only have 1-dimensional gaussians. It just means that if you want to have a 6-dimensional gaussian, your xs must be structured like (6) and not (2,3). So clumping the dimensions should make things workable. Also, it limits you so that even if you have one variable, you need to have the '1' dimensions explicitly everywhere. Singular distributions are not handled. This should use SVD and be able to handle both infinitely narrow and wide dimensions, preferably so that infinitely narrow dimensions can be queried like "$a-"relations()> or something like that. The routines should, if the user requests for it, check all the dimensions of the given arguments for reasonability. AUTHOR
Copyright (C) 1996 Tuomas J. Lukka (lukka@fas.harvard.edu) All rights reserved. There is no warranty. You are allowed to redistribute this software / documentation under certain conditions. For details, see the file COPYING in the PDL distribution. If this file is separated from the PDL distribution, the copyright notice should be included in the file. perl v5.8.0 2000-04-29 Gaussian(3)
Man Page