# What is the difference between rand and sample?

**URL:** <https://discourse.julialang.org/t/what-is-the-difference-between-rand-and-sample/52297>\
**Category:** General Usage\
**Tags:** question\
**Created:** [December 23, 2020, 9:53pm UTC](https://discourse.julialang.org/t/what-is-the-difference-between-rand-and-sample/52297 "2020-12-23T21:53:00Z")\
**Posts on this page:** 1\
**Showing post:** 9

<div class="post-metadata">

**Author:** ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)\
**Post date:** [December 24, 2020, 12:53pm UTC](https://discourse.julialang.org/t/what-is-the-difference-between-rand-and-sample/52297/9 "2020-12-24T12:53:18Z")

</div>

I fully agree with this view. The function `sample` refers to an operation performed on a dataset (or population) and can take weights and replacement options. The function `rand` is for random variables with a given distribution (e.g. `Distributions.jl`).

---

_[View the full topic](https://discourse.julialang.org/t/what-is-the-difference-between-rand-and-sample/52297)._
