# The percentile of a number in a vector

**URL:** <https://discourse.julialang.org/t/the-percentile-of-a-number-in-a-vector/80365>\
**Category:** New to Julia\
**Tags:** question\
**Created:** [May 2, 2022, 1:00pm UTC](https://discourse.julialang.org/t/the-percentile-of-a-number-in-a-vector/80365 "2022-05-02T13:00:23Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nash](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nash/32/14482_2.png) [@Nash](https://discourse.julialang.org/u/Nash)\
**Post date:** [May 2, 2022, 1:00pm UTC](https://discourse.julialang.org/t/the-percentile-of-a-number-in-a-vector/80365/1 "2022-05-02T13:00:23Z")

</div>

Is there a built-in function that finds the percentile of a number in a vector?

---

<div class="post-metadata">

**Author:** ![vettert](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/vettert/32/30599_2.png) [@vettert](https://discourse.julialang.org/u/vettert)\
**Post date:** [May 2, 2022, 2:19pm UTC](https://discourse.julialang.org/t/the-percentile-of-a-number-in-a-vector/80365/2 "2022-05-02T14:19:59Z")

</div>

(Deleted because I misunderstood the question)

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [May 2, 2022, 2:23pm UTC](https://discourse.julialang.org/t/the-percentile-of-a-number-in-a-vector/80365/3 "2022-05-02T14:23:34Z")

</div>

> [@Nash](#):
>
> Is there a built-in function that finds the percentile of a number in a vector?

I think you want something like the [`percentile` function in StatsBase.jl](https://juliastats.org/StatsBase.jl/stable/scalarstats/#StatsBase.percentile)? (Most of the statistics functions in Julia are in packages.)

Or do you want something like `percent(x, v) = 100 * count(<(x), v) / length(v)`, i.e. the percent of elements of `v` that are `< x`?

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [November 21, 2022, 3:33pm UTC](https://discourse.julialang.org/t/the-percentile-of-a-number-in-a-vector/80365/4 "2022-11-21T15:33:35Z")

</div>

6 posts were split to a new topic: [Opposite of StatsBase.percentile](https://discourse.julialang.org/t/opposite-of-statsbase-percentile/90592)
