Total Variation Regularized Numerical Differentiation (TVDiff)
This Matlab code implements the methods found in Rick Chartrand, "Numerical differentiation of noisy, nonsmooth data," ISRN Applied Mathematics, Vol. 2011, Article ID 164564, 2011. This paper can be found in my Publications page. Please cite this paper if you use the code in published work.
The code was written and tested in Matlab version R2010a. Known issues:
In versions before R2009b, the tilde output argument is not supported. In the 'else' branch of the 'if diagflag' (one for each of the small and large cases), the pcg command can have the tilde output argument replaced with a dummy variable name. (Having an argument suppresses the printing of pcg diagnostics.)
The 'large' case is missing a factor of dx in the definition of both A and AT. I am not changing it for now, so that the demo results will more closely match those of the paper. In any event, using a value of dx that is larger than that dictated by your problem can make things better conditioned, so it's best to simply rescale the results.
The function cholinc is not available anymore starting in Matlab version R2013a. For recent versions, line 225 in TVRegDiff.m should be changed to:
R = ichol( B, struct( 'type', 'ict', 'droptol', droptol ) );
Feb. 2023: it seems that the behavior of the function ichol has changed again. A user reports success with the following modification:
R = ichol(B, struct('shape', 'upper', 'droptol', droptol));
Please send bug reports to rickchartrand@cal.berkeley.edu.
Download
Download TVDiff.tar.
Python version
Simone Sturniolo (simone.sturniolo@stfc.ac.uk) has provided a Python version of the code, available on GitHub.
Julia version
Adrian Hill (hill@campus.tu-berlin.de) has provided a Julia version of the code, available on GitHub.