# Testing multimodal distribution

**URL:** <https://discourse.julialang.org/t/testing-multimodal-distribution/44346>\
**Category:** Statistics\
**Tags:** question, package\
**Created:** [August 5, 2020, 3:38pm UTC](https://discourse.julialang.org/t/testing-multimodal-distribution/44346 "2020-08-05T15:38:25Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dario\_Sarra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dario_sarra/32/9338_2.png) [@Dario\_Sarra](https://discourse.julialang.org/u/Dario_Sarra)\
**Post date:** [August 5, 2020, 3:38pm UTC](https://discourse.julialang.org/t/testing-multimodal-distribution/44346/1 "2020-08-05T15:38:25Z")

</div>

I am trying to find implementations of any statistical method to test whether a sample is unimodal or multimodal distributed.  
From [Wikipedia Multimodal Distribution](https://en.wikipedia.org/wiki/Multimodal_distribution#Statistical_tests), you can find multiple example of such tests. In particular:

> An implementation of the dip test is available for the [R programming language](https://en.wikipedia.org/wiki/R_(programming_language)).[[56]](https://en.wikipedia.org/wiki/Multimodal_distribution#cite_note-56) The p-values for the dip statistic values range between 0 and 1. P-values less than 0.05 indicate significant multimodality and p-values greater than 0.05 but less than 0.10 suggest multimodality with marginal significance [[57]](https://en.wikipedia.org/wiki/Multimodal_distribution#cite_note-FreemanDale2012-57).

Is there anything like this in julia?

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [August 6, 2020, 12:54pm UTC](https://discourse.julialang.org/t/testing-multimodal-distribution/44346/2 "2020-08-06T12:54:11Z")

</div>

Not that I am aware of — maybe implement one of these methods and put it in a package. I recently came across the “folding” test

[https://hal.archives-ouvertes.fr/hal-01951676/document](https://hal.archives-ouvertes.fr/hal-01951676/document)

which looks intuitively appealing, haven’t used it yet though. But it should be easy to implement.

---

<div class="post-metadata">

**Author:** ![mthelm85](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mthelm85/32/224164_2.png) [@mthelm85](https://discourse.julialang.org/u/mthelm85)\
**Post date:** [August 6, 2020, 1:10pm UTC](https://discourse.julialang.org/t/testing-multimodal-distribution/44346/3 "2020-08-06T13:10:46Z")

</div>

> [@Tamas\_Papp](#):
>
> maybe implement one of these methods and put it in a package.

Maybe HypothesisTests.jl would be a good place?

---

<div class="post-metadata">

**Author:** ![Dario\_Sarra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dario_sarra/32/9338_2.png) [@Dario\_Sarra](https://discourse.julialang.org/u/Dario_Sarra)\
**Post date:** [August 7, 2020, 10:37am UTC](https://discourse.julialang.org/t/testing-multimodal-distribution/44346/4 "2020-08-07T10:37:48Z")

</div>

Thanks for the link, I’ll give it a shot and present it to HypothesisTests if it works

---

<div class="post-metadata">

**Author:** ![grero](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/grero/32/109_2.png) [@grero](https://discourse.julialang.org/u/grero)\
**Post date:** [April 11, 2024, 12:24pm UTC](https://discourse.julialang.org/t/testing-multimodal-distribution/44346/5 "2024-04-11T12:24:57Z")

</div>

Just came across this while searching for a solution to the same problem. Did you ever implement the algorithm?

---

<div class="post-metadata">

**Author:** ![Dario\_Sarra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dario_sarra/32/9338_2.png) [@Dario\_Sarra](https://discourse.julialang.org/u/Dario_Sarra)\
**Post date:** [April 12, 2024, 12:21pm UTC](https://discourse.julialang.org/t/testing-multimodal-distribution/44346/6 "2024-04-12T12:21:42Z")

</div>

I tried different methods, and with my data, the results were inconsistent. Some methods identified the distribution as bimodal, and others didn’t. Therefore, I gave up and used a different approach.

In case it is helpful what I did to convince a reviewer that the distribution wasn’t bimodal, I used k-means to divide my dataset forcefully into 2 sets and show that the rest of the results in my study were consistent across the 2 sets.
