* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project

Survey

* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project

Document related concepts

Algorithm characterizations wikipedia, lookup

Mathematical optimization wikipedia, lookup

Eigenvalues and eigenvectors wikipedia, lookup

Smith–Waterman algorithm wikipedia, lookup

Pierre-Simon Laplace wikipedia, lookup

Computational electromagnetics wikipedia, lookup

Operational transformation wikipedia, lookup

Expectation–maximization algorithm wikipedia, lookup

Laplace transform wikipedia, lookup

Multidimensional empirical mode decomposition wikipedia, lookup

Linear algebra wikipedia, lookup

Transcript

Package ‘bcs’ April 5, 2017 Type Package Title Bayesian Compressive Sensing Using Laplace Priors Version 1.0.0 Date 2017-03-30 Description A Bayesian method for solving the compressive sensing problem. In particular, this package implements the algorithm 'Fast Laplace' found in the paper 'Bayesian Compressive Sensing Using Laplace Priors' by Babacan, Molina, Katsaggelos (2010) <DOI:10.1109/TIP.2009.2032894>. License GPL-3 | file LICENSE LazyData TRUE LinkingTo Rcpp, RcppArmadillo Imports fda (>= 2.4.4), stats (>= 3.3.2), Rcpp (>= 0.12.5), wmtsa (>= 2.0-1) RoxygenNote 5.0.1 Suggests testthat NeedsCompilation yes Author Matt Goodwin [aut, cre] Maintainer Matt Goodwin <[email protected]> Repository CRAN Date/Publication 2017-04-04 22:44:15 UTC R topics documented: BSplineBasis FastLaplace . FindSparse . FourierBasis . WaveletBasis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 2 4 5 6 8 1 2 FastLaplace BSplineBasis Finds the Transformation Matrix for the B-spline Basis Description Uses the package fda to find a transformation matrix where each column is a basis function from the B-spline basis, evaluated at specified points along the rows of the matrix. Usage BSplineBasis(tlist, N, train = NULL) Arguments tlist an array of the specific points where the basis functions are evaluated at. N number of basis functions in the matrix. train indices corresponding to which rows of the matrix to keep. Default is to keep all rows. Value A P x N discrete Fourier transformation matrix where P is equal to the length of train and N is the number of basis. If train is NULL then P equals the length of tlist. Examples # Points to evaluate the basis functions at points <- c(0,1,2,3,4) # Find first 8 B-spline basis functions evaluted at "points" b <- BSplineBasis(points, 8) # Find first 8 B-spline basis functions evaluated at "points" but only keep # last two rows b <- BSplineBasis(points, 8, train = c(4,5)) FastLaplace Implements the Fast Laplace Algorithm Description Implements the fast Laplace algorithm in Rcpp. For a more user friendly implementation of this function that makes things more convenient see FindSparse. Usage FastLaplace(PHI, y, sigma2, eta, roundit = 0L, verbose = 0L) FastLaplace 3 Arguments PHI typically equals the product of a measurment matrix and basis representation matrix, such as the wavelet basis. The solution vector w is assumed to be sparse in the chosen basis. y CS measurements, samples from the signal or function. sigma2 initial noise variance. eta threshold in determining convergence of marginal likelihood. roundit whether or not to round the marginal likelihood, in order to avoid machine precision error when comparing across platforms. 0 is False, 1 is True. verbose print which basis are added, re-estimated, or deleted. 0 is False, 1 is True. Details This code implements the fast Laplace algorithm from [1], which is based on [2]. The fast Laplace algorithm is a method used to solve the compressive sensing problem, or in general, a highly underdetermined system of equations. It does this by taking the system of equations y = Φw + n and converting it into a minimization problem where we minimize the error with a constraint on w (the vector we are solving for) that enforces sparsity. The fast Laplace method uses a Bayesian framework, and in particular, uses a Laplace prior to enforce sparsity on w. See [1] for more information. Value A list containing the following elements: weights used sigma2 errbars alpha sparse weights, the non-zero values of the sparse vector w. the positions of the sparse weights or non-zero values. re-estimated noise variance. one standard deviation around the sparse weights. sparse hyperparameters (1/gamma). References [1] S. D. Babacan, R. Molina and A. K. Katsaggelos, "Bayesian Compressive Sensing Using Laplace Priors," in IEEE Transactions on Image Processing, vol. 19, no. 1, pp. 53-63, Jan. 2010. [2] S. Ji, Y. Xue, L. Carin, "Bayesian Compressive Sensing," IEEE Trans. Signal Processing, vol. 56, no. 6, June 2008. [3] M. Tipping and A. Faul, "Fast marginal likelihood maximisation for sparse Bayesian models," in Proc. 9th Int. Workshop Artificial Intelligence and Statistics, C. M. Bishop and B. J. Frey, Eds., 2003. 4 FindSparse FindSparse Implements the Fast Laplace Algorithm Description Implements the fast Laplace algorithm given a measurement matrix and samples from a signal or function. Note that this function is a convenient wrapper for the function FastLaplace. Usage FindSparse(PHI, y, eta = 1e-08, roundit = FALSE, verbose = FALSE) Arguments PHI typically equals the product of a measurment matrix and basis representation matrix, such as the wavelet basis. The solution vector w (see Details below) is assumed to be sparse in the chosen basis. y CS measurements, samples from the signal or function. eta tolerance level in determining convergence of marginal likelihood. roundit whether or not to round the marginal likelihood, in order to avoid machine precision error when comparing across platforms. verbose print to screen which basis are added, re-estimated, or deleted. Details This code implements the fast Laplace algorithm. The fast Laplace algorithm is a method used to solve the compressive sensing problem, or in general, a highly underdetermined system of equations. It does this by taking the system of equations y = Φw + n and converting it into a minimization problem where we minimize the error with a constraint on w (the vector we are solving for) that enforces sparsity. The fast Laplace method uses a Bayesian framework, and in particular, uses a Laplace prior to enforce sparsity on w. See [1] for more information. Value The sparse signal w as found by the fast Laplace algorithm. References [1] S. D. Babacan, R. Molina and A. K. Katsaggelos, "Bayesian Compressive Sensing Using Laplace Priors," in IEEE Transactions on Image Processing, vol. 19, no. 1, pp. 53-63, Jan. 2010. FourierBasis 5 Examples # size of the basis function expansion N <- 64 # generate sparse coefficient vector w <- rep(0,N) w[sample(1:N,10)] <- runif(10,-1,1) # create wavelet basis trasform matrix wavelet.basis <- WaveletBasis(N) # generate actual signal signal <- wavelet.basis%*%w # now we try and recover 'w' and 'signal' from samples num_samps <- 25 # create random measurement matrix measure.mat <- matrix(runif(num_samps*N),num_samps,N) measure.mat <- measure.mat/matrix(rep(sqrt(apply(measure.mat^2,2,sum)), num_samps),num_samps,N,byrow=TRUE); PHI <- measure.mat%*%wavelet.basis # actual samples we see y <- measure.mat%*%signal # use fast Laplace algorithm w_est <- FindSparse(PHI, y) # compare plots of the sparse vector and the estimated sparse vector plot(w,type='h') lines(w_est,type='h',col='red') # estimate signal signal_est <- wavelet.basis%*%w_est # Root mean squared error of estimate error <- sqrt(mean((signal - signal_est)^2)) FourierBasis Finds the Discrete Fourier Transformation Matrix Description Uses the package fda to find a transformation matrix where the columns are the different Fourier basis functions, evaluated at specified points along the rows of the matrix. Usage FourierBasis(tlist, N, train = NULL) 6 WaveletBasis Arguments tlist an array of the specific points where the basis functions are evaluated at. N number of basis functions in the matrix. train indices corresponding to which rows of the matrix to keep. Default is to keep all rows. Value A P x N discrete Fourier transformation matrix where P is equal to the length of train and N is the number of basis. If train is NULL then P equals the length of tlist. Examples # Points to evaluate the basis functions at points <- c(0,1,2,3,4) # Find first 8 Fourier basis functions evaluted at "points" f <- FourierBasis(points, 8) # Find first 8 Fourier basis functions evaluated at "points" but only keep # last two rows f <- FourierBasis(points, 8, train = c(4,5)) WaveletBasis Finds the Discrete Wavelet Transform Matrix Description Uses the functions wavDWT and reconstruct from the wmtsa package to find the transformation matrix of the given wavelet basis type. Each column of the matrix is a wavelet basis function. Usage WaveletBasis(N, train = NULL, wavelet = "Haar") Arguments N number of wavelet basis functions to include in matrix. Note that N must be a power of 2, otherwise the matrix will include NA’s. The reason for this has to do with how the wavelet basis is defined. train indices corresponding to which rows of the matrix to keep. Default is to keep all rows. wavelet the type of wavelet basis to use. See wavDaubechies from wmtsa for types. Value A P x N discrete wavelet transform matrix, where P is equal to the length of train and N is the number of basis. If train is NULL then P equals N. WaveletBasis Examples # Find first 8 basis functions of the Haar wavelet type w.Haar <- WaveletBasis(8) # Find first 8 basis functions of the d4 wavelet type, keeping the first # half of the rows w.d4 <- WaveletBasis(8, 1:4, wavelet='d4') 7 Index BSplineBasis, 2 FastLaplace, 2, 4 fda, 2, 5 FindSparse, 2, 4 FourierBasis, 5 reconstruct, 6 wavDaubechies, 6 wavDWT, 6 WaveletBasis, 6 8