def delta_t_hist(t, nbins=50):
    """Build histogram of all possible delta_t's without storing every value"""
    hist = np.zeros(nbins, dtype='int')
    bins = np.linspace(0, max(t) - min(t), nbins+1)
    for i in range(len(t)):
        hist += np.histogram(t[i] - t[:i], bins=bins)[0]
        hist += np.histogram(t[i+1:] - t[i], bins=bins)[0]
    return hist / 2 # Double-counts since we loop over every pair twice
dataset/ETHPy150Open cesium-ml/cesium/cesium/obs_feature_tools.py/delta_t_hist/original