  The theory of compressive sensing (CS) asserts that an unknown signal
$\mathbf{x} \in \mathbb{C}^N$ can be accurately recovered from $m$ measurements
with $m\ll N$ provided that $\mathbf{x}$ is sparse. Most of the recovery
algorithms need the sparsity $s=\lVert\mathbf{x}\rVert_0$ as an input. However,
generally $s$ is unknown, and directly estimating the sparsity has been an open
problem. In this study, an estimator of sparsity is proposed by using Bayesian
hierarchical model. Its statistical properties such as unbiasedness and
asymptotic normality are proved. In the simulation study and real data study,
magnetic resonance image data is used as input signal, which becomes sparse
after sparsified transformation. The results from the simulation study confirm
the theoretical properties of the estimator. In practice, the estimate from a
real MR image can be used for recovering future MR images under the framework
of CS if they are believed to have the same sparsity level after
sparsification.
