def mad(self, median=None):
"""
Return the median absolute deviation for this segment only,
scaled by phi-1(3/4) to approximate the standard deviation.
:param median: If this is not None, it will be used as the median from which the deviation is calculated.
:return: A NDarray of shape (n_channels, 1) with the MAD for the channels of this segment.
"""
c = scipy.stats.norm.ppf(3 / 4)
if median is None:
subject_median = self.median()
else:
subject_median = median
median_residuals = self.mat_struct.data - subject_median # deviation between median and data
mad = np.median(np.abs(median_residuals), axis=1)[:, np.newaxis]
return mad / c
评论列表
文章目录