def get_substring_ef1_score(probabilities, substring_seq):
    """
    Get expected F1-score for a probability distribution

    params:
    probabilities (list): List of probabilities
    substring_seq (tuple): start and end index
    Returns:
    float: Expected f1 score for a string

    """
    # sum of all probabilities
    sum_of_all_probabilities = sum(probabilities)
    # probability substring
    substring_probabilities = probabilities[substring_seq[0]:substring_seq[1]]
    # sum of probabilities of substring
    sum_of_substring_probabilities = sum(substring_probabilities)
    # sum of indicator random variables
    num_of_indicator_rv = len(substring_probabilities)
    expected_precision = sum_of_substring_probabilities / num_of_indicator_rv
    expected_recall = sum_of_substring_probabilities / sum_of_all_probabilities
    # calculating expected ef1 score
    if expected_precision + expected_recall != 0:
        ef1_score_for_substring = (2 * expected_precision * expected_recall) / (
                expected_precision + expected_recall)
    else:
        # handling of division by 0
        ef1_score_for_substring = 0

    return ef1_score_for_substring