Skip to content

Adding quartic prior #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open

Adding quartic prior #8

wants to merge 8 commits into from

Conversation

lianctrl
Copy link

@lianctrl lianctrl commented Mar 6, 2025

PR Checklist

  • [] Bug fix
  • Feature addition/change
  • [] Documentation addition/change
  • [] Test addition/change
  • [] Black formatting

Describe your changes here:

Added a quartic prior, particularly useful to deal with CA angles resolution

@nec4
Copy link
Collaborator

nec4 commented Mar 6, 2025

Nice! - will take a look tonight

Edit: I will let others take a look first.

Copy link
Collaborator

@sayeg84 sayeg84 left a comment

Choose a reason for hiding this comment

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

Thanks a lot for the PR. I have a problem with the functional form that this prior has, I think it has redundant parameters for a polynomial which can induce inestabilities in the fit.

If people have already worked with a functional form like this and it works most of the time then maybe we could merge it but I would be against it.

It would also be interesting to hear the opinion of @jacopoventurin who I think has worked with similar functional forms before.

mlcg/nn/prior.py Outdated
@staticmethod
def _quartic_model(x, a, b, c, d, xa, xb, xc):
return a * (x - xa) ** 2 + b * (x - xb) ** 3 + c * (x - xc) ** 4 + d

Copy link
Collaborator

Choose a reason for hiding this comment

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

A deg 4 polynomial p(x) is uniquely caracterized by 5 numbers: a_0, .. a_4 such that p(x) = sum_{k=0}^4 a_k * x^k. Your degree 4 polynomial uses 7 parameters in order to keep this shape of p(x) = sum_{k=2}^4 b_k *(x_0^{(k)} x)^k. Isn't the fit then ill posed?

At some point I tried to use an expression similar to what you have now and found it problematic because of this redundancy of parameters.

mlcg/nn/prior.py Outdated
dG_nz: torch.Tensor,
**kwargs,
):
"""
Copy link
Collaborator

Choose a reason for hiding this comment

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

You need to make a PR also to mlcg-tk because we need to call also the fitting function from there.

@sayeg84
Copy link
Collaborator

sayeg84 commented Apr 1, 2025

So, after some changes and some IRL discussion, we agreed that, even though mathematically ill posed, your functional form was fittable by the use of bound. However, we saw that the same results could be achieved using also a polynomial function properly bounded and we agreed on moving forward with a simpler polynomial.

In my most recent push I replaced the Quartic class with the Polynomial and QuarticAngles class, which implement the mentioned polynomial. PLease feel free to test them.

I've also opened a PR in mlcg-tk to also support this prior so that you can train a model from scratch and fully test the performance.

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.

3 participants