# Range (statistics)

**URL:** <https://discourse.julialang.org/t/range-statistics/92518>\
**Category:** Statistics\
**Tags:** function\
**Created:** [January 4, 2023, 6:59pm UTC](https://discourse.julialang.org/t/range-statistics/92518 "2023-01-04T18:59:09Z")\
**Posts on this page:** 4\
**Page:** 2

<div class="post-metadata">

**Author:** ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Post date:** [January 5, 2023, 11:32pm UTC](https://discourse.julialang.org/t/range-statistics/92518/22 "2023-01-05T23:32:02Z")

</div>

> [@Dan](#):
>
> is it still 3X?

Yes, `extrema()` is still `3x` slower

---

<div class="post-metadata">

**Author:** ![uniment](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/uniment/32/24532_2.png) [@uniment](https://discourse.julialang.org/u/uniment)\
**Post date:** [January 6, 2023, 12:05am UTC](https://discourse.julialang.org/t/range-statistics/92518/23 "2023-01-06T00:05:33Z")

</div>

> [@rafael.guerra](#):
>
> `range4b()` is ~5% faster

branch prediction?

---

<div class="post-metadata">

**Author:** ![mcabbott](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mcabbott/32/6603_2.png) [@mcabbott](https://discourse.julialang.org/u/mcabbott)\
**Post date:** [January 6, 2023, 12:34am UTC](https://discourse.julialang.org/t/range-statistics/92518/24 "2023-01-06T00:34:48Z")

</div>

> [@DNF](#):
>
> Can you take a look at `Base.extrema` and see if you can tell what, if anything, is wrong with it, performance-wise?

One answer is [#45581](https://github.com/JuliaLang/julia/pull/45581). Which seems to be 3-4x faster than the functions above.

---

<div class="post-metadata">

**Author:** ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Post date:** [January 6, 2023, 9:09am UTC](https://discourse.julialang.org/t/range-statistics/92518/25 "2023-01-06T09:09:58Z")

</div>

Thank you for all the valuable answers. In the absence of a dedicated range function in the standard library, I marked the one from @stillyslalom as the solution, as it is the most compact one that uses `extrema()`, which according to @mcabbott will be greatly accelerated soon.

[Previous page](https://discourse.julialang.org/t/range-statistics/92518.md?page=1)
