Skip to content
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

Refactor package #36

Merged
merged 22 commits into from
Nov 22, 2021
Merged

Refactor package #36

merged 22 commits into from
Nov 22, 2021

Conversation

lmh91
Copy link
Collaborator

@lmh91 lmh91 commented May 20, 2021

I am currently refactoring the package.

The main difference is that model functions now have their own struct similar to
distributions, e.g. Normal, from the Distributions.jl package.

Currently, there is one predefined model function, NormalPeakUvD, which is a Gaussian plus linear background model.
But the user can of course also define his own models, see Doc.

Also, the fit syntax has changed. It is now like the fit function from StatsBase.jl and Distributions.jl:
fit(<::Type{Dist}>, data)::<Dist> where in our case the data are StatsBase.Histograms:
e.g.: fit(NormalPeakUvD, hist) which would return an instance of NormalPeakUvD with the fitted parameters.

Two fit "backends" are implemented:

  • Maximum LikeLiHood Estimation (MLE) via Optim.jl
  • Bayesian Fit via BAT.jl (optional via Require.jl)

They can be chosen via a keyword: backend = :optim (default) or backend = :BAT.

Both methods use the gradient of the model functions via AutoDiff.
User specific model functions need to be defined such that ForwardDiff.jl can differentiate them.
Currently, there is not yet a fallback to a non-gradient based optimizer / sampling algorithm.
But this can be easily added.

Also, NamedTuples can be used for the parameters of a model.
And the parameters can be individual set constant via ValueShapes.jl
such that they are fixed in the fits but the model does not have to be redefined.

@lmh91
Copy link
Collaborator Author

lmh91 commented May 25, 2021

A preview of the docs can be found under
https://juliaphysics.github.io/RadiationSpectra.jl/previews/PR36/

@lmh91 lmh91 force-pushed the refactor branch 3 times, most recently from 6e7133f to 473565e Compare May 25, 2021 17:45
@lmh91 lmh91 marked this pull request as ready for review November 3, 2021 07:22
@lmh91 lmh91 requested a review from oschulz November 19, 2021 17:19
@lmh91 lmh91 merged commit 466dd0d into master Nov 22, 2021
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.

None yet

1 participant