Computes the median absolute deviation with a fallback for
zero or near-zero MAD (constant columns). In that case the
inter-quartile range scaled to match the normal distribution
is used. If both are zero, returns 1 so that standardized
values remain unchanged.