# Random with no duplicate

**URL:** <https://discourse.julialang.org/t/random-with-no-duplicate/73434>\
**Category:** New to Julia\
**Created:** [December 21, 2021, 12:52pm UTC](https://discourse.julialang.org/t/random-with-no-duplicate/73434 "2021-12-21T12:52:07Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![hieun](https://avatars.discourse-cdn.com/v4/letter/h/8e8cbc/32.png) [@hieun](https://discourse.julialang.org/u/hieun)\
**Post date:** [December 21, 2021, 12:52pm UTC](https://discourse.julialang.org/t/random-with-no-duplicate/73434/1 "2021-12-21T12:52:07Z")

</div>

Hello everyone, I’m trying to random some values in range 1:100, and i want every value is unique, not duplicate. I’m using rand(1:100, n) to random n values but it doesn’t work as expected. Anyone give me solution ? Thanks

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://discourse.julialang.org/u/jules)\
**Post date:** [December 21, 2021, 1:01pm UTC](https://discourse.julialang.org/t/random-with-no-duplicate/73434/2 "2021-12-21T13:01:06Z")

</div>

Check this thread [Sampling from a list of integers without repetition](https://discourse.julialang.org/t/sampling-from-a-list-of-integers-without-repetition/41395)

---

<div class="post-metadata">

**Author:** ![hieun](https://avatars.discourse-cdn.com/v4/letter/h/8e8cbc/32.png) [@hieun](https://discourse.julialang.org/u/hieun)\
**Post date:** [December 21, 2021, 1:14pm UTC](https://discourse.julialang.org/t/random-with-no-duplicate/73434/3 "2021-12-21T13:14:37Z")

</div>

Thanks, i solved it

---

<div class="post-metadata">

**Author:** ![trilobit](https://avatars.discourse-cdn.com/v4/letter/t/a8b319/32.png) [@trilobit](https://discourse.julialang.org/u/trilobit)\
**Post date:** [December 21, 2021, 1:17pm UTC](https://discourse.julialang.org/t/random-with-no-duplicate/73434/4 "2021-12-21T13:17:18Z")

</div>

mydata=unique(rand(1:100, n)) ?

---

<div class="post-metadata">

**Author:** ![gustaphe](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gustaphe/32/18174_2.png) [@gustaphe](https://discourse.julialang.org/u/gustaphe)\
**Post date:** [December 21, 2021, 1:30pm UTC](https://discourse.julialang.org/t/random-with-no-duplicate/73434/5 "2021-12-21T13:30:12Z")

</div>

That will not in general return `n` numbers though.
