[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Bug-gsl] [Bug] gsl_cdf_tdist_P returns inaccurate p-value
From: |
Lin, Kuan-Ting |
Subject: |
Re: [Bug-gsl] [Bug] gsl_cdf_tdist_P returns inaccurate p-value |
Date: |
Mon, 9 Jan 2017 18:50:53 +0000 |
Hi Peter,
You are wonderful! Problem solved!
Thanks,
Woody
> On Jan 8, 2017, at 8:02 PM, Peter Johansson <address@hidden> wrote:
>
> Hi Woody,
>
>
> On 01/07/2017 07:27 AM, Lin, Kuan-Ting wrote:
>> Hi all,
>>
>> I am using gsl_cdf_tdist_P to get a p-value for the following two arrays:
>>
>> x = 1, 2, 4, 2, 3, 1, 2, 4, 2, 1, 2
>> y = 11, 12, 13, 12, 13, 11, 14, 11, 12, 13, 12
>>
>> (2* (1-gsl_cdf_tdist_P)) returns "8.882e-16”, but I got "9.189e-16” from
>> t.test(x,y,var.equal=T) function in R (a statistics language). It suggests
>> that gsl_cdf_tdist_P function is not returning a precise p-value.
>
> The problem is that you are comparing 1.0 with something that very close 1.0
> and your system does not have precision to that subtraction accurately. I
> suggest you replace '1-gsl_cdf_tdist_P' with 'gsl_cdf_tdist_Q', which in
> theory should be identical, but due to precision (rounding errors) the latter
> will be more correct.
>>
>> In addition, I noticed that (2* (1-gsl_cdf_tdist_P)) doesn’t return double
>> numbers. Instead, any p-value smaller than 1e-16 will be 0.
>
> Same thing. Try gsl_cdf_tdist_Q.
>
>>
>> Could someone help me with this?
>>
>> Thanks,
>> Woody
>>
>>
>