Skip to content

feature/triangle analysis closest#278

Merged
rhayes777 merged 10 commits into
mainfrom
feature/triangle_analysis_closest
Jun 17, 2024
Merged

feature/triangle analysis closest#278
rhayes777 merged 10 commits into
mainfrom
feature/triangle_analysis_closest

Conversation

@rhayes777
Copy link
Copy Markdown
Collaborator

  • 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

Copy link
Copy Markdown
Collaborator

@Jammy2211 Jammy2211 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Comment thread test_autolens/point/test_likelihood.py Outdated
redshift=0.5,
mass=al.mp.Isothermal,
)
source = af.Model(al.ps.PointSourceChi)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@Jammy2211
Copy link
Copy Markdown
Collaborator

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.

@rhayes777
Copy link
Copy Markdown
Collaborator Author

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?

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)

@rhayes777
Copy link
Copy Markdown
Collaborator Author

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.

By prioritising closer pairs we are likely to be getting what would be the highest likelihood solution if we tried all pairings.

@rhayes777 rhayes777 merged commit eacbcfb into main Jun 17, 2024
@Jammy2211
Copy link
Copy Markdown
Collaborator

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)

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 Solver object that customize the behaviour.

@rhayes777 rhayes777 deleted the feature/triangle_analysis_closest branch June 17, 2024 13:36
@rhayes777
Copy link
Copy Markdown
Collaborator Author

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)

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 Solver object that customize the behaviour.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants