# How to get p value from Chi Square table

**URL:** <https://discourse.julialang.org/t/how-to-get-p-value-from-chi-square-table/649>\
**Category:** Statistics\
**Tags:** question\
**Created:** [November 30, 2016, 6:42am UTC](https://discourse.julialang.org/t/how-to-get-p-value-from-chi-square-table/649 "2016-11-30T06:42:57Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hongwei](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hongwei/32/264_2.png) [@Hongwei](https://discourse.julialang.org/u/Hongwei)\
**Post date:** [November 30, 2016, 6:42am UTC](https://discourse.julialang.org/t/how-to-get-p-value-from-chi-square-table/649/1 "2016-11-30T06:42:57Z")

</div>

Hi guys,

Given cquantile(Chisq(1), .005), we can get its Chi square table value 7.8

Is there anyway to get the corresponding p value when given Chi square table value and freedom?

Thanks,

Hongwei

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [November 30, 2016, 10:47am UTC](https://discourse.julialang.org/t/how-to-get-p-value-from-chi-square-table/649/2 "2016-11-30T10:47:05Z")

</div>

```julia
using Distributions
ccdf(Chisq(1), 7.8)

```

---

<div class="post-metadata">

**Author:** ![mcreel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mcreel/32/30088_2.png) [@mcreel](https://discourse.julialang.org/u/mcreel)\
**Post date:** [November 30, 2016, 11:49am UTC](https://discourse.julialang.org/t/how-to-get-p-value-from-chi-square-table/649/3 "2016-11-30T11:49:58Z")

</div>

That one I can help with:

```julia
julia> 1-cdf(Chisq(1),7.8)
0.00522462344006136

```

---

<div class="post-metadata">

**Author:** ![Hongwei](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hongwei/32/264_2.png) [@Hongwei](https://discourse.julialang.org/u/Hongwei)\
**Post date:** [November 30, 2016, 2:18pm UTC](https://discourse.julialang.org/t/how-to-get-p-value-from-chi-square-table/649/4 "2016-11-30T14:18:57Z")

</div>

Thanks a lot, Tamas!

---

<div class="post-metadata">

**Author:** ![Hongwei](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hongwei/32/264_2.png) [@Hongwei](https://discourse.julialang.org/u/Hongwei)\
**Post date:** [November 30, 2016, 2:20pm UTC](https://discourse.julialang.org/t/how-to-get-p-value-from-chi-square-table/649/5 "2016-11-30T14:20:41Z")

</div>

Thanks a lot, Mcreel! It seems ccdf and cdf are complementary of each other.

---

<div class="post-metadata">

**Author:** ![johnmyleswhite](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/johnmyleswhite/32/31_2.png) [@johnmyleswhite](https://discourse.julialang.org/u/johnmyleswhite)\
**Post date:** [November 30, 2016, 3:32pm UTC](https://discourse.julialang.org/t/how-to-get-p-value-from-chi-square-table/649/6 "2016-11-30T15:32:28Z")

</div>

`ccdf` may offer more precision in some cases. Computing `1 - cdf` can be numerically problematic if `cdf` is very close to 1:

> julia\> (1 - 0.9999999999999999) + 0.0000000000000001  
> 2.1102230246251565e-16
> 
> julia\> 1 - (0.9999999999999999 + 0.0000000000000001)  
> 0.0

---

<div class="post-metadata">

**Author:** ![johnmyleswhite](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/johnmyleswhite/32/31_2.png) [@johnmyleswhite](https://discourse.julialang.org/u/johnmyleswhite)\
**Post date:** [November 30, 2016, 5:09pm UTC](https://discourse.julialang.org/t/how-to-get-p-value-from-chi-square-table/649/7 "2016-11-30T17:09:27Z")

</div>

Looking at this again, I wrote this example way too quickly and totally screwed it up by putting a plus sign instead of a minus sign in the first computation. The relevant comparison would be something like this:

> julia\> 1 - (0.9999999999999999 + 0.0000000000000001)  
> 0.0
> 
> julia\> (1 - 0.9999999999999999) - 0.0000000000000001  
> 1.1022302462515656e-17
