Martin Woudstra wrote: > Dear Root Developers, > > I would like to make a 3D fit (e.g. plane) to a set of 3D > points (x,y,z) with their errors. Both the points and the errors > come from another calculation and I want to set directly the > points with their errors, like in TGraphErrors, but then in 3D. > > So, something like TGraph2DErrors class could do the job. > Would it be useful to add this to ROOT? > I was surprised you didn't put it in yet (at least I didn't find it). > > Currently I am using TH2F, but each bin has one entry (with > weight=z), and the assumed error on this in a Fit is > certainly wrong (1.0 I guess), so the fit is wrong. > > So I am thinking of making a new class like > class TH2FErrors : public TH2F { > void Fill(Axis_t x, Axis_t y, Stat_t w, Stat_t e) > } > > void TH2FErrors::Fill(Axis_t x, Axis_t y, Stat_t w, Stat_t e) > { > Int_t binx, biny, bin; > TH2F::Fill(x,y,w);// ensure bookkeeping > > binx = fXaxis.FindBin(x); > biny = fYaxis.FindBin(y); > bin = biny*(fXaxis.GetNbins()+2) + binx; > // overwrite bin contents + bin error > SetBinContent(bin,w); > SetBinError(bin,e); > } > > But I'm not sure this is a good idea, and it might even be > dangerous. Maybe you can help me here. > > Thanks! > > Martin. Martin, Your solution above cannot work. If you have equidistant points, you can use the already existing class TH3F. This creates a 3-D histogram that you can fill with TH1::Fill(x,y,z,w) then use TH1::Fit to fit your 3-d distribution. Use the example 13 in the tutorials "Fitting with a user-defined function" as a model. In case you have non-equidistant points, look at the batch example in $ROOTSYS/test/minexam. This illustrates how to make a fit on n dimensions with non-equidistant points. This examples shows also how to define your own fitting model. Rene Brun
This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:26:22 MET