Practical collapse

global option

Author

A Ginolhac

Published

September 22, 2025

Note

This practical has:

  • show-solution: true, solution are displayed.
  • collapse-solution: false, solution are not collapsed (collapsed is the usual default mode)
Generate 5 numbers from the uniform distribution between 0 and 1
SolutionSolution 1
runif(n = 5)
[1] 0.14390831 0.08263177 0.31566206 0.19642834 0.07688183

The next solution collapsed despite the global option because of its specific option: #| unilur-collapse: true

Generate 5 numbers from the uniform distribution between 5 and 10
 runif(n = 5, min = 5, max = 10)
[1] 6.742243 9.206956 5.961668 5.032217 8.416589
Generate 5 numbers from the strandard distribution
SolutionSolution 3
 rnorm(n = 5)
[1] -0.24673227  0.71884133  2.32360426 -0.09054084 -0.74260678

Next block is also collapsed individually

Results are always changing, how to get identical random numbers?

Use the set.seed(xx) where xx is a fixed number.