@@ -27,7 +27,7 @@ What this function does depends on the arguments you give it.
27
27
There are _ many_ options.
28
28
29
29
With no arguments, it generates a float between 0 and 1.
30
- This is a [ ` uniform ` ] [ uniform-distribution ] with all values equally likely, as discussed in the Working with Distributions section, below.
30
+ This is a [ ` uniform ` ] [ uniform ] distribution with all values equally likely, as discussed in the Working with Distributions section, below.
31
31
32
32
A single integer argument generates a vector of that length.
33
33
@@ -81,6 +81,18 @@ julia> rand(1:10, 5)
81
81
In the ` rand(1:10, 5) ` example above, notice that there are (coincidentally) repeating values, because each pick is independent.
82
82
This is "sampling with replacement", discussed in more detail below.
83
83
84
+ For floating-point values in a range, you will usually need to specify a step size.
85
+ Otherwise the step will default to 1.0, which is rarely useful.
86
+
87
+ ``` julia-repl
88
+ julia> rand(2.4:0.01:3.2, 4)
89
+ 4-element Vector{Float64}:
90
+ 3.19
91
+ 2.53
92
+ 3.14
93
+ 3.13
94
+ ```
95
+
84
96
Alternatively, supply an array or tuple, and ` rand ` will return a random entry:
85
97
86
98
``` julia-repl
@@ -290,7 +302,7 @@ For a much wider range of options, there is the [`Distributions.jl`][distributio
290
302
[ sampling-with-replacement ] : https://www.youtube.com/watch?v=LnGFL_A6A6A
291
303
[ standard-deviation ] : https://simple.wikipedia.org/wiki/Standard_deviation
292
304
[ truly-random ] : https://www.malwarebytes.com/blog/news/2013/09/in-computers-are-random-numbers-really-random
293
- [ uniform-distribution ] : https://www.investopedia.com/terms/u/uniform-distribution.asp#:~:text=In%20statistics%2C%20uniform%20distribution%20refers,a%20spade%20is%20equally%20likely.
305
+ [ uniform ] : https://www.investopedia.com/terms/u/uniform-distribution.asp#:~:text=In%20statistics%2C%20uniform%20distribution%20refers,a%20spade%20is%20equally%20likely.
294
306
[ reproducibility ] : https://docs.julialang.org/en/v1/stdlib/Random/#Reproducibility
295
307
[ statsbase ] : https://juliastats.org/StatsBase.jl/stable/
296
308
[ sbsample ] : https://juliastats.org/StatsBase.jl/stable/sampling/#StatsBase.sample
0 commit comments