Skip to content

Commit ac68317

Browse files
colinleachColin Leach
and
Colin Leach
authored
Update randomness (#909)
* concepts.wip exercises changed to deprecated * Revert "concepts.wip exercises changed to deprecated" This reverts commit 28f91a8. * Change annelyns-infiltration slug for old version * Revert "Change annelyns-infiltration slug for old version" This reverts commit 09dfe5d. * propagates edits from captains-log --------- Co-authored-by: Colin Leach <[email protected]>
1 parent 30c8a5a commit ac68317

File tree

2 files changed

+27
-3
lines changed

2 files changed

+27
-3
lines changed

concepts/randomness/about.md

+14-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ What this function does depends on the arguments you give it.
2727
There are _many_ options.
2828

2929
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.
3131

3232
A single integer argument generates a vector of that length.
3333

@@ -81,6 +81,18 @@ julia> rand(1:10, 5)
8181
In the `rand(1:10, 5)` example above, notice that there are (coincidentally) repeating values, because each pick is independent.
8282
This is "sampling with replacement", discussed in more detail below.
8383

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+
8496
Alternatively, supply an array or tuple, and `rand` will return a random entry:
8597

8698
```julia-repl
@@ -290,7 +302,7 @@ For a much wider range of options, there is the [`Distributions.jl`][distributio
290302
[sampling-with-replacement]: https://www.youtube.com/watch?v=LnGFL_A6A6A
291303
[standard-deviation]: https://simple.wikipedia.org/wiki/Standard_deviation
292304
[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.
294306
[reproducibility]: https://docs.julialang.org/en/v1/stdlib/Random/#Reproducibility
295307
[statsbase]: https://juliastats.org/StatsBase.jl/stable/
296308
[sbsample]: https://juliastats.org/StatsBase.jl/stable/sampling/#StatsBase.sample

concepts/randomness/introduction.md

+13-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ What this function does depends on the arguments you give it.
2727
There are _many_ options.
2828

2929
With no arguments, it generates a float between 0 and 1.
30-
This is a `uniform` with all values equally likely, as discussed in the Working with Distributions section, below.
30+
This is a `uniform` distribution with all values equally likely, as discussed in the Working with Distributions section, below.
3131

3232
A single integer argument generates a vector of that length.
3333

@@ -81,6 +81,18 @@ julia> rand(1:10, 5)
8181
In the `rand(1:10, 5)` example above, notice that there are (coincidentally) repeating values, because each pick is independent.
8282
This is "sampling with replacement", discussed in more detail below.
8383

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+
8496
Alternatively, supply an array or tuple, and `rand` will return a random entry:
8597

8698
```julia-repl

0 commit comments

Comments
 (0)