def _bw_scott(column_summ, N, logtrans, d):
    """Scott's rule of thumb for KDE kernel bandwidth.

    Parameters
    ----------
    column_summ : dict
        Dictionary as returned by `column_summary`.
    N : int
        Number of elements in the series for which the KDE is to be
        evaluated.
    logtrans : bool
        Whether the series is assumed to be 'exponential' (True) or
        'linear' (False). An 'exponential' series (representing, e.g.
        income) is log-transformed before the KDE. The bandwidth
        therefore needs to be estimated for the log transformed series.
    d : int
        Dimension of the KDE.

    Returns
    -------
    float
        Estimate of the kernel bandwidth for the KDE.
    """
    if N == 0:
        return 0

    norm = 1.349  # norm.ppf(0.75) - norm.ppf(0.25)
    if logtrans:
        std, IQR = column_summ["logtrans_std"], column_summ["logtrans_IQR"]
        factor = 2
    else:
        std, IQR = column_summ["std"], column_summ["iqr"]
        factor = 1.4

    if IQR > 0:
        iqr_estimate = min(IQR / norm, std)
    elif std > 0:
        iqr_estimate = std
    else:
        iqr_estimate = 1.0

    bandwidth = 1.06 * iqr_estimate * N ** (-1.0 / (4.0 + d))

    return bandwidth / factor