Skip to content

Gaussian-Gaussian conjugate prior (#43) - #2073

Open
affeldt-aist wants to merge 4 commits into
math-comp:masterfrom
affeldt-aist:normal_20260803
Open

Gaussian-Gaussian conjugate prior (#43)#2073
affeldt-aist wants to merge 4 commits into
math-comp:masterfrom
affeldt-aist:normal_20260803

Conversation

@affeldt-aist

Copy link
Copy Markdown
Member
Motivation for this change
  • add Gaussian-Gaussian conjugate prior

Developed with the assistance of Claude Opus 4.8 and Fable 5 (1M context).

fyi: @gbdrt

Checklist
  • added corresponding entries in CHANGELOG_UNRELEASED.md
  • added corresponding documentation in the headers

Reference: How to document

Merge policy

As a rule of thumb:

  • PRs with several commits that make sense individually and that
    all compile are preferentially merged into master.
  • PRs with disorganized commits are very likely to be squash-rebased.
Reminder to reviewers

@affeldt-aist affeldt-aist added this to the 1.18.0 milestone Aug 3, 2026
@affeldt-aist affeldt-aist added the enhancement ✨ This issue/PR is about adding new features enhancing the library label Aug 3, 2026
gbdrt and others added 2 commits August 9, 2026 23:37
* add Gaussian-Gaussian conjugate prior

Developed with the assistance of Claude Opus 4.8 and Fable 5 (1M context).

---------

Co-authored-by: Reynald Affeldt <reynald.affeldt@aist.go.jp>

@affeldt-aist affeldt-aist left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I made a few final simplifications and I think that the code is ok but
the documentation can be improved. A few points:

What does "complete the square" (two occurrences) mean?

The comment before the lemma normal_pdf_conjugate is talking
about conditional probability but this does not appear
explicitly in the statement.

The comment before the lemma normal_prob_conjugate is talking
about theta but this is not a free variable in the conclusion.

The lemma normal_prob_conjugate is supposed to correspond to the first row of the table
https://en.wikipedia.org/wiki/Conjugate_prior#When_the_likelihood_function_is_a_continuous_distribution

This could be mentioned in the documentation and used to make the documentation more precise by using
similar vocabulary.

@gbdrt ?

@affeldt-aist

Copy link
Copy Markdown
Member Author

By the way, the documentation now looks like that:
Screenshot 2026-08-10 at 9 36 14

Screenshot 2026-08-10 at 9 37 03

@gbdrt

gbdrt commented Aug 10, 2026

Copy link
Copy Markdown

Thanks @affeldt-aist!

What does "complete the square" (two occurrences) mean?

It's just the basic manipulation: $a x^2 + b x + c = a (x - mu)^2 + Cst$ (required here to recover the new gaussian pdf). We can probably just drop it in the these comments.

The comment before the lemma normal_pdf_conjugate is talking about conditional probability but this does not appear explicitly in the statement.

Right. We should avoid the Bayesian presentation here. What about something more descriptive?

(**md $\mathcal{N}(t,s)(x)\mathcal{N}(m_0,s_0)(t) =
  \mathcal{N}\left(m_0,\sqrt{s_0^2+s^2}\right)(x)\mathcal{N}(\mu_1,\sigma_1)(t)$
 with $\mu_1$ = [post_mean m0 s0 x s] and $\sigma_1$ = [post_stddev s0 s]. 
*)

The comment before the lemma normal_prob_conjugate is talking about theta but this is not a free variable in the conclusion.

The lemma normal_prob_conjugate is supposed to correspond to the first row of the table https://en.wikipedia.org/wiki/Conjugate_prior#When_the_likelihood_function_is_a_continuous_distribution

This could be mentioned in the documentation and used to make the documentation more precise by using similar vocabulary.

Yes that would be much better. What about?

(**md Gaussian-Gaussian conjugate prior for a single observation $x$ (cf. first
 row of the table of
 [conjugate priors for continuous likelihoods](https://en.wikipedia.org/wiki/Conjugate_prior#When_the_likelihood_function_is_a_continuous_distribution)):
 the prior $\mathcal{N}(m_0,s_0)$ is conjugate to the likelihood
 $\mathcal{N}(\mu,s)$ with parameter $\mu$ (and known variance $s^2$), and the
 posterior hyperparameters are $\mu_1$ = `post_mean m0 s0 x s` and
 $\sigma_1$ = `post_stddev s0 s`; i.e.,
 $V \mapsto \int_{t \in V} \mathcal{N}(t,s)(x)d\mathcal{N}(m_0,s_0)$ normalized
 by its total mass is $\mathcal{N}(\mu_1,\sigma_1)$.
 *)

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

Labels

enhancement ✨ This issue/PR is about adding new features enhancing the library

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants