View source: R/multiscaleSVDxpts.R
sum_preserving_matrix_partition | R Documentation |
This function takes a matrix as input and partitions each column such that only one entry in each row is non-zero, and the sums of each row are roughly equivalent.
sum_preserving_matrix_partition(X, option = 2, tol = 0.001)
X |
A matrix of size p x k |
option |
An integer indicating whether to allow +/- values (option 1) or only + values (option 2). Default is 1. |
tol |
A numeric value indicating the tolerance for the row sums. Default is 0.1. |
The function uses a greedy algorithm to select the entry with the maximum absolute value (or maximum positive value) in each column. The rows are then normalized to ensure that the sums are roughly equivalent.
A matrix with segmented rows
X <- matrix(rnorm(3000), nrow = 1000)
Y <- sum_preserving_matrix_partition(X, option = 1)
Y <- sum_preserving_matrix_partition(X, option = 2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.