38 double tmp = (x-x0)/sigma;
45 for (
int k = 0; k < ndim; ++k) {
46 double y =
GaussPdf( x[k], p[ 2*k], p[2*k + 1] );
48 y = std::max(y, 1.
E-300);
55 typedef std::vector< std::vector< double> >
Data;
57 struct LogLikeFCN :
public FCNBase {
59 LogLikeFCN(
const Data &
data) : fData(data) {}
61 double operator() (
const std::vector<double> & p )
const {
63 int ndata = fData.size();
64 for (
int i = 0; i <
ndata; ++i) {
69 double Up()
const {
return 0.5; }
78 std::vector< double> event(ndim);
80 std::vector<double> mean(ndim);
81 std::vector<double>
sigma(ndim);
82 for (
int k = 0; k < ndim; ++k) {
83 mean[k] = -double(ndim)/2 + k;
84 sigma[k] = 1. + 0.1*k;
88 for (
int i = 0; i <
ndata; ++i) {
89 for (
int k = 0; k < ndim;++k) {
100 std::vector<double> init_par(2*ndim);
101 for (
int k = 0; k < ndim; ++k) {
106 std::vector<double> init_err(2*ndim);
107 for (
int k = 0; k < 2*ndim; ++k) {
117 std::cout<<
"minimum: "<<min<<std::endl;
147 int main(
int argc,
char **argv) {
151 ndim = atoi(argv[1] );
154 ndata = atoi(argv[2] );
156 std::cout <<
"do fit of " << ndim <<
" dimensional data on " << ndata <<
" events " << std::endl;
int doFit(int ndim, int ndata)
double LogMultiGaussPdf(const std::vector< double > &x, const std::vector< double > &p)
class holding the full result of the minimization; both internal and external (MnUserParameterState) ...
std::vector< std::vector< double > > Data
Interface (abstract class) defining the function to be minimized, which has to be implemented by the ...
VecExpr< UnaryOp< Fabs< T >, VecExpr< A, T, D >, T >, T, D > fabs(const VecExpr< A, T, D > &rhs)
Instantiates the SeedGenerator and MinimumBuilder for Variable Metric Minimization method...
virtual FunctionMinimum Minimize(const FCNBase &, const std::vector< double > &, const std::vector< double > &, unsigned int stra=1, unsigned int maxfcn=0, double toler=0.1) const
double GaussPdf(double x, double x0, double sigma)
int main(int argc, char **argv)