Created
February 7, 2023 05:34
-
-
Save mmore500/fc4caba18a98b20fbda3fb223cf49552 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def _estimate_rank_of_mrca_between_unbiased( | |
first: HereditaryStratigraphicColumn, | |
second: HereditaryStratigraphicColumn, | |
) -> typing.Optional[float]: | |
ranks_of_retained_commonality_between = [ | |
*iter_ranks_of_retained_commonality_between_generic(first, second) | |
] | |
if not ranks_of_retained_commonality_between: | |
return None | |
rank_of_first_retained_disparity_between = ( | |
calc_rank_of_first_retained_disparity_between( | |
first, | |
second, | |
confidence_level=0.1, # TODO why can't this be set to 0.0? | |
) | |
) | |
waypoints_descending = [ | |
rank_of_first_retained_disparity_between - 1, | |
*reversed(ranks_of_retained_commonality_between), | |
] | |
exclusive_ub_correction = 1 / 2 | |
expected_ranks = ( | |
np.array( | |
[ | |
waypoints_descending[:-1], | |
waypoints_descending[1:], | |
] | |
).mean(axis=1) | |
- exclusive_ub_correction | |
) | |
base = 1 / 2 ** first.GetStratumDifferentiaBitWidth() | |
weights = np.logspace( | |
0, | |
len(expected_ranks), | |
base=base, | |
num=len(expected_ranks), | |
endpoint=False, | |
) | |
# index of weights corresponds to num spurious collisions | |
return np.average(expected_ranks, weights=weights) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment