Last active
January 25, 2017 17:19
-
-
Save pn11/c87a95f687160cca291da6dfda1d4a9c to your computer and use it in GitHub Desktop.
TMinuit の使い方 ref: http://qiita.com/pn11/items/36af3e3067f5d11f18eb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
x^2+x |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <string> | |
using namespace std; | |
#include "TMinuit.h" | |
void chi2(Int_t &npar, Double_t *gin, Double_t &f, Double_t *par, Int_t iflag){ | |
f = par[0]*par[0] + par[0] + 1; | |
} | |
int main (){ | |
TMinuit *min = new TMinuit(1); | |
min->SetPrintLevel(1); | |
double par, parErr; | |
string parName = "test_para"; | |
double stepSize = 0.1, minVal = -100.0, maxVal = 100.0; | |
min->DefineParameter(0, parName.c_str(), par, stepSize, minVal, maxVal); | |
min->SetFCN(chi2); | |
int migrad_stats = min->Migrad(); | |
min->GetParameter(0, par, parErr); | |
cout << "Result: " <<par << " +/- " << parErr << endl; | |
cout << "Status of Migrad: " << migrad_stats << endl; | |
delete min; | |
return 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
********** | |
** 1 **SET PRINT 100 | |
********** | |
PARAMETER DEFINITIONS: | |
NO. NAME VALUE STEP SIZE LIMITS | |
1 test_para 2.10781e-317 1.00000e-01 -1.00000e+02 1.00000e+02 | |
********** | |
** 2 **MIGRAD | |
********** | |
FIRST CALL TO USER FUNCTION AT NEW START POINT, WITH IFLAG=4. | |
START MIGRAD MINIMIZATION. STRATEGY 1. CONVERGENCE WHEN EDM .LT. 1.00e-04 | |
FCN=1 FROM MIGRAD STATUS=INITIATE 4 CALLS 5 TOTAL | |
EDM= unknown STRATEGY= 1 NO ERROR MATRIX | |
EXT PARAMETER CURRENT GUESS STEP FIRST | |
NO. NAME VALUE ERROR SIZE DERIVATIVE | |
1 test_para 0.00000e+00 1.00000e-01 1.00000e-03 1.00000e+02 | |
NO ERROR MATRIX | |
FCN=0.75 FROM MIGRAD STATUS=PROGRESS 7 CALLS 8 TOTAL | |
EDM=1.74834e-11 STRATEGY= 1 NO ERROR MATRIX | |
EXT PARAMETER CURRENT GUESS STEP FIRST | |
NO. NAME VALUE ERROR SIZE DERIVATIVE | |
1 test_para -4.99998e-01 1.00000e-01 -5.00000e-03 4.18132e-04 | |
RELATIVE CHANGE IN COV. MATRIX= 50.0 per cent | |
MIGRAD MINIMIZATION HAS CONVERGED. | |
MIGRAD WILL VERIFY CONVERGENCE AND ERROR MATRIX. | |
START COVARIANCE MATRIX CALCULATION. | |
EIGENVALUES OF SECOND-DERIVATIVE MATRIX: | |
1.0000e+00 | |
COVARIANCE MATRIX CALCULATED SUCCESSFULLY | |
FCN=0.75 FROM MIGRAD STATUS=CONVERGED 12 CALLS 13 TOTAL | |
EDM=8.74186e-12 STRATEGY= 1 ERROR MATRIX ACCURATE | |
EXT PARAMETER STEP FIRST | |
NO. NAME VALUE ERROR SIZE DERIVATIVE | |
1 test_para -4.99998e-01 9.99983e-01 6.45935e-06 4.18130e-04 | |
EXTERNAL ERROR MATRIX. NDIM= 25 NPAR= 1 ERR DEF=1 | |
1.000e+00 | |
Result: -0.499998 +/- 0.999983 | |
Status of Migrad: 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment