example of fitting a 3D function Typical multidimensional parametric regression where the predictor depends on 3 variables 
In the case of 1 or 2D one can use the TGraph classes but since no TGraph3D class exists this tutorial provide an example of fitting 3D points
 
****************************************
Minimizer is Minuit2 / Migrad
Chi2                      =      993.065
NDf                       =          997
Edm                       =   2.2677e-24
NCalls                    =            7
p0                        =     0.993546   +/-   0.00475134  
p1                        =      0.99397   +/-   0.00434249  
p2                        =     0.997895   +/-   0.000545663 
Good fit : p-value  = 0.529221
   
 
 
 
 
   
   for (
int i = 0; i < 
n; ++i) {
 
      v[i] = sin(
x[i] ) + cos(
y[i]) + z[i] + 
r.Gaus(0,
ev);
 
   }
 
   
   for(
int i = 0; i < 
n; ++i) {
 
      
   }
 
   TF3 * f3 = 
new TF3(
"f3",
"[0] * sin(x) + [1] * cos(y) + [2] * z",0,10,0,10,0,10);
 
   
   
      
      
      
         Error(
"exampleFit3D",
"Bad data fit - fit p-value is %f",
prob);
 
      else
         std::cout << 
"Good fit : p-value  = " << 
prob << std::endl;
 
 
   }
   else
      Error(
"exampleFit3D",
"3D fit failed");
 
}
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
 
void Error(const char *location, const char *msgfmt,...)
Use this function in case an error occurred.
 
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
 
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t r
 
Class describing the binned data sets : vectors of x coordinates, y values and optionally error on y ...
 
class containing the result of the fit and all the related information (fitted parameter values,...
 
void Print(std::ostream &os, bool covmat=false) const
print the result and optionally covariance matrix and correlations
 
double Prob() const
p value of the fit (chi2 probability)
 
Fitter class, entry point for performing all type of fits.
 
const FitResult & Result() const
get fit result
 
bool Fit(const Data &data, const Function &func, const ROOT::EExecutionPolicy &executionPolicy=ROOT::EExecutionPolicy::kSequential)
fit a data set using any generic model function If data set is binned a least square fit is performed...
 
void SetFunction(const IModelFunction &func, bool useGradient=false)
Set the fitted function (model function) from a parametric function interface.
 
virtual void SetParameters(const Double_t *params)
 
virtual void SetFitResult(const ROOT::Fit::FitResult &result, const Int_t *indpar=nullptr)
Set the result from the fit parameter values, errors, chi2, etc... Optionally a pointer to a vector (...
 
A 3-Dim function with parameters.
 
Random number generator class based on the maximally quidistributed combined Tausworthe generator by ...
 
- Author
 - Lorenzo Moneta 
 
Definition in file exampleFit3D.C.