Skip to content

negative cross mate correlations break here #18

@sashagusev

Description

@sashagusev

When the cross-mate correlation is set to be negative, this line breaks and produces no realized correlation. A simple fix is to correct for the correlation sign:

signal_scale = np.sqrt(abs(R))
noise_scale = np.sqrt(max(0.0, 1 - abs(R)))
sign = 1.0 if R >= 0 else -1.0

mating_score1 = sum_scaled_mate1 * signal_scale + noise_scale * np.random.normal(0, np.std(sum_scaled_mate1), n)
mating_score2 = sign * sum_scaled_mate2 * signal_scale + noise_scale * np.random.normal(0, np.std(sum_scaled_mate2), n)

xftsim/xftsim/mate.py

Lines 872 to 873 in 00080b3

mating_score1 = sum_scaled_mate1 * np.sqrt(R) + np.sqrt(np.abs(1-R))*np.random.normal(0,np.std(sum_scaled_mate1),n)#sum_scaled_mate1.shape[0])
mating_score2 = sum_scaled_mate2 * np.sqrt(R) + np.sqrt(np.abs(1-R))*np.random.normal(0,np.std(sum_scaled_mate2),n)#sum_scaled_mate2.shape[0])

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions