I have two functions with the same name, but from two different packages. How do I determine whether one of them is an extension of the other or both are extensions of the same function? I have in mind `mean()`

which occurs in both Distributions.jl and Statistics.jl

I only starting using Julia recently, but doesn’t `methods(mean)`

tell you what you want to know? If there are multiple methods from different sources for function `mean`

it will list them. E.g.

```
julia> using Statistics
julia> using Distributions
julia> methods(mean)
# 88 methods for generic function "mean":
[1] mean(d::DiscreteUniform) in Distributions at /home/melis/.julia/packages/Distributions/jFoHB/src/univariate/discrete/discreteuniform.jl:52
[2] mean(d::Hypergeometric) in Distributions at /home/melis/.julia/packages/Distributions/jFoHB/src/univariate/discrete/hypergeometric.jl:47
[3] mean(d::Kolmogorov) in Distributions at /home/melis/.julia/packages/Distributions/jFoHB/src/univariate/continuous/kolmogorov.jl:22
[4] mean(d::Chernoff) in Distributions at /home/melis/.julia/packages/Distributions/jFoHB/src/univariate/continuous/chernoff.jl:220
[5] mean(r::AbstractRange{var"#s828"} where var"#s828"<:Real) in Statistics at /usr/share/julia/stdlib/v1.5/Statistics/src/Statistics.jl:185
[6] mean(A::AbstractArray{T,N} where N, w::StatsBase.AbstractWeights{W,T,V} where V<:AbstractArray{T,1} where T<:Real, dims::Int64) where {T<:Number, W<:Real} in StatsBase at deprecated.jl:70
[7] mean(A::AbstractArray; dims) in Statistics at /usr/share/julia/stdlib/v1.5/Statistics/src/Statistics.jl:164
[8] mean(A::AbstractArray, w::StatsBase.UnitWeights; dims) in StatsBase at /home/melis/.julia/packages/StatsBase/548SN/src/weights.jl:620
[9] mean(A::AbstractArray, w::StatsBase.AbstractWeights; dims) in StatsBase at /home/melis/.julia/packages/StatsBase/548SN/src/weights.jl:613
[10] mean(d::Bernoulli) in Distributions at /home/melis/.julia/packages/Distributions/jFoHB/src/univariate/discrete/bernoulli.jl:60
[11] mean(d::BetaBinomial) in Distributions at /home/melis/.julia/packages/Distributions/jFoHB/src/univariate/discrete/betabinomial.jl:57
[12] mean(d::Binomial) in Distributions at /home/melis/.julia/packages/Distributions/jFoHB/src/univariate/discrete/binomial.jl:68
[13] mean(d::DiscreteNonParametric) in Distributions at /home/melis/.julia/packages/Distributions/jFoHB/src/univariate/discrete/discretenonparametric.jl:156
...
```

You could also do this:

```
julia> import Distributions, Statistics, StatsBase
julia> Distributions.mean === Statistics.mean
julia> Distributions.mean === StatsBase.mean
julia> Statistics.mean === StatsBase.mean
```

This will print true if the two `mean`

s are the same generic function.

5 Likes

Thanks!