import numpy as np

def mad(x, axis=None, no_scale=False):
    """
    median absolute deviation - scaled like a standard deviation    
    
        mad = 1.4826*median(|x-median(x)|)
        
    Parameters
    ----------
    x: array-like 
        array to take MAD of
    axis: int
        axis over which to take mode (default: None)
    no_scale: bool
        return MAD not scaled to match a Gaussian (default: False)
    
    Returns
    -------
    mad: float
        MAD of array x    
    """
    mad = np.median(np.abs(x - np.median(x,axis=axis)),axis=axis)
    if no_scale:
        return mad
    else:
        return 1.4826*mad
