<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def mad(data):
 r"""Median absolute deviation This method calculates the median absolute deviation of the input data. Parameters data : np.ndarray Input data array Returns ------- float MAD value Examples -------- 2.0 Notes ----- The MAD is calculated as follows: .. math:: \mathrm{MAD} = \mathrm{median}\left(|X_i - \mathrm{median}(X)|\right) """


    return np.median(np.abs(data - np.median(data)))