def compute_stats(hits,
                  misses,
                  false_alarms,
                  correct_rejections,
                  partial_hits=0,
                  partial_hit_weight=1.0,
                  partial_misses=0,
                  partial_miss_weight=0.0
                  ):
    """
    Computes scoring statistics based on hits (H), misses (M),
    false alarms (F) and correct rejections (C).
    
    Optionally, partial hits and misses can also be passes, along with
    weights for each.
    
    In the case of binary scoring (no partial hits/misses)
    
    stats = {'n_truth':H+M,
             'n_pred':H+F,
             'hits':H,
             'misses':M,
             'false_alarms':F,
             'correct_rejections':C,
             'pod':H/(H+M),
             'far':F/(F+H),
             'csi':H/(H+M+F),
             'bias':(H+F)/(H+M)}
    
    If partial hits/misses are included, then  
      
        hits  :  hits   + partial_hits * partial_hit_weight
        misses  :  misses + partial_misses * partial_miss_weight
    
    
    Parameters
    ----------
    hits   scalar
       Number of hits in scene   
    misses   scalar
       Number of misses in scene
    false_alarms   scalar
       Number of false alarms in scene
    correct_rejections   scalar
       Number of correct rejections in scene
    partial_hits scalar
       Number of partial hits
    partial_hits_weight scalar
       Weight of partial hits in pod/far/csi calculation
    partial_misses
       Number of partial misses
    partial_missses_weight scalar
       Weight of partial misses in pod/far/csi calculation
       
    Returns
    -------
    scores  dict
       Dictionary containing statistics                    
    """
    H=hits+partial_hits*partial_hit_weight
    M=misses+partial_misses*partial_miss_weight
    F=false_alarms
    C=correct_rejections
    
    n_truth=1.0*(H+M)
    n_pred=1.0*(H+F)
    n_any=1.0*(H+M+F)
    
    pod = 1.0*H/n_truth if n_truth>0 else 1.0
    far = 1.0*F/n_pred if n_pred>0 else 0.0
    csi = 1.0*H/n_any if n_any>0 else 1.0
    bias = n_pred/n_truth if n_truth>0 else 1.0
    
    return {'n_truth':  n_truth,
            'n_pred':  n_pred,
            'hits':    H,
            'misses':  M,
            'false_alarms':F,
            'correct_rejections':C,
            'pod':pod,
            'far':far,
            'csi':csi,
            'bias':bias}