def weight_by_order_type(phase_type, order):
    """ Calculate the new weight for the order using the perc of orders with this order type for the given phase
        as calculated in the dataset. (e.g. 20% of orders in a movement phase are H)
        :param phase_type: The current phase type ('M', 'R', 'A')
        :param order: The order to evaluate
        :return: The new weight for the order
    """
    probs = {'M': {'H': 0.19798, '-': 0.49738, 'S': 0.28929, 'C': 0.01535,
        'R': 0.0, 'B': 0.0, 'D': 0.0}, 'R': {'H': 0.9436, '-': 0.0, 'S': 
        0.0, 'C': 0.0, 'R': 0.03213, 'B': 0.0, 'D': 0.02427}, 'A': {'H': 
        0.8495, '-': 0.0, 'S': 0.0, 'C': 0.0, 'R': 0.0, 'B': 0.11252, 'D': 
        0.03798}}
    parts = order.split()
    if len(parts) < 3:
        return 1e-05
    order_type = parts[2]
    if phase_type in probs and order_type in probs[phase_type]:
        return probs[phase_type][order_type]
    return 1e-05
