Hi all,
yesterday me and a colleague found ourselves writing, for the millionth
time, a hansl function implementing the so-called "soft thresholding"
operator, and I was thinking that, although it's very easy, it'd be nice
if it were a builtin function. So I wrote a hansl function that IMO is
quite nice and general (works with scalars, series and matrices) and is
in the attached script, along with a few usage examples[*].
Note that the function could be made more general, for example
introducing the scalar rho as in
https://www.sciencedirect.com/topics/computer-science/soft-thresholding
, eq. (11.46) or allowing for "hard thresholding", like in the
Mathematica function "wthresh", but maybe not for now.
What I'm asking the community is:
1) Is it worthwhile having a dedicated function for this at all?
2) If so, should we have this as a builtin function[**], or should it
just be in extra?
3) Does anyone have better ideas on the function's signature?
[*] I know, it could have written in a cooler way by usign the sgn()
function and conditional assignment, but hey.
[**] We already have a C version for scalars in plugins/regls.c.
-------------------------------------------------------
Riccardo (Jack) Lucchetti
Dipartimento di Scienze Economiche e Sociali (DiSES)
Università Politecnica delle Marche
(formerly known as Università di Ancona)
r.lucchetti(a)univpm.it
http://www2.econ.univpm.it/servizi/hpp/lucchetti
-------------------------------------------------------