Re: TProfile nan bins.

From: Lorenzo Moneta <Lorenzo.Moneta_at_cern.ch>
Date: Fri, 11 Mar 2011 11:08:55 +0100


In reality a TProfile is different from a histogram. The first one is computing an average in y, so I am not surprised that the NaN will get propagated in the bin content. Filling a TH2 and then doing TH2::ProfileX is not exactly equivalent to create and fill directly a TProfile. First of all the projection consider only bin center values and then the underflow/overflow cannot be used in the projection. In case of underflow/overflow, you will get something very similar (a part from using the bin center ), if you set a range in the variable Y in the TProfile.  

What should work, and it is not working now, is, when you set limits in y in the TProfile constructor, the NaN should not be considered. I will fix this,

 Best

 Lorenzo   

On Mar 11, 2011, at 10:26 AM, Stefan Piperov wrote:

> 
> Well, the initial user complaint, that two statistical entities, treated in a similar, statistically valid, way produce inconsistent result remains unaddressed. Other users will fall in the same trap as BetterWang did if this behaviour remains as it is.
> 
> Perhaps ROOT can be more coherent here?
> Stefan.
> 
> 
> 
> On Fri, 11 Mar 2011, Lorenzo Moneta wrote:
> 
>> Hi,
>> 
>> If you fill a NaN in an histogram, it will go to the overflow bin, while if the y value of the Profile is a NaN
>> the resulting bin content will be NaN. This has the advantage that can be immediately discovered by  the user.
>> I think it is a user responsibility not to fill histogram or profile with NaN values
>> 
>>  Best Regards
>> 
>> Lorenzo
>> On Mar 11, 2011, at 5:27 AM, BetterWang wrote:
>> 
>>> Well, it has been solved.
>>> In very rare occasions, I have NaN from divided by zero.
>>> If I fill NaN in a 2D histo, I won't have problem at all.
>>> But if I fill NaN in a TProfile, it will result that bin to be NaN.
>>> Maybe TProfile can have NaN protection in the Fill function, or leave
>>> that to users.
>>> 
>>> Thanks,
>>> 
>>> 
>>> On Wed, Mar 9, 2011 at 3:19 AM, Lorenzo Moneta <Lorenzo.Moneta_at_cern.ch> wrote:
>>>> Hi,
>>>> 
>>>> Can you please send me a macro reproducing  this problem ?
>>>> Thank you
>>>> 
>>>> Lorenzo
>>>> On Mar 1, 2011, at 5:07 PM, BetterWang wrote:
>>>> 

>>>>> Hi ROOT experts,
>>>>>
>>>>> I am filling TH2D and TProfile at the same time.
>>>>> They have the same definition, for example:
>>>>>
>>>>> TH2D *h2 = new TH2D("h2", h2", 220, -1.1, 1.1, 220, -1.1, 1.1);
>>>>> TProfile *h2p = new TProfile("h2p", "h2p", 220, -1.1, 1.1, -1.1, 1.1);
>>>>>
>>>>> After filling lots of data.
>>>>> h2 looks fine, but h2p has some bins with content "NaN".
>>>>> h2->ProfileX() can give a profile without any problem.
>>>>> Does anyone know what is going on under the hood?
>>>>> And how can I avoid "NaN" in a TProfile?
>>>>>
>>>>> Thanks,
>>>>>
>>>> 
>>>> 
>> 
>> 
> 
> *---------------------------------------------------------------------*
> Stefan Piperov      Mail: FNAL P.O.Box 500, MS 205, Batavia, IL-60510
> Phone: (630) 840-5176                        E-Mail: piperov_at_fnal.gov
> *---------------------------------------------------------------------*
> "Give a skeptic an inch... and he'll measure it."
Received on Fri Mar 11 2011 - 11:09:01 CET

This archive was generated by hypermail 2.2.0 : Fri Mar 11 2011 - 17:50:01 CET