Measurement Matrix
This module contains functions to generate measurement matrices used in compressive sensing.
measurement_matrix.py - Functions for generating deterministic and random measurement matrices.
This module provides functionality to generate: 1. Deterministic Diagonally Blocked Block Diagonal (DBBD) matrices. 2. Random matrices based on different types, such as Gaussian and binary matrices.
These matrices are commonly used in compressed sensing and other signal processing applications.
Example usage:
>>> from measurement_matrix import generate_DBBD_matrix, generate_random_matrix
>>> # Generate a DBBD matrix
>>> dbbd_matrix = generate_DBBD_matrix(3, 9)
>>> # Generate a Gaussian random matrix
>>> random_matrix = generate_random_matrix(3, 9, matrix_type='gaussian')
- CompSensePack.measurement_matrix.generate_DBBD_matrix(M, N)[source]
Generates a deterministic Diagonally Blocked Block Diagonal (DBBD) matrix.
A DBBD matrix is a type of block diagonal matrix where each block is a square diagonal matrix.
Parameters
- Mint
Number of rows in the matrix.
- Nint
Number of columns in the matrix. Should be a multiple of M.
Returns
- Anumpy.ndarray
The generated DBBD matrix of shape (M, N).
Raises
- ValueError
If N is not a multiple of M.
Example
>>> generate_DBBD_matrix(3, 9) array([[1., 1., 1., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 1., 1., 1., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 1., 1., 1.]])
- CompSensePack.measurement_matrix.generate_random_matrix(M, N, matrix_type='gaussian')[source]
Generates a random matrix based on the specified type.
Parameters
- Mint
Number of rows in the matrix.
- Nint
Number of columns in the matrix.
- matrix_typestr, optional (default=’gaussian’)
The type of random matrix to generate. Options are: - ‘gaussian’: A matrix with entries drawn from a normal distribution scaled by 1/M. - ‘scaled_binary’: A matrix with binary entries (±0.5), scaled by 1/sqrt(M). - ‘unscaled_binary’: A matrix with binary entries (±1), with no scaling.
Returns
- Anumpy.ndarray
The generated random matrix of shape (M, N).
Raises
- ValueError
If matrix_type is not one of the supported types.
Example
>>> generate_random_matrix(2, 3, matrix_type='gaussian') array([[ 0.01, -0.02, 0.03], [-0.04, 0.05, -0.06]])
>>> generate_random_matrix(2, 3, matrix_type='scaled_binary') array([[-0.5, 0. , -0.5], [ 0.5, -0.5, 0. ]])
>>> generate_random_matrix(2, 3, matrix_type='unscaled_binary') array([[ 1., -1., 1.], [-1., 1., -1.]])