def rescale(likelihood_array, fraction_of_limit):
    """
    Rescales the likelihood array if it gets too small/large, by multiplying it by a factor of 10.
    :param fraction_of_limit: int, to be rescaled the min (max) non-zero likelihood value should be
    smaller that MIN_VALUE / fraction_of_limit (larger than MAX_LIMIT / fraction_of_limit).
    :param likelihood_array: numpy array containing the likelihood to be rescaled
    :return: float, factor of 10 by which the likelihood array has been multiplies.
    """

    max_limit = MAX_VALUE / fraction_of_limit
    min_limit = MIN_VALUE / fraction_of_limit

    min_lh_value = np.log10(np.min(likelihood_array[np.nonzero(likelihood_array)]))
    max_lh_value = np.log10(np.max(likelihood_array[np.nonzero(likelihood_array)]))

    factors = 0
    if max_lh_value > max_limit:
        factors = max_limit - max_lh_value - 1
        likelihood_array *= np.power(10, factors)
    elif min_lh_value < min_limit:
        factors = min(-min_lh_value, max_limit - max_lh_value)
        likelihood_array *= np.power(10, factors)
    return factors
def rescale ( likelihood_array , fraction_of_limit ) : max_limit = MAX_VALUE / fraction_of_limit min_limit = MIN_VALUE / fraction_of_limit min_lh_value = np . log10 ( np . min ( likelihood_array [ np . nonzero ( likelihood_array ) ] ) ) max_lh_value = np . log10 ( np . max ( likelihood_array [ np . nonzero ( likelihood_array ) ] ) ) factors = 0 if max_lh_value > max_limit : factors = max_limit - max_lh_value - 1 likelihood_array *= np . power ( 10 , factors ) elif min_lh_value < min_limit : factors = min ( - min_lh_value , max_limit - max_lh_value ) likelihood_array *= np . power ( 10 , factors ) return factors
Rescales the likelihood array if it gets too small/large, by multiplying it by a factor of 10.
    :param fraction_of_limit: int, to be rescaled the min (max) non-zero likelihood value should be
    smaller that MIN_VALUE / fraction_of_limit (larger than MAX_LIMIT / fraction_of_limit).
    :param likelihood_array: numpy array containing the likelihood to be rescaled
    :return: float, factor of 10 by which the likelihood array has been multiplies.