# Determining whether two methods are both extensions of the same function?

**URL:** <https://discourse.julialang.org/t/determining-whether-two-methods-are-both-extensions-of-the-same-function/55617>\
**Category:** New to Julia\
**Tags:** functions\
**Created:** [February 19, 2021, 2:17pm UTC](https://discourse.julialang.org/t/determining-whether-two-methods-are-both-extensions-of-the-same-function/55617 "2021-02-19T14:17:02Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![marty0801](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/marty0801/32/12715_2.png) [@marty0801](https://discourse.julialang.org/u/marty0801)\
**Post date:** [February 19, 2021, 2:17pm UTC](https://discourse.julialang.org/t/determining-whether-two-methods-are-both-extensions-of-the-same-function/55617/1 "2021-02-19T14:17:02Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![paulmelis](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/paulmelis/32/35063_2.png) [@paulmelis](https://discourse.julialang.org/u/paulmelis)\
**Post date:** [February 19, 2021, 3:05pm UTC](https://discourse.julialang.org/t/determining-whether-two-methods-are-both-extensions-of-the-same-function/55617/2 "2021-02-19T15:05:16Z")

</div>

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
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
...

```

---

<div class="post-metadata">

**Author:** ![dilumaluthge](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dilumaluthge/32/29283_2.png) [@dilumaluthge](https://discourse.julialang.org/u/dilumaluthge)\
**Post date:** [February 19, 2021, 3:10pm UTC](https://discourse.julialang.org/t/determining-whether-two-methods-are-both-extensions-of-the-same-function/55617/3 "2021-02-19T15:10:14Z")

</div>

You could also do this:

```julia
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.

---

<div class="post-metadata">

**Author:** ![marty0801](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/marty0801/32/12715_2.png) [@marty0801](https://discourse.julialang.org/u/marty0801)\
**Post date:** [February 19, 2021, 4:18pm UTC](https://discourse.julialang.org/t/determining-whether-two-methods-are-both-extensions-of-the-same-function/55617/4 "2021-02-19T16:18:21Z")

</div>

Thanks!
