# Odd result from Distributions quantile

**URL:** <https://discourse.julialang.org/t/odd-result-from-distributions-quantile/25820>\
**Category:** Statistics\
**Created:** [June 28, 2019, 7:53pm UTC](https://discourse.julialang.org/t/odd-result-from-distributions-quantile/25820 "2019-06-28T19:53:09Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![abx](https://avatars.discourse-cdn.com/v4/letter/a/edb3f5/32.png) [@abx](https://discourse.julialang.org/u/abx)\
**Post date:** [June 28, 2019, 7:53pm UTC](https://discourse.julialang.org/t/odd-result-from-distributions-quantile/25820/1 "2019-06-28T19:53:09Z")

</div>

I am experiencing inconsistent results using the Distributions package. When I run the following code, I get two different results on different machines

> Distributions.quantile(Distributions.Normal(), 0.3631592166130919)

a\> -0.3500270020514903  
b\> -0.3500270020514902

Which looks very little difference, but because of some ripple effect it turns causing issues with my roll-ups 😕

Digging into it, I figured that the issue hides into the Base.Math library, in the @horner macro that, following the code, is called with the parameters:

> @horner(-0.4875984000082292, 0.14780\_64707\_15138\_316110e2, -0.91374\_16702\_42603\_13936e2, 0.21015\_79048\_62053\_17714e3, -0.22210\_25412\_18551\_32366e3, 0.10760\_45391\_60551\_23830e3, -0.20601\_07303\_28265\_443e2, 0.1e1)

Which results in  
a\> 141.71157435331995  
b\> 141.71157435331997

Looking into the macro I can’t really figure out what’s going on!

```julia
macro horner(x, p...)
    ex = esc(p[end])
    for i = length(p)-1:-1:1
        ex = :(muladd(t, $ex, $(esc(p[i]))))
    end
    ex = quote local r = $ex end 
    return Expr(:block, :(local t = $(esc(x))), ex, :r)
end

```

What can possibly cause the issue? Thanks

---

<div class="post-metadata">

**Author:** ![nalimilan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nalimilan/32/147_2.png) [@nalimilan](https://discourse.julialang.org/u/nalimilan)\
**Post date:** [June 28, 2019, 9:01pm UTC](https://discourse.julialang.org/t/odd-result-from-distributions-quantile/25820/2 "2019-06-28T21:01:30Z")

</div>

`muladd` does a “fused multiply-add” operation using SIMD instructions if possible. This will give slightly different results depending on instructions which are available on the machine (SSE, AVX, etc.). Anyway in general with floating point better be tolerant to small differences, e.g. using `isapprox`.

---

<div class="post-metadata">

**Author:** ![abx](https://avatars.discourse-cdn.com/v4/letter/a/edb3f5/32.png) [@abx](https://discourse.julialang.org/u/abx)\
**Post date:** [June 29, 2019, 4:41pm UTC](https://discourse.julialang.org/t/odd-result-from-distributions-quantile/25820/3 "2019-06-29T16:41:35Z")

</div>

That is the issue - one of the machines has FMA support, the other one does not! Thanks for you help 🙂

---

<div class="post-metadata">

**Author:** ![abx](https://avatars.discourse-cdn.com/v4/letter/a/edb3f5/32.png) [@abx](https://discourse.julialang.org/u/abx)\
**Post date:** [July 4, 2019, 6:56pm UTC](https://discourse.julialang.org/t/odd-result-from-distributions-quantile/25820/4 "2019-07-04T18:56:34Z")

</div>

Just in case anyone else stumble on my same issue - it is possible to exclude specific CPU features as described [here](https://docs.julialang.org/en/v1/devdocs/sysimg/index.html#Specifying-multiple-system-image-targets-1), so in my case I had to use the following arguments:

> julia --cpu-target=native,-fma

Moreover, since I am using workers for parallel operations, I had to add exeflags when starting new processes

> addprocs(_n_, exeflags=“–cpu-target=native,-fma”)
