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
|
||||
#' 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.
|
||||
#' @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
|
||||
#' (for `j = 1,…,K`) contains the increments of the CDF evaluated at
|
||||
@@ -105,7 +107,8 @@ compute_matrix <- function(
|
||||
sample_X_fn,
|
||||
fv,
|
||||
Fv,
|
||||
guard = sqrt(.Machine$double.eps)
|
||||
guard = sqrt(.Machine$double.eps),
|
||||
scaled = FALSE
|
||||
) {
|
||||
## 1.1 Check inputs ==========================================================
|
||||
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
|
||||
Q <- diff(cdf_mat, lag=1) # operates along rows
|
||||
|
||||
if (scaled) { Q <- 1 / sqrt(n) * Q }
|
||||
Q
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user