Skip to content

Threshold

Replaces array values whose magnitude is at or below the threshold with zero.

$ wo 'Threshold[{1, -2, 3, -0.5, 4}, 2]'
{0., 0., 3., 0., 4.}

The thresholding method can be given as {method, delta}. Soft thresholding shrinks each value toward zero by delta:

$ wo 'Threshold[{1, 2, 3, 4, 5}, {"Soft", 2}]'
{0., 0., 1., 2., 3.}

The non-negative garrote method:

$ wo 'Threshold[{1, 2, 3, 4, 5}, {"PiecewiseGarrote", 2}]'
{0., 0., 1.6666666666666667, 3., 4.2}