Re: [ROOT] strnage integral values

From: Rene Brun (Rene.Brun@cern.ch)
Date: Thu Dec 11 2003 - 14:49:03 MET


I am reposting my previous answer, just in case you missed it

Rene

Hi Stanislav, Vincent, Martin,

When we introduced the new TF1 functions (thanks Gene Van Buren)
TF1::Moment and CentralMoment, the integral of the function must be evaluated
with the absolute value of the function.
I was supposed to introduce immediatly a flag in TF1::Integral to use
the normal function value or its absolute value. Unfortunately, I forgot
to do it. Apologies.

I have now introduced this flag in the CVS version.
The functions TF1::Integral and TF1::IntegralMultiple have been modified
to use the absolute value of the function when fgAbsValue is TRUE.
The functions TF1::Moment and TF1::CentralMoment set fgAbsValue to kTRUE.
By default fgAbsValue is kFALSE

Rene Brun


Martijn Schellekens wrote:
> 
> Hi,
> Yes that's what I noticed as well. I suppose this is a mistake, will this
> be changed in the next version or is there an explicit reason for this?
> 
> Thanks, best regards,
> 
> Martijn
> 
> A 15:18 11/12/2003 +0300, Stanislav Nesterov a écrit :
> >   Hi,
> >   You are right. An integral of the absolute value is calculated since
> > ver. 1.68 of TF1.cxx (CVS rev.).  I don't know why the statistical
> > functions required such thing.
> >----------------------------------------------------------------------
> >--- TF1.cxx    14 Jul 2003 12:58:22 -0000    1.67
> >+++ TF1.cxx    20 Aug 2003 07:00:47 -0000    1.68
> >@@ -1,4 +1,4 @@
> >-// @(#)root/hist:$Name:  $:$Id: TF1.cxx,v 1.67 2003/07/14 12:58:22 brun Exp $
> >+// @(#)root/hist:$Name:  $:$Id: TF1.cxx,v 1.68 2003/08/20 07:00:47 brun Exp $
> >// Author: Rene Brun   18/08/95
> >/*************************************************************************
> >@@ -1563,18 +1563,18 @@
> >   for (i=0;i<4;i++) {
> >      u     = c2*x[i];
> >      xx[0] = c1+u;
> >-     f1    = EvalPar(xx,params);
> >+     f1    = TMath::Abs(EvalPar(xx,params));
> >      xx[0] = c1-u;
> >-     f2    = EvalPar(xx,params);
> >+     f2    = TMath::Abs(EvalPar(xx,params));
> >      s8   += w[i]*(f1 + f2);
> >   }
> >   s16 = 0;
> >   for (i=4;i<12;i++) {
> >      u     = c2*x[i];
> >      xx[0] = c1+u;
> >-     f1    = EvalPar(xx,params);
> >+     f1    = TMath::Abs(EvalPar(xx,params));
> >      xx[0] = c1-u;
> >-     f2    = EvalPar(xx,params);
> >+     f2    = TMath::Abs(EvalPar(xx,params));
> >      s16  += w[i]*(f1 + f2);
> >   }
> >   s16 = c2*s16;
> >@@ -1749,14 +1749,14 @@
> >    sum3   = 0;
> >    for (j=0;j<n;j++) {
> >       z[j]    = ctr[j] - xl2*wth[j];
> >-      f2      = EvalPar(z,fParams);
> >+      f2      = TMath::Abs(EvalPar(z,fParams));
> >       z[j]    = ctr[j] + xl2*wth[j];
> >-      f2     += EvalPar(z,fParams);
> >+      f2     += TMath::Abs(EvalPar(z,fParams));
> >       wthl[j] = xl4*wth[j];
> >       z[j]    = ctr[j] - wthl[j];
> >-      f3      = EvalPar(z,fParams);
> >+      f3      = TMath::Abs(EvalPar(z,fParams));
> >       z[j]    = ctr[j] + wthl[j];
> >-      f3     += EvalPar(z,fParams);
> >+      f3     += TMath::Abs(EvalPar(z,fParams));
> >       sum2   += f2;
> >       sum3   += f3;
> >       dif     = TMath::Abs(7*f2-f3-12*sum1);
> >@@ -1777,7 +1777,7 @@
> >             for (m=0;m<2;m++) {
> >                wthl[k] = -wthl[k];
> >                z[k]    = ctr[k] + wthl[k];
> >-               sum4 += EvalPar(z,fParams);
> >+               sum4 += TMath::Abs(EvalPar(z,fParams));
> >             }
> >          }
> >          z[k] = ctr[k];
> >@@ -1791,7 +1791,7 @@
> >       z[j] = ctr[j] + wthl[j];
> >    }
> >L90:
> >-   sum5 += EvalPar(z,fParams);
> >+   sum5 += TMath::Abs(EvalPar(z,fParams));
> >    for (j=0;j<n;j++) {
> >       wthl[j] = -wthl[j];
> >       z[j] = ctr[j] + wthl[j];
> >--------------------------------------------------------------
> >
> >As you can see function value everywhere is replaced by its absolute value.
> >
> >                                        Best regards,
> >                                                             Stanislav.
> >
> >Vincent Roberfroid wrote:
> >
> >>Yes it's correct !
> >>This problem is present with root 3.10/00.
> >>It doesn't exist with root 3.05.
> >>
> >>Vincent
> >>
> >>On Wednesday 10 December 2003 19:42, Martijn Schellekens wrote:
> >>
> >>
> >>>Dear Rooters,
> >>>
> >>>I have this strange integral result:
> >>> > TH1 func("func","-x",-50,50)
> >>> >func.Integral(-1,1)
> >>>
> >>>result:
> >>>         1
> >>>Can someone explains this result to me???
> >>>(seems to compute the integral of the absolute value: negatif values are
> >>>not of this world after all???)
> >>>
> >>>Thanks a lot,
> >>>Martijn Schellekens
> >>>
> >



This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:17 MET