Learn R Programming

topolow (version 1.0.0)

add_noise_bias: Add Noise and Bias to Matrix Data

Description

Creates noisy versions of a distance matrix by adding random noise and/or systematic bias. Useful for testing robustness of algorithms to measurement errors and systematic biases.

Usage

add_noise_bias(matrix_data)

Value

A list containing three noisy matrix objects:

n1

Matrix with the first realization of random Gaussian noise.

n2

Matrix with a second, different realization of random Gaussian noise.

nb

Matrix with both random noise and a systematic negative bias.

Arguments

matrix_data

Numeric matrix to add noise to

Details

The function generates three variants of the input matrix:

  1. n1: Matrix with random Gaussian noise

  2. n2: Different realization of random noise

  3. nb: Matrix with both random noise and systematic negative bias

The noise level is scaled relative to the data mean to maintain realistic error magnitudes.

Examples

Run this code
# Create sample distance matrix
dist_mat <- matrix(runif(100), 10, 10)
dist_mat[lower.tri(dist_mat)] <- t(dist_mat)[lower.tri(dist_mat)]
diag(dist_mat) <- 0

# Generate noisy versions
noisy_variants <- add_noise_bias(dist_mat)

Run the code above in your browser using DataLab