Skip to contents

This function generates a new matrix by applying a random linear transformation to a given latent matrix and adding Gaussian noise.

Usage

matrix_from_latent(latent_matrix, target_p, noise_sd = 0.3)

Arguments

latent_matrix

A numeric matrix representing the latent structure (n x k).

target_p

An integer specifying the number of columns in the output matrix.

noise_sd

A numeric value indicating the standard deviation of the Gaussian noise to be added. Default is 0.3.

Value

A numeric matrix of dimensions (n x target_p), generated from the latent matrix with a random linear transformation and added Gaussian noise.

Examples

latent <- matrix(rnorm(20), nrow = 5, ncol = 4)
generated_matrix <- matrix_from_latent(latent, target_p = 3, noise_sd = 0.2)
print(generated_matrix)
#>            [,1]        [,2]       [,3]
#> [1,] -0.8420428 -2.26384990 -1.4360201
#> [2,] -1.4226564  0.01670062  2.9901238
#> [3,] -3.9410985 -6.29693119  4.4003814
#> [4,]  2.4102664  1.54497778 -0.5047176
#> [5,] -1.5365092  0.60855535  0.2409585