### Math Libraries

#### Mathcore

- New interface class `ROOT::Math::DistSampler` for generating random number according to a given distribution.
  - The class defines the methods to generate a single number `DistSampler::Sample()`or a data sets `DistSampler::Generate(n, data)`. The data set generation can be unbinned or binned in the given range (only equidistant bins are currently supported)
  - Sampling of 1D or multi-dim distributions is supported via the same interface
  - Derived classes implementing this interface are not provided by MathCore but by other libraries and they can be instantiated using the plugin manager. Implementations based on Unuran and Foam exist.
  - The tutorial `math/multidimSampling.C` is an example on how to use this class
- New class `ROOT::Math::GoFTest` for goodness of fit tests of unbinned data
  - The class implements the Kolmogorov-Smirnov and Anderson-Darling tests for two samples (data vs data ) and one sample (data vs distribution)
  - For the data vs distribution test, the user can compare using a predefined distributions (Gaussian, LogNormal or Exponential) or by passing a user defined PDF or CDF.
  - Example 1: perform a 2 sample GoF test from two arrays, `sample1[n1]` and `sample2[n2]` containing the data

            ROOT::Math::GoFTest goftest(n1, sample1, n2, sample2);
            double pValueAD = goftest.AndersonDarling2SamplesTest();
            double pValueKS = goftest.KolmogorovSmirnov2SamplesTest();

    The class can return optionally also the test statistics instead of the p value.
  - Example 2: perform a 1 sample test with a pre-defined distribution starting from a data set `sample[n]`

            ROOT::Math::GoFTest goftest(n, sample, ROOT::Math::GoFTest::kGaussian);
            double pValueAD = goftest.AndersonDarlingTest();
            double pValueKS = goftest.KolmogorovSmirnovTest();

  - Example 3: perform a 1 sample test with a user-defined distribution provided as cdf

                 ROOT::Math::Functor1D cdf_func(&ROOT::Math::landau_cdf);
                 ROOT::Math::GofTest goftest(n, sample, cdf_func, ROOT::Math::GoFTest::kCDF);
                 double pValueAD = goftest.AndersonDarlingTest();

  - Example 4: perform a 1 sample test with a user-defined distribution provided as pdf. Note that in this case to avoid integration problems is sometimes recommended to give some reasonable xmin and xmax values. xmin (and xmax) should however be smaller (larger) than the minimum (maximum) data value.

                 ROOT::Math::Functor1D pdf_func(&ROOT::Math::landau_pdf);
                 double xmin = 5*TMath::Min_Element(n,sample);
                 double xmax = 5*TMath::Max_Element(n,sample);
                 ROOT::Math::GofTest goftest(n, sample, pdf_func, ROOT::Math::GoFTest::kPDF,xmin,xmax);
                 double pValueAD = goftest.AndersonDarlingTest();

  - The tutorial `math/goftest.C` is an example on how to use the `ROOT::Math::GofTest` class
- New class `TKDTreeBinning` for binning multidimensional data.
  - The class implements multidimensional binning by constructing a TKDTree inner structure form the data which is used as the bins.
  - The bins are retrieved as two double*, one for the minimum bin edges, the other as the maximum bin edges. For one dimension one of these is enough to correctly define the bins. The bin edges of d-dimensional data is a d-tet of the bin's thresholds. For example if d=3 the minimum bin edges of bin b is of the form of the following array: {xbmin, ybmin, zbmin}.
  - Example 1: constructing a TKDTreeBinning object with `sample[dataSize]` containing the data and `dataDim` and `nBins`, multidimension and bin number parameters.

            TKDTreeBinning* fBins = new TKDTreeBinning(dataSize, dataDim, sample, nBins);

  - Example 2: retrieving the bin edges. For the multidimensional case both minimum and maximum ones are necessary for the bins to be well defined

               Double_t* binsMinEdges = fBins->GetBinsMinEdges();
               Double_t* binsMaxEdges = fBins->GetBinsMaxEdges();

    If you wish to retrieve them sorted by their density issue before the earlier getters fBins->SortBinsByDensity();
  - Example 3: retrieving the bin edges of bin `b`. For the multidimensional case both minimum and maximum ones are necessary for the bins to be well defined

              std::pair binEdges = fBins->GetBinEdges(b);

  - Example 4: perform queries on bin `b` information

              Double_t density = GetBinDensity(b);
              Double_t volume  = GetBinVolume(b);
              Double_t* center = GetBinCenter(b);

  - The tutorial `math/kdTreeBinning.C` is an example on how to use this class
