# Distributions package invlogcdf() function returning the wrong answer?

**URL:** https://discourse.julialang.org/t/distributions-package-invlogcdf-function-returning-the-wrong-answer/26867
**Category:** Statistics
**Created:** [July 27, 2019, 12:21am UTC](https://discourse.julialang.org/t/distributions-package-invlogcdf-function-returning-the-wrong-answer/26867 "2019-07-27T00:21:14Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![dataSurfer](https://avatars.discourse-cdn.com/v4/letter/d/67e7ee/32.png) [@dataSurfer](https://discourse.julialang.org/u/dataSurfer)
#### Post date: [July 27, 2019, 12:21am UTC](https://discourse.julialang.org/t/distributions-package-invlogcdf-function-returning-the-wrong-answer/26867/1 "2019-07-27T00:21:14Z")

</div>

Consider that the following answer:

```julia
invlogcdf(Chi(11), log(0.975))
# 4.681885225101231
qchisq(0.975, 11)
# 21.920049261021205

```

is wrong when comparing `invlogcdf()` to the equivalent R function, but the following is correct (used as a basic check to test that whether I am using the function correctly):

```julia
invlogcdf(Normal(), log(0.975))
# 1.9599639845400534
qnorm(0.975)
# 1.9599639845400536

```

Maybe there is an issue with how Chi-Squared inverse CDF is implemented or am I doing something wrong?

---

<div class="post-metadata">

### Author: ![aplavin](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/aplavin/32/222056_2.png) [@aplavin](https://discourse.julialang.org/u/aplavin)
#### Post date: [July 27, 2019, 12:33am UTC](https://discourse.julialang.org/t/distributions-package-invlogcdf-function-returning-the-wrong-answer/26867/2 "2019-07-27T00:33:56Z")

</div>

You ask `Distributions` for `Chi` distribution - and it gives the correct result. Just ask it for `Chisq` distribution: `invlogcdf(Chisq(11), log(0.975)) = 21.92`.

---

<div class="post-metadata">

### Author: ![dataSurfer](https://avatars.discourse-cdn.com/v4/letter/d/67e7ee/32.png) [@dataSurfer](https://discourse.julialang.org/u/dataSurfer)
#### Post date: [July 27, 2019, 12:39am UTC](https://discourse.julialang.org/t/distributions-package-invlogcdf-function-returning-the-wrong-answer/26867/3 "2019-07-27T00:39:21Z")

</div>

Wow, I didn’t even know the Chi-distribution existed! I though that Chi was just short hand for Chi-Squared. I have been searching for the bug in my code for ages and in the end realised I wasn’t getting anything like the values I was expecting for the Chi() distribution. 😆

Thanks for setting me right.
