Logo ROOT   6.10/09
Reference Guide
GaussDataGen.cxx
Go to the documentation of this file.
1 // @(#)root/minuit2:$Id$
2 // Authors: M. Winkler, F. James, L. Moneta, A. Zsenei 2003-2005
3 
4 /**********************************************************************
5  * *
6  * Copyright (c) 2005 LCG ROOT Math team, CERN/PH-SFT *
7  * *
8  **********************************************************************/
9 
10 #include "GaussDataGen.h"
11 #include "GaussFunction.h"
12 #include "GaussRandomGen.h"
13 #include "FlatRandomGen.h"
14 
15 namespace ROOT {
16 
17  namespace Minuit2 {
18 
19 
21 
22  // create random generator for mean values of Gaussian [-50, 50)
23  FlatRandomGen rand_mean(0., 50.);
24 
25  // create random generator for sigma values of Gaussian [1., 11.)
26  FlatRandomGen rand_var(6., 5.);
27 
28  // errors of measurements (Gaussian, mean=0., sig = 0.01)
29  double mvariance = 0.01*0.01;
30  GaussRandomGen rand_mvar(0., 0.01);
31 
32  // simulate data
33  fSimMean = rand_mean();
34  fSimVar = rand_var();
35  double sim_sig = sqrt(fSimVar);
36  double sim_const = 1.;
37  GaussFunction gauss_sim(fSimMean, sim_sig, sim_const);
38 
39  for(unsigned int i = 0; i < n; i++) {
40 
41  //x-position, from -5sigma < mean < +5sigma
42  double position = fSimMean-5.*sim_sig + double(i)*10.*sim_sig/double(n);
43  fPositions.push_back(position);
44 
45  //y-position (function Value)
46  double epsilon = rand_mvar();
47  fMeasurements.push_back(gauss_sim(position) + epsilon);
48  fVariances.push_back(mvariance);
49  }
50 
51 }
52 
53  } // namespace Minuit2
54 
55 } // namespace ROOT
Namespace for new ROOT classes and functions.
Definition: StringConv.hxx:21
GaussDataGen(unsigned int npar=100)
std::vector< double > fVariances
Definition: GaussDataGen.h:42
double sqrt(double)
REAL epsilon
Definition: triangle.c:617
std::vector< double > fMeasurements
Definition: GaussDataGen.h:41
std::vector< double > fPositions
Definition: GaussDataGen.h:40
const Int_t n
Definition: legend1.C:16