Calculate the firing rate of spikes

    :param spike_times: times of spike instances
    :type spike_times: list
    :param window_size: length of time to use to determine rate.
    If none, uses time from first to last spike in spike_times
    :type window_size: float

def firing_rate(spike_times, window_size=None):
    """Calculate the firing rate of spikes

    :param spike_times: times of spike instances
    :type spike_times: list
    :param window_size: length of time to use to determine rate.
    If none, uses time from first to last spike in spike_times
    :type window_size: float
    """
    if len(spike_times) == 0:
        return 0

    if window_size is None:
        if len(spike_times) > 1:
            window_size = spike_times[-1] - spike_times[0]
        elif len(spike_times) > 0:
            # Only one spike, and no window - what to do?
            window_size = 1
        else:
            window_size = 0

    rate = window_size/len(spike_times)
    return rate