Add scaled option for matrix generation

This commit is contained in:
Niclas
2026-03-02 15:26:02 +01:00
parent 9db48a9a33
commit 56125e7099

View File

@@ -48,6 +48,8 @@ source("R/graphon_distribution.R")
#' which is about `1.5e8` 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
}