feature/triangle analysis closest#278
Conversation
rhayes777
commented
Jun 17, 2024
- refactor to extract fixtures
- added test and fixed likelihood
- more testing
- more testing
- create test package
- implementation of closest-square-distance
- moved square likelihood function
- more testing
- docs
Jammy2211
left a comment
There was a problem hiding this comment.
For the paring likelihood, how is uniqueness handled, if at all?
In most circumstances, pairing each model image to its closest data point will give the highest likelihood solution. But there might be edge cases where this process produces a lower likelihood solution.
Do you have a uniqueness pairing criteria or can multiple model images go to one data point?
| redshift=0.5, | ||
| mass=al.mp.Isothermal, | ||
| ) | ||
| source = af.Model(al.ps.PointSourceChi) |
There was a problem hiding this comment.
The PointSourceChi object has a special use, which is described as follows:
This example above performs point-source fitting and modeling using what is often referred to as an "image-plane
chi-squared". This means that the multiple image positions predicted by the model are computed in the image-plane
and compared to the observed multiple image positions in the image-plane.
An alternative approach is to perform point-source modeling using a "source-plane chi-squared". This means that the
multiple image positions predicted by the model are computed and compared in the source-plane.
This is often regarded as a less robust way to perform point-source modeling, which has been shown to produce biased
and incorrect lens models. This is because a mass model may predict multiple images that are not observed in the
image-plane, which the source-plane chi-squared calculation fails to properly account for.
However, a source-plane chi-squared is much faster to compute than an image-plane chi-squared, as it does not require
triangles to be iteratively traced to the source-plane to find the multiple images. In certain science cases, it is
therefore useful, and therefore supported by **PyAutoLens**.
The advanced search chaining feature of PyAutoLens allows one initially fit a model quickly using a
source-plane chi-squared and then switch to an image-plane chi-squared for a robust final lens model.
Using a source-plane chi-squared requires us to simply change the point source model input into the source
galaxy to a `PointSourceChi` object
It is basically the object used for when point source tracings are compared in the source-plane and do not need the TriangleSolver.
It therefore should not be used for anything which tests image-plane point solving functionality.
The object which does this is just al.ps.Point, as the SourceChi is a special one-off use-case.
|
One option might be to evaluate all possible unique pairing combinations and take the maximum likelihood of those, I cant imagine that computationally this would have any meaningful slow down compared to the solving / ray tracing. |
Each model position matches with only one data position and vice-versa starting with the closest pair. If the model predicts an incorrect number of multiple image positions a FitException is raised (i.e. a very low likelihood is returned to the optimiser) |
By prioritising closer pairs we are likely to be getting what would be the highest likelihood solution if we tried all pairings. |
Ok, my point is that by "starting with closest pair" you might actually choose a series of pairing that are a lower likelihood than an alternative series of pairings. For example, you could imagine a strange scenario where if you paired the first model image with its second closest data point, the pairings of the remaining multiple images would span lower distances and thus be higher likelihood. As I've said before, there is no "right way" to do this. Its probably fine for now, and once the code is a bit more mature we can put some bools in the |
Yeah I can imagine those scenarios but I think there would still be a gradient towards the correct solution which would also have the highest likelihood. |