function [cm,xo] = randopt(fcn,x,io,x0,tmax)
% [cm,xo] = randopt(fcn,x,io,x0,tmax)
% Starting from x0 a parameter is chosen at random and a normally distributed 
% step.  If the cost function fcn at this new point is less than at the former 
% point, the next step is chosen starting from this point otherwise from the 
% former.
%
% fcn     :  string defining the cost function.  All parameters of fcn 
%            must be called within the string fcn as x(1), x(2), x(3), ... 
%
% x       :  vector of parameters of fcn.  
%            Although the parameters within fcn are named x(i) the actual 
%            parameter set for this formal x may be an arbitrary named vector.
%            The value of x(io(:)) are arbitrary since they are variied for 
%            optimization.
%
% io      :  vector of indices. The parameters x(io(1)) to x(io(end)) 
%            are variied to find the desired optimum
%
% x0      :  2*n-matrix:
% x0(1,:) :  starting point x(io(:))
% x0(2,:) :  standard deviation of the parameter for the random steps
%
% tmax    :  at least after tmax seconds the iteration shall stop
