# Creating a new distibution with Distributions.jl

**URL:** <https://discourse.julialang.org/t/creating-a-new-distibution-with-distributions-jl/138436>\
**Category:** New to Julia\
**Tags:** distributions, subtype\
**Created:** [July 23, 2026, 9:02pm UTC](https://discourse.julialang.org/t/creating-a-new-distibution-with-distributions-jl/138436 "2026-07-23T21:02:02Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![dgagnon](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dgagnon/32/45466_2.png) [@dgagnon](https://discourse.julialang.org/u/dgagnon)\
**Post date:** [July 23, 2026, 9:02pm UTC](https://discourse.julialang.org/t/creating-a-new-distibution-with-distributions-jl/138436/1 "2026-07-23T21:02:02Z")

</div>

Hello

I am trying to create a new discrete distribution using the package Distributions.jl but I am getting error. I have tried with `import` instead of `using` but I always get the same message.

```julia-auto
using Distributions
julia> struct shiftwilcoxon <: DiscreteUnivarateDistribution
                n1::Int
                n2::Int
                lambda::Float64
                eta::Float64
       end
ERROR: UndefVarError: `DiscreteUnivarateDistribution` not defined in `Main`
Suggestion: check for spelling errors or missing imports.

```

What am I missing?  
I will define all mandatory methods mentioned in the documentation after, but I understood that the first step was to create my structure from the abstract type.

Thanks for your time.

---

<div class="post-metadata">

**Author:** ![ForceBru](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/forcebru/32/21389_2.png) [@ForceBru](https://discourse.julialang.org/u/ForceBru)\
**Post date:** [July 23, 2026, 10:09pm UTC](https://discourse.julialang.org/t/creating-a-new-distibution-with-distributions-jl/138436/2 "2026-07-23T22:09:34Z")

</div>

Have you tried `struct shiftwilcoxon <: Distributions.DiscreteUnivarateDistribution`?

---

<div class="post-metadata">

**Author:** ![dgagnon](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dgagnon/32/45466_2.png) [@dgagnon](https://discourse.julialang.org/u/dgagnon)\
**Post date:** [July 24, 2026, 12:26am UTC](https://discourse.julialang.org/t/creating-a-new-distibution-with-distributions-jl/138436/3 "2026-07-24T00:26:35Z")

</div>

Just did. But now I have

```julia-auto
ERROR: UndefVarError: `DiscreteUnivarateDistribution` not defined in `Distributions`
Suggestion: check for spelling errors or missing imports.

```

Do I need to import something else?

---

<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:** [July 24, 2026, 12:47am UTC](https://discourse.julialang.org/t/creating-a-new-distibution-with-distributions-jl/138436/4 "2026-07-24T00:47:51Z")

</div>

I think you have a small, very subtle spelling mistake?

I think the spelling should be: `DiscreteUnivariateDistribution`

“Univariate” instead of “Univarate”

---

<div class="post-metadata">

**Author:** ![dgagnon](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dgagnon/32/45466_2.png) [@dgagnon](https://discourse.julialang.org/u/dgagnon)\
**Post date:** [July 24, 2026, 11:17am UTC](https://discourse.julialang.org/t/creating-a-new-distibution-with-distributions-jl/138436/5 "2026-07-24T11:17:02Z")

</div>

Oh god! I cut and paste from the documentation. I never thought it could contain a typo.

Thanks a lot.

---

<div class="post-metadata">

**Author:** ![asinghvi17](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/asinghvi17/32/8272_2.png) [@asinghvi17](https://discourse.julialang.org/u/asinghvi17)\
**Post date:** [July 24, 2026, 8:01pm UTC](https://discourse.julialang.org/t/creating-a-new-distibution-with-distributions-jl/138436/6 "2026-07-24T20:01:05Z")

</div>

[Fix typo in docs and add `@ref`s - Pull Request #2085 - JuliaStats/Distributions.jl - GitHub](https://github.com/JuliaStats/Distributions.jl/pull/2085) should fix that typo in the docs
