Generate random samples from a uniform distribution [0,1] and return in matrix form
Arguments
- dim1
The dimension of the matrix (if square), otherwise the number of rows.
- dim2
The number of columns, if different from the number of rows.
Examples
rand(2,3)
#> [,1] [,2] [,3]
#> [1,] 0.2717516 0.9919274 0.3182798
#> [2,] 0.5017143 0.5025788 0.6659964
rand(5)
#> [,1] [,2] [,3] [,4] [,5]
#> [1,] 0.31456713 0.5136063 0.4548753 0.72281396 0.9066814
#> [2,] 0.19491013 0.1752408 0.8044770 0.64161495 0.7553744
#> [3,] 0.59222335 0.3744199 0.1364994 0.07834173 0.7900134
#> [4,] 0.36817123 0.7626153 0.4031720 0.84524066 0.6066816
#> [5,] 0.04101537 0.4499194 0.7583156 0.02986028 0.4358027