Skip to content

Conversation

MatthewQuenneville
Copy link
Contributor

The formula for the variance is incorrect in the docstring of the NormalMixture distribution. The correct expression can be found on the Wikipedia page for a Mixture Distribution, or it follows from the moment expressions in section A.2.2 of The Matrix Cookbook.

The two expressions are not equivalent, as can be verified by checking the case of a mixture of two normal distributions with equal weights, means, and variances. The resulting mixture distribution should be identical to the two individual components, but the expression would give half the variance of the components as written.

...

Checklist

Major / Breaking Changes

  • ...

Bugfixes / New features

  • ...

Docs / Maintenance

  • Fix the incorrect variance formula in the NormalMixture distribution docstring

@codecov
Copy link

codecov bot commented Aug 27, 2022

Codecov Report

Merging #6073 (ae3439e) into main (a90c420) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #6073   +/-   ##
=======================================
  Coverage   89.52%   89.52%           
=======================================
  Files          72       72           
  Lines       12950    12950           
=======================================
  Hits        11593    11593           
  Misses       1357     1357           
Impacted Files Coverage Δ
pymc/distributions/mixture.py 95.72% <ø> (ø)

@maresb
Copy link
Contributor

maresb commented Sep 10, 2022

I'm not an official reviewer, I can confirm that the math checks out. Nice catch!

Copy link
Member

@michaelosthege michaelosthege left a comment

Choose a reason for hiding this comment

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

@maresb confirmed that this is correct.

Thanks for the PR !

@michaelosthege michaelosthege merged commit 9b9826c into pymc-devs:main Sep 10, 2022
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