This C++ version of BAT is still being maintained, but addition of new features is unlikely. Check out our new incarnation, BAT.jl, the Bayesian analysis toolkit in Julia. In addition to Metropolis-Hastings sampling, BAT.jl supports Hamiltonian Monte Carlo (HMC) with automatic differentiation, automatic prior-based parameter space transformations, and much more. See the BAT.jl documentation.

Frequently Asked Questions

Please have a look at the questions and answers in this list before contacting us with your problem.

Installation procedure

  1. How can I compile BAT in 32bit mode on 64bit machine?
  2. I have no trouble installing BAT, but when I try to link an example, I get an error message like
    libBAT.so: undefined reference to `ROOT::Math::normal_cdf(double, double, double)'
  3. I am running Ubuntu 12.04 with g++ 4.6.3 and have no trouble installing BAT, but when I try to link an example, I get an error message like
    /PATH/TO/BAT/lib/libBAT.so: undefined reference to `TCanvas::TCanvas(char const*, char const*, int, int)'
    /PATH/TO/BAT/lib/libBAT.so: undefined reference to `TPad::TPad(char const*, char const*, double, double, double, double, short, short, short)'
    /PATH/TO/BAT/lib/libBAT.so: undefined reference to `TCanvas::TCanvas(char const*, char const*, int)'
    /PATH/TO/BAT/lib/libBAT.so: undefined reference to `TCanvas::TCanvas(bool)'
  4. During compilation I get an error message like
    relocation R_X86_64_32S against `a local symbol' can not be used when making a shared object; recompile with -fPIC
  5. My machine is upgraded to Ubuntu (from some SL I guess) and when compiling BAT, I get this message
    /usr/bin/ld: skipping incompatible /cernroot/5_24_00/gcc.3.4.6/lib/libCore.so when searching for -lCore
  6. [BAT > 0.3.2] I successfully configured BAT using
    ./configure --with-rootsys=/PATH/TO/ROOT
    but during compilation I receive an error message like this
    /PATH/TO/ROOT/bin/rootcint: error while loading shared libraries: libCint.so: cannot open shared object file: No such file or directory
    make[2]: *** [BCDataPointDict.cxx] Error 127

    or
    Making all in src
    make[2]: Entering directory `/home/user/BAT-0.4.2/src'
    /PATH/TO/CONFLICTING/ROOT/bin/rootcint -f BCDataPointDict.cxx -c -I.. ../BAT/BCDataPoint.h
    make[2]: *** [BCDataPointDict.cxx] Segmentation fault

Use of Cuba library

  1. What does Cuba do?
  2. When do I need Cuba?
  3. Can I still do numerical integration if I don't install Cuba?

Tuning settings

  1. How can I change the number of bins used for the histograms of marginalized distributions?
  2. When I calculate the p-value for a model using myModel->CalculatePValue( myModel->GetBestFitParameters() ); I get an error message like this:
    Warning : BCGoFTest::SetTestDataPoint(). Boundaries of the original data set are not defined.
    and myModel->GetPValue(...) only showed -1.?



Answers

  1. How can I compile BAT in 32bit mode on 64bit machine?

    When running the ./configure script add CXXFLAGS="-m32" LDFLAGS="-m32" to the command line.


  2. I have no trouble installing BAT, but when I try to link an example, I get an error message like
    libBAT.so: undefined reference to `ROOT::Math::normal_cdf(double, double, double)'

    Most likely your version of ROOT is misconfigured. Check the output of root-config --libs. If you don't find -lMathCore in the output, then you have to add the the library by hand to your makefile, i.e., append -lMathCore to the end of the line defining the ROOTLIBS variable:

    ROOTLIBS := $(shell root-config --libs) -lMinuit -lMathCore



  3. I am running Ubuntu 12.04 with g++ 4.6.3 and have no trouble installing BAT, but when I try to link an example, I get an error message like
    /PATH/TO/BAT/lib/libBAT.so: undefined reference to `TCanvas::TCanvas(char const*, char const*, int, int)'
    /PATH/TO/BAT/lib/libBAT.so: undefined reference to `TPad::TPad(char const*, char const*, double, double, double, double, short, short, short)'
    /PATH/TO/BAT/lib/libBAT.so: undefined reference to `TCanvas::TCanvas(char const*, char const*, int)'
    /PATH/TO/BAT/lib/libBAT.so: undefined reference to `TCanvas::TCanvas(bool)'


    A workaround is to use an older compiler. Install g++-4.4 from the repositories, then do
    make clean
    ./configure YOUR_OPTIONS CXX=g++-4.4
    make
    make install



  4. During compilation I get an error message like
    relocation R_X86_64_32S against `a local symbol' can not be used when making a shared object; recompile with -fPIC

    You need to compile Cuba with -fPIC option. Try this
    ./configure ... CFLAGS='-fPIC -g -O3'
    make lib
    make install

    If you just use make, cuba tries to build examples, which won't work.



  5. My machine is upgraded to Ubuntu (from some SL I guess) and when compiling BAT, I get this message
    /usr/bin/ld: skipping incompatible /cernroot/5_24_00/gcc.3.4.6/lib/libCore.so when searching for -lCore

    Make sure to use your version of ROOT is built for your platform. Perhaps you adjust the value of $ROOTSYS. Then configure BAT again before running make.


  6. [BAT > 0.3.2] I successfully configured BAT using
    ./configure --with-rootsys=/PATH/TO/ROOT
    but during compilation I receive an error message like this
    /PATH/TO/ROOT/bin/rootcint: error while loading shared libraries: libCint.so: cannot open shared object file: No such file or directory
    make[2]: *** [BCDataPointDict.cxx] Error 127

    or
    Making all in src
    make[2]: Entering directory `/home/user/BAT-0.4.2/src'
    /PATH/TO/CONFLICTING/ROOT/bin/rootcint -f BCDataPointDict.cxx -c -I.. ../BAT/BCDataPoint.h
    make[2]: *** [BCDataPointDict.cxx] Segmentation fault


    In the first case, the ROOT libraries aren't available for dynamic linking at all, in the second case, there are most likely several ROOT versions installed, and the version in /PATH/TO/CONFLICTING/ROOT/ is different from the one in /PATH/TO/ROOT/ used in ./configure. To make things work, add the proper ROOT libraries to the beginning of your LD_LIBRARY_PATH by hand before compilation. In the bash shell, it would look like this
    ./configure --with-rootsys=/PATH/TO/ROOT
    export LD_LIBRARY_PATH=/PATH/TO/ROOT/lib/:$LD_LIBRARY_PATH
    make
    When running an application compiled with BAT, you need to make sure that the proper ROOT libraries appear LD_LIBRARY_PATH before any conflicting ROOT versions. Note that LD_LIBRARY_PATH is searched before the system default directories like /usr/lib, where an older ROOT version may have been installed via the package manager of your favourite Linux distribution.



  7. What does Cuba do?

    Cuba is a library for numerical integration; see the Cuba webpage for more details.


  8. When do I need Cuba?

    You need Cuba if you want to normalize the probability for models with many parameters. The performance of Cuba in that respect is much better than that of Sampled mean MC. Normalization of model is normally only needed when doing Bayesian model comparison or calculation of K-factors. For standard posterior mapping (running of MCMC) it is not needed.
    BAT does not automatically normalize the models. To do that the user has to explicitely request it using
    myModel->Normalize()
    or

    modelManager->Normalize()



  9. Can I still do numerical integration if I don't install Cuba?

    Yes. BAT has also implemented the numerical integration via Sampled Mean Monte Carlo. If BAT was compiled without Cuba then the integration method defaults to Sampled Mean MC.


  10. How can I change the number of bins used for the histograms of marginalized distributions?

    To set the number of bins to 500 for parameter A of your model use command

    myModel->SetNbins("A",500)

    To set the number of bins to 500 for all parameters of the model use command

    myModel->SetNbins(500)



  11. When I calculate the p-value for a model using myModel->CalculatePValue( myModel->GetBestFitParameters() ); I get an error message like this:
    Warning : BCGoFTest::SetTestDataPoint(). Boundaries of the original data set are not defined.
    and myModel->GetPValue(...) only showed -1.?

    So what happens when myModel->CalculatePValue is called? BAT runs a Markov chain and creates datasets. By itself BAT cannot decide which data sets are reasonable or not, so the user has to tell BAT. This is exactly analogous to the case where you fit parameters and you supply ranges for each parameter. Then BAT samples from the posterior only within these ranges.

    A helpful example is supplied with the BAT source code in subdirectory examples/advanced/polynomialfit/ . In that example each data point has three dimensions, (x,y,sigma). The respective ranges (so identical for each data point) are set for each of the two models with this code

    mgr->SetDataBoundaries(0, 0.0, 100.0); // possible x-values
    mgr->SetDataBoundaries(1, 0.0, 5.0); // possible y-values
    mgr->SetDataBoundaries(2, 0.2, 5.2); // possible sigmas

    You can also set boundaries individually for each point of a model using
    void BCModel::SetDataBoundaries(unsigned int index, double lowerboundary, double upperboundary)
    void BCModel::SetDataPointLowerBoundary(int index, double lowerboundary)
    void BCModel::SetDataPointUpperBoundary(int index, double upperboundary)