Description Usage Arguments Examples
View source: R/nonnegativeleastsquares.R
plot_nnm_reconstruction
Function for plotting the nnm_sol reconstruction
1 | plot_nnm_reconstruction(nnm, X, nnm_sol)
|
nnm |
NNM object from generate_nnm function |
X |
Nonnegative design matrix |
nnm_sol |
Solution object from nnls_mm function |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | # Setup mixture example
n <- 1e3
p <- 10
nnm <- generate_nnm(n,p)
set.seed(12345)
X <- nnm$X
b <- double(p)
nComponents <- 3
k <- sample(1:p,nComponents,replace=FALSE)
b[k] <- matrix(runif(nComponents),ncol=1)
y <- X%*%b + 0.25*matrix(abs(rnorm(n)),n,1)
# Obtain solution to mixture problem
nnm_sol <- nnls_mm(y,X,runif(p))
# Plot the reconstruction
plot_nnm_reconstruction(nnm,X,nnm_sol)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.