- New statistical functions `ROOT::Math::landau_quantile` (inverse of landau cumulative distribution) translated from RANLAN and `ROOT::Math::landau_quantile_c`.
- New statistical functions `ROOT::Math::negative_binomial_pdf` and the cumulative distributions `ROOT::Math::negative_binomial_cdf` and `ROOT::Math::negative_binomial_cdf_c`.
- New special functions: sine and cosine integral, translated by B. List from CERNLIB: `ROOT::Math::sinint` and `ROOT::Math::cosint`
- New classes `ROOT::Math::IOptions` and `ROOT::Math::GenAlgoOptions` for dealing in general with the options for the numerical algorithm. The first one is the interface for the second and defines the setting and retrieval of generic pair of (name,value) options.
- They are used for defining possible extra options for the minimizer, integration and sampler options.
- Integration classes:
  - Fix a bug in the templated method setting the integrand function
  - Use now `IntegrationOneDim::kADAPTIVESINGULAR` as default method for the 1D integration
  - Add the method `IntegrationOneDim::kLEGENDRE` based on the `GaussLegendreIntegrator` class.
  - Implement also for the GaussIntegrator and GaussLegendreIntegrator the undefined and semi-undefined integral using a function transformation as it is done in the GSLIntegrator
  - Fix a bug in `IntegratorOneDim::SetAbsTolerance`
  - New class `ROOT::Math::IntegratorOptions` which can be passed to all integrator allowing the user to give options to the class and in particular default value. Via the support for extra options (with the class `ROOT::Math::IOptions` generic (string,value) options can be used in the base class to define specific options for the implementations. For example for the MCIntegrator class, specific options can now be passed to VEGAS or MISER.
- Improve the root finder and 1D minimization classes (`BrentRootFinder` and `BrentMinimizer1D`) by fixing a bug in the Brent method (see rev. 32544) and adding possibility to pass the tolerance and max number of iterations
- Change also the interface classes, `ROOT::Math::RootFinder` and `ROOT::Math::IMinimizer1D` to have methods consistent with the other numerical algorithm classes (e.g. return bool and not int from `RootFinder::Solve` and add a `RootFinder::Status()` function. In addition, use the same default tolerance for all the root finder algorithms.
- The class `ROOT::Math::Data::Range` returns in the method GetRange the values `-inf` and `+inf` when no range is set
- Use in `TRandom::SetSeed(int seed)` a value of `seed=0` as default argument. This is the same now in all the derived classes.
- Add new methods in `ROOT::Fit::FitResult` to have a more consistent and expressive API:`FitResult::Parameter(index)`, `FitResult::ParError(index)` and `FitResult::ParName(index)`. The method `FitResult::ParError` should be used instead of `FitResult::Error` in the derived `TFitResult` class to avoid a conflict with `TObject::Error` (see bug 67671).
- Fix a bug in `Tmath::AreEqualRel` to take into account the case when the two arguments may be null.
- Improve implementation of the F distribution for large N and M. Use now the same implementation in ROOT::Math and TMath
- Fix the returned value of the incomplete gamma functions for a=0 or a is a negative integer number.

#### Mathmore

- Fix a bug in `ROOT::Math::Random::Multinomial`.
- Fix some bugs in `GSLInterpolator`
- New mathematical special functions in the `ROOT::Math` namespace implemented using GSL:
  - Airy functions:

           double airy_Ai(double x);
           double airy_Bi(double x);
           double airy_Ai_deriv(double x);
           double airy_Bi_deriv(double x);
           double airy_zero_Ai(unsigned int s);
           double airy_zero_Bi(unsigned int s);
           double airy_zero_Ai_deriv(unsigned int s);
           double airy_zero_Bi_deriv(unsigned int s);

  - Wigner coefficient functions:

           double wigner_3j(int ja, int jb, int jc, int ma, int mb, int mc);
           double wigner_6j(int ja, int jb, int jc, int jd, int je, int jf);
           double wigner_9j(int ja, int jb, int jc, int jd, int je, int jf, int jg, int jh, int ji);

- New statistical function: non-central chisquare probability density function

         double noncentral_chisquared_pdf(double x, double r, double lambda);

  It is implemented using Bessel functions or hypergeometric function
- New classes `VavilovAccurate` and `VavilovFast`, derived from the abstract base class `Vavilov`, provide pdf, cdf and quantile functions for the Vavilov distribution, based on the algorithms of CERNLIB (G116 and G115, respectively). The classes `VavilovAccuratePdf`, `VavilovAccurateCdf` and `VavilovAccurateQuantile` implement the `IParametricFunctionOneDim` interface for easier use in fit problems.

#### Unuran

- Use new version 1.7.2
- Add new class TUnuranSampler implementing the `ROOT::Math::DistSampler` interface for one dimensional continuous and discrete distributions and for mult-dimensional ones

#### Foam

- Add new class TFoamSampler implementing the `ROOT::Math::DistSampler` interface for generating random numbers according to any one or multi-dim distributions using Foam.
- All the TFoam options can be controlled via the `ROOT::Math::DistSamplerOptions` class, which can be passed as input to the virtual `ROOT::Math::DistSampler::Init(..)` function.

#### GenVector

- Add some missing copy constructor and assignment operators to fix compilation issue observed with LLVM (Clang)

#### Minuit

- Fix a bug when using at the same time `TMinuit` or `TFitter` with the new `TMinuitMinimizer` class. See bug 72909.

#### Minuit2

- Fix the returned error from the Minimizer class for fixed and constant parameters. Now is set explicitly to zero.
- Fix a problem in re-defining fixed parameters as variable ones. Before it was not possible to release them.
- Fix a problem in the number of function calls when running MnHesse after minimizing. Now the number is incremented instead of being reset.

#### Genetic

- Add a new Minimizer implementation based on the genetic algorithm used in TMVA (plugin name "Genetic"). See example programs in math/genetic/test.