Skip to content

Posterior module API#105

Merged
hmd101 merged 3 commits intoflatironinstitute:mainfrom
hmd101:api
Mar 12, 2026
Merged

Posterior module API#105
hmd101 merged 3 commits intoflatironinstitute:mainfrom
hmd101:api

Conversation

@hmd101
Copy link
Collaborator

@hmd101 hmd101 commented Mar 12, 2026

Separation of concerns: ParameterPosterior vs PredictivePosterior:

  • ParameterPosterior: Its only job is to safely encapsulate the result of an inference engine (a point estimate for MAP, or eventually an array of samples for MCMC). Think of it as a data container.

  • PredictivePosterior: takes data contained in ParameterPosterior and does the 'math' to e.g.,  predict_thresholds once, rather than re-implementing it inside MAPPosterior, LangevinPosterior, etc.

Replacing class inheritance with interfaces (Protocols):

  • If an object has .params, .model, and .sample(), it is a ParameterPosterior.
  • example: the user calls optimizer.fit(model, data). They don't need to know or care that they are getting a MAPPosterior. They just know the factory handed them back an object that fully satisfies the ParameterPosterior protocol. This makes the frontend API identical whether you're using MAP or MCMC.

Related to #87 and shelving #87 for now as the current API separating Model (prior and likelihood) from Posterior is in line with other established Bayesian libraries.

@hmd101 hmd101 merged commit be1ab95 into flatironinstitute:main Mar 12, 2026
0 of 3 checks passed
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.

1 participant