## CSCview: Crossmatch Probability Calculation

The CSCview Crossmatch feature allows the user to enter a table of source positions and optionally, position errors, into the GUI and return the list of all CSC source positions which match the sources in the input list, determined by user search criteria and the crossmatch algorithm used by CSCview. The separation in arcseconds of each CSC source match from the corresponding source in the input list is returned, along with a measure of the probability that it is a true match. A probability value of 1.0 means that the CSC source returned for the corresponding source in the user-input list is an exact match (down to many significant digits in the source position), and a probability of 0.0 means it is very unlikely that it is a true match.

The crossmatch probabilities have different interpretations depending on whether or not the user has supplied position errors for their input sources. The probability formulae below describe the two different cases.

### Case 1: User provides source positions but not position errors

For each candidate matching a user-supplied source position and a catalog source position, the probability is computed as follows:

Compute the radial separation r (in arcseconds, because err_ellipse_r0 is in arcseconds) between the user-supplied source position and the catalog master source position (as for the current CSCview cone search).

Compute the sigma equivalent to the catalog master source position error:

```   catsigma = err_ellipse_r0 / (sqrt(2 * ln(20))
= 0.4085389826536349 * err_ellipse_r0
```

[If catalog release 1.0 position errors are used, then add in the absolute position uncertainty:

```   catsigma = sqrt(catsigma^2 + 0.16^2)
```

This step is NOT required for catalog release 1.1 positions.]

Compute the one-dimensional probability that the separation between the catalog position and the user supplied position is >= the radial separation r between the positions:

```   p_sep = erfc(r / (sqrt(2) * catsigma))
```

where erfc is the complementary error function [erfc(x) = 1 - erf(x)].

Note that r = 0 should give p_sep = 1 and r -> infinity should give p_sep -> 0.

### Case 2: User provides source positions and position errors

For each source position provided by the user, we assume they provide the corresponding 1-sigma radial Gaussian position error usersigma in arcsec.

For each candidate matching a user-supplied source position and a catalog source position, the probability is computed as follows:

Compute the radial separation r (in arcseconds, because err_ellipse_r0 is in arcseconds) between the user-supplied source position and the catalog master source position (as for the current CSCview cone search).

Compute the sigma equivalent to the catalog master source position error:

```   catsigma = err_ellipse_r0 / (sqrt(2 * ln(20))
= 0.4085389826536349 * err_ellipse_r0
```

[If catalog release 1.0 position errors are used, then add in the absolute position uncertainty:

```   catsigma = sqrt(catsigma^2 + 0.16^2)
```

This step is NOT required for catalog release 1.1 positions.]

Compute the joint probability that the catalog source position and the user source position match under the assumption of circularly symmetric Gaussian errors:

```   p_joint = (2 * catsigma * usersigma) / (catsigma2 + usersigma2)
* exp(-1/2 * (r2 / (catsigma2 + usersigma2)))
```
Note that r = 0 and catsigma = usersigma should give p_joint = 1 and r -> infinity should give p_sep -> 0.