def calculate_beta(weight_gap, weight_reference, weight_sample, gamma_gap, gamma_reference, gamma_sample):
    """
    Calculates the factor \(\\beta\) that is needed to calculate the compensated moment of a sample.
    """
    return ((weight_reference*gamma_reference)-(weight_sample*gamma_sample))/(weight_gap*gamma_gap)