Let’s add some bounds on the initial matrix generation methods.
row_sum <- seq(20, 80, 10)
mat_min <- row_sum %*% t(row_sum) * 0 + 2
mat_max <- row_sum %*% t(row_sum) * 0 + 30
generate_matrix_homo(row_sum, mat_min = mat_min, mat_max = mat_max)
## [,1] [,2] [,3] [,4] [,5] [,6] [,7]
## [1,] 3 3 3 2 3 3 3
## [2,] 3 5 4 5 4 4 5
## [3,] 3 4 7 7 7 6 6
## [4,] 3 4 7 9 9 9 9
## [5,] 2 4 6 9 12 14 13
## [6,] 3 5 6 9 13 17 17
## [7,] 3 5 7 9 12 17 27
mat_max <- row_sum %*% t(row_sum) * 0 + 75
generate_matrix_hetero(row_sum, mat_min = mat_min, mat_max = mat_max)
## [,1] [,2] [,3] [,4] [,5] [,6] [,7]
## [1,] 8 2 2 2 2 2 2
## [2,] 2 18 2 2 2 2 2
## [3,] 2 2 28 2 2 2 2
## [4,] 2 2 2 38 2 2 2
## [5,] 2 2 2 2 48 2 2
## [6,] 2 2 2 2 2 58 2
## [7,] 2 2 2 2 2 2 68
mat_max <- row_sum %*% t(row_sum) * 0 + 20
generate_matrix_prop(row_sum, mat_min = mat_min, mat_max = mat_max)
## [,1] [,2] [,3] [,4] [,5] [,6] [,7]
## [1,] 2 2 2 3 3 4 4
## [2,] 3 2 3 5 5 6 6
## [3,] 2 4 6 5 6 8 9
## [4,] 2 5 5 8 8 10 12
## [5,] 3 5 6 8 11 12 15
## [6,] 4 6 8 10 12 14 16
## [7,] 4 6 10 11 15 16 18
The maximum constraint poses some issues because the method may take an incorrect start and loop indefinitely. Solving this issue is left to future developements.
## R version 3.4.3 (2017-11-30)
## Platform: x86_64-pc-linux-gnu (64-bit)
## Running under: Ubuntu 16.04.3 LTS
##
## Matrix products: default
## BLAS: /usr/lib/openblas-base/libblas.so.3
## LAPACK: /usr/lib/libopenblasp-r0.2.18.so
##
## locale:
## [1] LC_CTYPE=fr_FR.UTF-8 LC_NUMERIC=C
## [3] LC_TIME=fr_FR.UTF-8 LC_COLLATE=fr_FR.UTF-8
## [5] LC_MONETARY=fr_FR.UTF-8 LC_MESSAGES=fr_FR.UTF-8
## [7] LC_PAPER=fr_FR.UTF-8 LC_NAME=C
## [9] LC_ADDRESS=C LC_TELEPHONE=C
## [11] LC_MEASUREMENT=fr_FR.UTF-8 LC_IDENTIFICATION=C
##
## attached base packages:
## [1] stats graphics grDevices utils datasets methods base
##
## other attached packages:
## [1] stringr_1.0.0 tidyr_0.2.0 ggplot2_2.2.1 dplyr_0.4.3 purrr_0.2.0
##
## loaded via a namespace (and not attached):
## [1] Rcpp_0.12.10 knitr_1.15.1 magrittr_1.5 munsell_0.4
## [5] colorspace_1.2-2 R6_2.1.0 rlang_0.1 plyr_1.8.1
## [9] tools_3.4.3 parallel_3.4.3 grid_3.4.3 gtable_0.1.2
## [13] pacman_0.4.6 DBI_0.3.1 htmltools_0.3.6 yaml_2.1.13
## [17] lazyeval_0.2.0 rprojroot_1.2 digest_0.6.3 assertthat_0.1
## [21] tibble_1.3.1 evaluate_0.10 rmarkdown_1.5 stringi_0.5-5
## [25] compiler_3.4.3 scales_0.4.1 backports_1.0.5