1Minuit(3)             User Contributed Perl Documentation            Minuit(3)
2
3
4

NAME

6       PDL::Minuit -- a PDL interface to the Minuit library
7

DESCRIPTION

9       This package implements an interface to the Minuit minimization
10       routines (part of the CERN Library)
11

SYNOPSIS

13       A basic fit with Minuit will call three functions in this package.
14       First, a basic initialization is done with mn_init(). Then, the
15       parameters are defined via the function mn_def_pars(), which allows
16       setting upper and lower bounds. Then the function mn_excm() can be used
17       to issue many Minuit commands, including simplex and migrad
18       minimization algorithms (see Minuit manual for more details).
19
20       See the test file minuit.t in the test (t/) directory for a basic
21       example.
22

FUNCTIONS

24   mninit
25         Signature: (int a();int b(); int c())
26
27       info not available
28
29       mninit does not process bad values.  It will set the bad-value flag of
30       all output piddles if the flag is set for any of the input piddles.
31
32   mn_abre
33         Signature: (int l(); char* nombre; char* mode)
34
35       info not available
36
37       mn_abre does not process bad values.  It will set the bad-value flag of
38       all output piddles if the flag is set for any of the input piddles.
39
40   mn_cierra
41         Signature: (int l())
42
43       info not available
44
45       mn_cierra does not process bad values.  It will set the bad-value flag
46       of all output piddles if the flag is set for any of the input piddles.
47
48   mnparm
49         Signature: (int a(); double b(); double c(); double d(); double e(); int [o] ia(); char* str)
50
51       info not available
52
53       mnparm does not process bad values.  It will set the bad-value flag of
54       all output piddles if the flag is set for any of the input piddles.
55
56   mnexcm
57         Signature: (double a(n); int ia(); int [o] ib(); char* str; SV* function; int numelem)
58
59       info not available
60
61       mnexcm does not process bad values.  It will set the bad-value flag of
62       all output piddles if the flag is set for any of the input piddles.
63
64   mnpout
65         Signature: (int ia(); double [o] a(); double [o] b(); double [o] c(); double [o] d();int [o] ib(); SV* str)
66
67       info not available
68
69       mnpout does not process bad values.  It will set the bad-value flag of
70       all output piddles if the flag is set for any of the input piddles.
71
72   mnstat
73         Signature: (double [o] a(); double [o] b(); double [o] c(); int [o] ia(); int [o] ib(); int [o] ic())
74
75       info not available
76
77       mnstat does not process bad values.  It will set the bad-value flag of
78       all output piddles if the flag is set for any of the input piddles.
79
80   mnemat
81         Signature: (double [o] mat(n,n))
82
83       info not available
84
85       mnemat does not process bad values.  It will set the bad-value flag of
86       all output piddles if the flag is set for any of the input piddles.
87
88   mnerrs
89         Signature: (int ia(); double [o] a(); double [o] b(); double [o] c(); double [o] d())
90
91       info not available
92
93       mnerrs does not process bad values.  It will set the bad-value flag of
94       all output piddles if the flag is set for any of the input piddles.
95
96   mncont
97         Signature: (int ia(); int ib(); int ic(); double [o] a(n); double [o] b(n); int [o] id(); SV* function; int numelem)
98
99       info not available
100
101       mncont does not process bad values.  It will set the bad-value flag of
102       all output piddles if the flag is set for any of the input piddles.
103
104   mn_init()
105       The function mn_init() does the basic initialization of the fit. The
106       first argument has to be a reference to the function to be minimized.
107       The function to be minimized has to receive five arguments
108       ($npar,$grad,$fval,$xval,$iflag). The first is the number of parameters
109       currently variable. The second is the gradient of the function (which
110       is not necessarily used, see the Minuit documentation). The third is
111       the current value of the function. The fourth is a piddle with the
112       values of the parameters.  The fifth is an integer flag, which
113       indicates what the function is supposed to calculate. The function has
114       to return the  values ($fval,$grad), the function value and the
115       function gradient.
116
117       There are three optional arguments to mn_init(). By default, the output
118       of Minuit will come through STDOUT unless a filename $logfile is given
119       in the Log option. Note that this will mercilessly erase $logfile if it
120       already exists. Additionally, a title can be given to the fit by the
121       Title option, the default is 'Minuit Fit'. If the output is written to
122       a logfile, this is assigned Fortran unit number 88. If for whatever
123       reason you want to have control over the unit number that Fortran
124       associates to the logfile, you can pass the number through the Unit
125       option.
126
127       Usage:
128
129        mn_init($function_ref,{Log=>$logfile,Title=>$title,Unit=>$unit})
130
131       Example:
132
133        mn_init(\&my_function);
134
135        #same as above but outputting to a file 'log.out'.
136        #title for fit is 'My fit'
137        mn_init(\&my_function,
138                {Log => 'log.out', Title => 'My fit'});
139
140
141        sub my_function{
142           # the five variables input to the function to be minimized
143           # xval is a piddle containing the current values of the parameters
144           my ($npar,$grad,$fval,$xval,$iflag) = @_;
145
146
147           # Here is code computing the value of the function
148           # and potentially also its gradient
149           # ......
150
151           # return the two variables. If no gradient is being computed
152           # just return the $grad that came as input
153           return ($fval, $grad);
154        }
155
156   mn_def_pars()
157       The function mn_def_pars() defines the initial values of the parameters
158       of the function to be minimized and the value of the initial steps
159       around these values that the minimizer will use for the first
160       variations of the parameters in the search for the minimum.  There are
161       several optional arguments. One allows assigning names to these
162       parameters which otherwise get names (Par_0, Par_1,....,Par_n) by
163       default. Another two arguments can give lower and upper bounds for the
164       parameters via two piddles. If the lower and upper bound for a given
165       parameter are both equal to 0 then the parameter is unbound. By default
166       these lower and upper bound piddles are set to  zeroes(n), where n is
167       the number of parameters, i.e. the parameters are unbound by default.
168
169       The function needs two input variables: a piddle giving the initial
170       values of the parameters and another piddle giving the initial steps.
171       An optional reference to a perl array with the  variable names can be
172       passed, as well as piddles with upper and lower bounds for the
173       parameters (see example below).
174
175       It returns an integer variable which is 0 upon success.
176
177       Usage:
178
179        $iflag = mn_def_pars($pars, $steps,{Names => \@names,
180                               Lower_bounds => $lbounds,
181                               Upper_bounds => $ubounds})
182
183       Example:
184
185        #initial parameter values
186        my $pars = pdl(2.5,3.0);
187
188        #steps
189        my $steps = pdl(0.3,0.5);
190
191        #parameter names
192        my @names = ('intercept','slope');
193
194        #use mn_def_pars with default parameter names (Par_0,Par_1,...)
195        my $iflag = mn_def_pars($pars,$steps);
196
197        #use of mn_def_pars explicitly specify parameter names
198        $iflag = mn_def_pars($pars,$steps,{Names => \@names});
199
200        # specify lower and upper bounds for the parameters.
201        # The example below leaves parameter 1 (intercept) unconstrained
202        # and constrains parameter 2 (slope) to be between 0 and 100
203        my $lbounds = pdl(0, 0);
204        my $ubounds = pdl(0, 100);
205
206        $iflag = mn_def_pars($pars,$steps,{Names => \@names,
207                               Lower_bounds => $lbounds,
208                               Upper_bounds => $ubounds}});
209
210        #same as above because $lbounds is by default zeroes(n)
211        $iflag = mn_def_pars($pars,$steps,{Names => \@names,
212                               Upper_bounds => $ubounds}});
213
214   mn_excm()
215       The function mn_excm() executes a Minuit command passed as a string.
216       The first argument is the command string and an optional second
217       argument is a piddle with arguments to the command.  The available
218       commands are listed in Chapter 4 of the Minuit manual (see url below).
219
220       It returns an integer variable which is 0 upon success.
221
222       Usage:
223
224        $iflag = mn_excm($command_string, {$arglis})
225
226       Example:
227
228         #start a simplex minimization
229         my $iflag = mn_excm('simplex');
230
231         #same as above but specify the maximum allowed numbers of
232         #function calls in the minimization
233         my $arglist = pdl(1000);
234         $iflag = mn_excm('simplex',$arglist);
235
236         #start a migrad minimization
237         $iflag = mn_excm('migrad')
238
239         #set Minuit strategy in order to get the most reliable results
240         $arglist = pdl(2)
241         $iflag = mn_excm('set strategy',$arglist);
242
243         # each command can be specified by a minimal string that uniquely
244         # identifies it (see Chapter 4 of Minuit manual). The comannd above
245         # is equivalent to:
246         $iflag = mn_excm('set stra',$arglis);
247
248   mn_pout()
249       The function mn_pout() gets the current value of a parameter. It takes
250       as input the parameter number and returns an array with the parameter
251       value, the current estimate of its uncertainty (0 if parameter is
252       constant), lower bound on the parameter, if any (otherwise 0), upper
253       bound on the parameter, if any (otherwise 0), integer flag (which is
254       equal to the parameter number if variable, zero if the parameter is
255       constant and negative if parameter is not defined) and the parameter
256       name.
257
258       Usage:
259
260            ($val,$err,$bnd1,$bnd2,$ivarbl,$par_name) = mn_pout($par_number);
261
262   mn_stat()
263       The function mn_stat() gets the current status of the minimization.  It
264       returns an array with the best function value found so far, the
265       estimated vertical distance remaining to minimum, the value of UP
266       defining parameter uncertainties (default is 1), the number of
267       currently variable parameters, the highest parameter defined and an
268       integer flag indicating how good the covariance matrix is (0=not
269       calculated at all; 1=diagonal approximation, not accurate; 2=full
270       matrix, but forced positive definite; 3=full accurate matrix)
271
272       Usage:
273
274           ($fmin,$fedm,$errdef,$npari,$nparx,$istat) = mn_stat();
275
276   mn_emat()
277       The function mn_emat returns the covariance matrix as a piddle.
278
279       Usage:
280
281         $emat = mn_emat();
282
283   mn_err()
284       The function mn_err() returns the current existing values for the error
285       in the fitted parameters. It returns an array with the positive error,
286       the negative error, the "parabolic" parameter error from the error
287       matrix and the global correlation coefficient, which is a number
288       between 0 and 1 which gives the correlation between the requested
289       parameter and that linear combination of all other parameters which is
290       most strongly correlated with it. Unless the command 'MINOS' has been
291       issued via the function mn_excm(), the first three values will be
292       equal.
293
294       Usage:
295
296         ($eplus,$eminus,$eparab,$globcc) = mn_err($par_number);
297
298   mn_contour()
299       The function mn_contour() finds contours of the function being
300       minimized with respect to two chosen parameters. The contour level is
301       given by F_min + UP, where F_min is the minimum of the function and UP
302       is the ERRordef specified by the user, or 1.0 by default (see Minuit
303       manual). The contour calculated by this function is dynamic, in the
304       sense that it represents the minimum of the function being minimized
305       with respect to all the other NPAR-2 parameters (if any).
306
307       The function takes as input the parameter numbers with respect to which
308       the contour is to be determined (two) and the number of points $npt
309       required on the contour (>4).  It returns an array with piddles
310       $xpt,$ypt containing the coordinates of the contour and a variable
311       $nfound indicating the number of points actually found in the contour.
312       If all goes well $nfound will be equal to $npt, but it can be negative
313       if the input arguments are not valid, zero if less than four points
314       have been found or <$npt if the program could not find $npt points.
315
316       Usage:
317
318         ($xpt,$ypt,$nfound) = mn_contour($par_number_1,$par_number_2,$npt)
319

SEE ALSO

321       PDL
322
323       The Minuit documentation is online at
324
325         http://wwwasdoc.web.cern.ch/wwwasdoc/minuit/minmain.html
326

AUTHOR

328       This file copyright (C) 2007 Andres Jordan <ajordan@eso.org>.  All
329       rights reserved. There is no warranty. You are allowed to redistribute
330       this software/documentation under certain conditions. For details, see
331       the file COPYING in the PDL distribution. If this file is separated
332       from the PDL distribution, the copyright notice should be included in
333       the file.
334
335
336
337perl v5.32.0                      2020-09-17                         Minuit(3)
Impressum