# Error in Distributions.quantile when broadcasting in Julia 1.0

**URL:** <https://discourse.julialang.org/t/error-in-distributions-quantile-when-broadcasting-in-julia-1-0/14182>\
**Category:** General Usage\
**Created:** [August 28, 2018, 11:45am UTC](https://discourse.julialang.org/t/error-in-distributions-quantile-when-broadcasting-in-julia-1-0/14182 "2018-08-28T11:45:18Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![cherichy](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cherichy/32/5167_2.png) [@cherichy](https://discourse.julialang.org/u/cherichy)\
**Post date:** [August 28, 2018, 11:45am UTC](https://discourse.julialang.org/t/error-in-distributions-quantile-when-broadcasting-in-julia-1-0/14182/1 "2018-08-28T11:45:19Z")

</div>

I found this broadcast error when using Distributions.quantile. And I found that it was called on the type of Noraml, which is the first parameter. So I check the help ?quantile, and found that there are three usages of quantine:

```julia
quantile(itr, p; sorted=false)
eg: quantile(0:20, [0.1, 0.5, 0.9])

quantile(v, w::AbstractWeights, p)

quantile(d::UnivariateDistribution, q::Real)

```

The error is shown below, it can be seen that the first version was invoked. As the package has been updated, the version `quantile(d::UnivariateDistribution, X::AbstractArray)` is deprecated. Is this a bug of Julia or the package Distribuations?

```julia
julia> using Distributions

julia> d=Normal(0.0,1.0)
Normal{Float64}(μ=0.0, σ=1.0)

julia> quantile(d,0.7)
0.5244005127080407

julia> quantile.(d,[0.1,0.7])
ERROR: MethodError: no method matching iterate(::Normal{Float64})
Closest candidates are:
  iterate(::Core.SimpleVector) at essentials.jl:578
  iterate(::Core.SimpleVector, ::Any) at essentials.jl:578
  iterate(::ExponentialBackOff) at error.jl:171
  ...
Stacktrace:
 [1] copyto!(::Array{Float64,1}, ::Normal{Float64}) at .\abstractarray.jl:646
 [2] _collect(::UnitRange{Int64}, ::Normal{Float64}, ::Base.HasEltype, ::Base.HasLength) at .\array.jl:563
 [3] collect(::Normal{Float64}) at .\array.jl:557
 [4] broadcastable(::Normal{Float64}) at .\broadcast.jl:609
 [5] broadcasted(::Function, ::Normal{Float64}, ::Array{Float64,1}) at .\broadcast.jl:1139
 [6] top-level scope at none:0

```

---

<div class="post-metadata">

**Author:** ![Nosferican](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nosferican/32/9275_2.png) [@Nosferican](https://discourse.julialang.org/u/Nosferican)\
**Post date:** [August 28, 2018, 5:30pm UTC](https://discourse.julialang.org/t/error-in-distributions-quantile-when-broadcasting-in-julia-1-0/14182/2 "2018-08-28T17:30:50Z")

</div>

```julia
quantile.(Ref(d), [0.1,0.7])

```

You should check the documentation of `broadcast` in particular the part about `Ref` which has good examples.

---

<div class="post-metadata">

**Author:** ![cherichy](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cherichy/32/5167_2.png) [@cherichy](https://discourse.julialang.org/u/cherichy)\
**Post date:** [August 29, 2018, 12:47am UTC](https://discourse.julialang.org/t/error-in-distributions-quantile-when-broadcasting-in-julia-1-0/14182/3 "2018-08-29T00:47:19Z")

</div>

Thanks for your help 😀  
I just follow the deprecated warning and `quantile(d::UnivariateDistribution, X::AbstractArray)` is deprecated, use `quantile.(d, X)` instead.
