Add scaled option for matrix generation
This commit is contained in:
@@ -48,6 +48,8 @@ source("R/graphon_distribution.R")
|
|||||||
#' which is about `1.5e‑8` on most platforms – small enough to be negligible
|
#' which is about `1.5e‑8` on most platforms – small enough to be negligible
|
||||||
#' for most computations. If it is null, then it is not used.
|
#' for most computations. If it is null, then it is not used.
|
||||||
#' The guard is used for the value k = 0, which can cause arithmetic errors.
|
#' The guard is used for the value k = 0, which can cause arithmetic errors.
|
||||||
|
#' @param scaled Rescales the matrix according to the dimension with the factor
|
||||||
|
#' 1 / sqrt(n). Default value is FALSE.
|
||||||
#'
|
#'
|
||||||
#' @return A numeric matrix **Q** of dimension `K × n`. The \eqn{j}-th row
|
#' @return A numeric matrix **Q** of dimension `K × n`. The \eqn{j}-th row
|
||||||
#' (for `j = 1,…,K`) contains the increments of the CDF evaluated at
|
#' (for `j = 1,…,K`) contains the increments of the CDF evaluated at
|
||||||
@@ -105,7 +107,8 @@ compute_matrix <- function(
|
|||||||
sample_X_fn,
|
sample_X_fn,
|
||||||
fv,
|
fv,
|
||||||
Fv,
|
Fv,
|
||||||
guard = sqrt(.Machine$double.eps)
|
guard = sqrt(.Machine$double.eps),
|
||||||
|
scaled = FALSE
|
||||||
) {
|
) {
|
||||||
## 1.1 Check inputs ==========================================================
|
## 1.1 Check inputs ==========================================================
|
||||||
if (!is.numeric(seed) || length(seed) != 1) stop("'seed' must be a single number")
|
if (!is.numeric(seed) || length(seed) != 1) stop("'seed' must be a single number")
|
||||||
@@ -147,6 +150,7 @@ compute_matrix <- function(
|
|||||||
cdf_mat <- Fv(outer(graphon_quantiles, inner_products, "-")) # (K +1) x n matrix
|
cdf_mat <- Fv(outer(graphon_quantiles, inner_products, "-")) # (K +1) x n matrix
|
||||||
Q <- diff(cdf_mat, lag=1) # operates along rows
|
Q <- diff(cdf_mat, lag=1) # operates along rows
|
||||||
|
|
||||||
|
if (scaled) { Q <- 1 / sqrt(n) * Q }
|
||||||
Q
|
Q
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user