.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Minuit 3pm" .TH Minuit 3pm "2023-06-17" "perl v5.36.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" PDL::Minuit \-\- a PDL interface to the Minuit library .SH "DESCRIPTION" .IX Header "DESCRIPTION" This package implements an interface to the Minuit minimization routines (part of the \s-1CERN\s0 Library) .SH "SYNOPSIS" .IX Header "SYNOPSIS" A basic fit with Minuit will call three functions in this package. First, a basic initialization is done with \fBmn_init()\fR. Then, the parameters are defined via the function \fBmn_def_pars()\fR, which allows setting upper and lower bounds. Then the function \fBmn_excm()\fR can be used to issue many Minuit commands, including simplex and migrad minimization algorithms (see Minuit manual for more details). .PP See the test file minuit.t in the test (t/) directory for a basic example. .SH "FUNCTIONS" .IX Header "FUNCTIONS" .SS "mninit" .IX Subsection "mninit" .Vb 1 \& Signature: (longlong a();longlong b(); longlong c()) .Ve .PP info not available .PP mninit does not process bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. .SS "mn_abre" .IX Subsection "mn_abre" .Vb 1 \& Signature: (longlong l(); char* nombre; char* mode) .Ve .PP info not available .PP mn_abre does not process bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. .SS "mn_cierra" .IX Subsection "mn_cierra" .Vb 1 \& Signature: (longlong l()) .Ve .PP info not available .PP mn_cierra does not process bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. .SS "mnparm" .IX Subsection "mnparm" .Vb 1 \& Signature: (longlong a(); double b(); double c(); double d(); double e(); longlong [o] ia(); char* str) .Ve .PP info not available .PP mnparm does not process bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. .SS "mnexcm" .IX Subsection "mnexcm" .Vb 1 \& Signature: (double a(n); longlong ia(); longlong [o] ib(); char* str; SV* function; IV numelem) .Ve .PP info not available .PP mnexcm does not process bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. .SS "mnpout" .IX Subsection "mnpout" .Vb 1 \& Signature: (longlong ia(); double [o] a(); double [o] b(); double [o] c(); double [o] d();longlong [o] ib(); SV* str) .Ve .PP info not available .PP mnpout does not process bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. .SS "mnstat" .IX Subsection "mnstat" .Vb 1 \& Signature: (double [o] a(); double [o] b(); double [o] c(); longlong [o] ia(); longlong [o] ib(); longlong [o] ic()) .Ve .PP info not available .PP mnstat does not process bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. .SS "mnemat" .IX Subsection "mnemat" .Vb 1 \& Signature: (double [o] mat(n,n)) .Ve .PP info not available .PP mnemat does not process bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. .SS "mnerrs" .IX Subsection "mnerrs" .Vb 1 \& Signature: (longlong ia(); double [o] a(); double [o] b(); double [o] c(); double [o] d()) .Ve .PP info not available .PP mnerrs does not process bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. .SS "mncont" .IX Subsection "mncont" .Vb 1 \& Signature: (longlong ia(); longlong ib(); longlong ic(); double [o] a(n); double [o] b(n); longlong [o] id(); SV* function; IV numelem) .Ve .PP info not available .PP mncont does not process bad values. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. .SS "\fBmn_init()\fP" .IX Subsection "mn_init()" The function \fBmn_init()\fR does the basic initialization of the fit. The first argument has to be a reference to the function to be minimized. The function to be minimized has to receive five arguments ($npar,$grad,$fval,$xval,$iflag). The first is the number of parameters currently variable. The second is the gradient of the function (which is not necessarily used, see the Minuit documentation). The third is the current value of the function. The fourth is an ndarray with the values of the parameters. The fifth is an integer flag, which indicates what the function is supposed to calculate. The function has to return the values ($fval,$grad), the function value and the function gradient. .PP There are three optional arguments to \fBmn_init()\fR. By default, the output of Minuit will come through \s-1STDOUT\s0 unless a filename \f(CW$logfile\fR is given in the Log option. Note that this will mercilessly erase \f(CW$logfile\fR if it already exists. Additionally, a title can be given to the fit by the Title option, the default is 'Minuit Fit'. If the output is written to a logfile, this is assigned Fortran unit number 88. If for whatever reason you want to have control over the unit number that Fortran associates to the logfile, you can pass the number through the Unit option. .PP Usage: .PP .Vb 1 \& mn_init($function_ref,{Log=>$logfile,Title=>$title,Unit=>$unit}) .Ve .PP Example: .PP .Vb 1 \& mn_init(\e&my_function); \& \& #same as above but outputting to a file \*(Aqlog.out\*(Aq. \& #title for fit is \*(AqMy fit\*(Aq \& mn_init(\e&my_function, \& {Log => \*(Aqlog.out\*(Aq, Title => \*(AqMy fit\*(Aq}); \& \& sub my_function{ \& # the five variables input to the function to be minimized \& # xval is an ndarray containing the current values of the parameters \& my ($npar,$grad,$fval,$xval,$iflag) = @_; \& \& # Here is code computing the value of the function \& # and potentially also its gradient \& # ...... \& \& # return the two variables. If no gradient is being computed \& # just return the $grad that came as input \& return ($fval, $grad); \& } .Ve .SS "\fBmn_def_pars()\fP" .IX Subsection "mn_def_pars()" The function \fBmn_def_pars()\fR defines the initial values of the parameters of the function to be minimized and the value of the initial steps around these values that the minimizer will use for the first variations of the parameters in the search for the minimum. There are several optional arguments. One allows assigning names to these parameters which otherwise get names (Par_0, Par_1,....,Par_n) by default. Another two arguments can give lower and upper bounds for the parameters via two ndarrays. If the lower and upper bound for a given parameter are both equal to 0 then the parameter is unbound. By default these lower and upper bound ndarrays are set to zeroes(n), where n is the number of parameters, i.e. the parameters are unbound by default. .PP The function needs two input variables: an ndarray giving the initial values of the parameters and another ndarray giving the initial steps. An optional reference to a perl array with the variable names can be passed, as well as ndarrays with upper and lower bounds for the parameters (see example below). .PP It returns an integer variable which is 0 upon success. .PP Usage: .PP .Vb 3 \& $iflag = mn_def_pars($pars, $steps,{Names => \e@names, \& Lower_bounds => $lbounds, \& Upper_bounds => $ubounds}) .Ve .PP Example: .PP .Vb 2 \& #initial parameter values \& my $pars = pdl(2.5,3.0); \& \& #steps \& my $steps = pdl(0.3,0.5); \& \& #parameter names \& my @names = (\*(Aqintercept\*(Aq,\*(Aqslope\*(Aq); \& \& #use mn_def_pars with default parameter names (Par_0,Par_1,...) \& my $iflag = mn_def_pars($pars,$steps); \& \& #use of mn_def_pars explicitly specify parameter names \& $iflag = mn_def_pars($pars,$steps,{Names => \e@names}); \& \& # specify lower and upper bounds for the parameters. \& # The example below leaves parameter 1 (intercept) unconstrained \& # and constrains parameter 2 (slope) to be between 0 and 100 \& my $lbounds = pdl(0, 0); \& my $ubounds = pdl(0, 100); \& \& $iflag = mn_def_pars($pars,$steps,{Names => \e@names, \& Lower_bounds => $lbounds, \& Upper_bounds => $ubounds}}); \& \& #same as above because $lbounds is by default zeroes(n) \& $iflag = mn_def_pars($pars,$steps,{Names => \e@names, \& Upper_bounds => $ubounds}}); .Ve .SS "\fBmn_excm()\fP" .IX Subsection "mn_excm()" The function \fBmn_excm()\fR executes a Minuit command passed as a string. The first argument is the command string and an optional second argument is an ndarray with arguments to the command. The available commands are listed in Chapter 4 of the Minuit manual (see url below). .PP It returns an integer variable which is 0 upon success. .PP Usage: .PP .Vb 1 \& $iflag = mn_excm($command_string, {$arglis}) .Ve .PP Example: .PP .Vb 2 \& #start a simplex minimization \& my $iflag = mn_excm(\*(Aqsimplex\*(Aq); \& \& #same as above but specify the maximum allowed numbers of \& #function calls in the minimization \& my $arglist = pdl(1000); \& $iflag = mn_excm(\*(Aqsimplex\*(Aq,$arglist); \& \& #start a migrad minimization \& $iflag = mn_excm(\*(Aqmigrad\*(Aq) \& \& #set Minuit strategy in order to get the most reliable results \& $arglist = pdl(2) \& $iflag = mn_excm(\*(Aqset strategy\*(Aq,$arglist); \& \& # each command can be specified by a minimal string that uniquely \& # identifies it (see Chapter 4 of Minuit manual). The comannd above \& # is equivalent to: \& $iflag = mn_excm(\*(Aqset stra\*(Aq,$arglis); .Ve .SS "\fBmn_pout()\fP" .IX Subsection "mn_pout()" The function \fBmn_pout()\fR gets the current value of a parameter. It takes as input the parameter number and returns an array with the parameter value, the current estimate of its uncertainty (0 if parameter is constant), lower bound on the parameter, if any (otherwise 0), upper bound on the parameter, if any (otherwise 0), integer flag (which is equal to the parameter number if variable, zero if the parameter is constant and negative if parameter is not defined) and the parameter name. .PP Usage: .PP .Vb 1 \& ($val,$err,$bnd1,$bnd2,$ivarbl,$par_name) = mn_pout($par_number); .Ve .SS "\fBmn_stat()\fP" .IX Subsection "mn_stat()" The function \fBmn_stat()\fR gets the current status of the minimization. It returns an array with the best function value found so far, the estimated vertical distance remaining to minimum, the value of \s-1UP\s0 defining parameter uncertainties (default is 1), the number of currently variable parameters, the highest parameter defined and an integer flag indicating how good the covariance matrix is (0=not calculated at all; 1=diagonal approximation, not accurate; 2=full matrix, but forced positive definite; 3=full accurate matrix) .PP Usage: .PP .Vb 1 \& ($fmin,$fedm,$errdef,$npari,$nparx,$istat) = mn_stat(); .Ve .SS "\fBmn_emat()\fP" .IX Subsection "mn_emat()" The function mn_emat returns the covariance matrix as an ndarray. .PP Usage: .PP .Vb 1 \& $emat = mn_emat(); .Ve .SS "\fBmn_err()\fP" .IX Subsection "mn_err()" The function \fBmn_err()\fR returns the current existing values for the error in the fitted parameters. It returns an array with the positive error, the negative error, the \*(L"parabolic\*(R" parameter error from the error matrix and the global correlation coefficient, which is a number between 0 and 1 which gives the correlation between the requested parameter and that linear combination of all other parameters which is most strongly correlated with it. Unless the command '\s-1MINOS\s0' has been issued via the function \fBmn_excm()\fR, the first three values will be equal. .PP Usage: .PP .Vb 1 \& ($eplus,$eminus,$eparab,$globcc) = mn_err($par_number); .Ve .SS "\fBmn_contour()\fP" .IX Subsection "mn_contour()" The function \fBmn_contour()\fR finds contours of the function being minimized with respect to two chosen parameters. The contour level is given by F_min + \s-1UP,\s0 where F_min is the minimum of the function and \s-1UP\s0 is the ERRordef specified by the user, or 1.0 by default (see Minuit manual). The contour calculated by this function is dynamic, in the sense that it represents the minimum of the function being minimized with respect to all the other \s-1NPAR\-2\s0 parameters (if any). .PP The function takes as input the parameter numbers with respect to which the contour is to be determined (two) and the number of points \f(CW$npt\fR required on the contour (>4). It returns an array with ndarrays \f(CW$xpt\fR,$ypt containing the coordinates of the contour and a variable \f(CW$nfound\fR indicating the number of points actually found in the contour. If all goes well \f(CW$nfound\fR will be equal to \f(CW$npt\fR, but it can be negative if the input arguments are not valid, zero if less than four points have been found or <$npt if the program could not find \f(CW$npt\fR points. .PP Usage: .PP .Vb 1 \& ($xpt,$ypt,$nfound) = mn_contour($par_number_1,$par_number_2,$npt) .Ve .SH "SEE ALSO" .IX Header "SEE ALSO" \&\s-1PDL\s0 .PP The Minuit documentation is online at .PP .Vb 1 \& http://wwwasdoc.web.cern.ch/wwwasdoc/minuit/minmain.html .Ve .SH "AUTHOR" .IX Header "AUTHOR" This file copyright (C) 2007 Andres Jordan . All rights reserved. There is no warranty. You are allowed to redistribute this software/documentation under certain conditions. For details, see the file \&\s-1COPYING\s0 in the \s-1PDL\s0 distribution. If this file is separated from the \&\s-1PDL\s0 distribution, the copyright notice should be included in the file.