def compute_miller_set_correlation(
    ms_a, ms_b, map_to_asu=False, merge_equivalents=False
):
    """Compute correlation between two miller arrays.

    Args:
      ms_a (cctbx.miller.array): Input miller.array `a`.
      ms_b (cctbx.miller.array): Input miller.array `b`.
      map_to_asu (bool): If ``True``, then map miller indices to the asymmetric
        unit before matching miller indices between input miller arrays.
      merge_equivalents (bool): If ``True`` then merge symmetry equivalent
        reflections before matching miller indices between input miller arrays.

    Returns:
      tuple[int, float]: A tuple of the number of observations and the correlation
      coefficient.
    """
    if map_to_asu:
        # not obvious that this will help for the reasons stated below
        ms_a = ms_a.map_to_asu()
        ms_b = ms_b.map_to_asu()

    if merge_equivalents:
        # only want to do this if we have essentially "scaled" the data - if not
        # then we will get a smooth Wilson plot and about CC=1 (due to general
        # fall off with resolution)
        ms_a = ms_a.merge_equivalents().array()
        ms_b = ms_b.merge_equivalents().array()

    common_a, common_b = ms_a.common_sets(ms_b)

    return common_a.size(), common_a.correlation(common_b).coefficient()