def mcs_to_rate(mcs, bw=20, long_gi=True):
    """Convert MCS index to rate in Mbps.

    See http://mcsindex.com/

    Args:
        mcs (int): MCS index
        bw (int): bandwidth, 20, 40, 80, ...
        long_gi(bool): True if long GI is used.

    Returns:
        rate (float): bitrate in Mbps


    >>> mcs_to_rate(5, bw=20, long_gi=False)
    57.8

    >>> mcs_to_rate(4, bw=40, long_gi=True)
    81

    >>> mcs_to_rate(3, bw=80, long_gi=False)
    130

    >>> mcs_to_rate(13, bw=160, long_gi=True)
    936
    """
    if bw not in [20, 40, 80, 160]:
        raise Exception("Unknown bandwidth: %d MHz" % (bw))
    if mcs not in MCS_TABLE:
        raise Exception("Unknown MCS: %d" % (mcs))

    idx = int((math.log(bw/10, 2)-1)*2)
    if not long_gi:
        idx += 1
    return MCS_TABLE[mcs][idx]