Merged
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR implements the M-step of the EM algorithm using the method of moments for Weibull, Exponential, and Gaussian distributions, providing an alternative to maximum likelihood estimation.
- Implementation of
MomentsMStepclass for parameter estimation using sample moments - Addition of
calc_moments_paramsmethods to distribution models (Weibull, Gaussian, Exponential) - Comprehensive test suite covering single distributions, same distribution mixtures, and mixed distribution scenarios
Reviewed Changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
mpest/em/methods/moments_method.py |
Core implementation of moments-based M-step algorithm |
mpest/models/weibull.py |
Addition of moments-based parameter calculation for Weibull distribution |
mpest/models/gaussian.py |
Addition of moments-based parameter calculation for Gaussian distribution |
mpest/models/exponential.py |
Addition of moments-based parameter calculation for Exponential distribution |
tests/tests_moments/moments_utils.py |
Utility functions for moments method testing |
tests/tests_moments/test_*.py |
Comprehensive test suite for moments method validation |
examples/*.py |
Minor import ordering adjustments for consistency |
Comments suppressed due to low confidence (3)
tests/tests_moments/test_two_same_distributions_complex.py:103
- Function name
test_two_same_distributions_simpleis misleading as this test handles complex scenarios with custom prior probabilities, not simple ones.
def test_two_same_distributions_simple(
tests/tests_moments/test_any_distributions_simple.py:67
- Function name
testis too generic and doesn't describe what the test is actually testing. It should be renamed to something more descriptive liketest_any_distributions_simple.
def test(
tests/tests_moments/test_any_distributions_complex.py:78
- Function name
testis too generic and doesn't describe what the test is actually testing. It should be renamed to something more descriptive liketest_any_distributions_complex.
def test(
iraedeus
requested changes
Jul 26, 2025
Collaborator
iraedeus
left a comment
There was a problem hiding this comment.
Critical error in tests, you have tested LMoments method, not Moments method.
iraedeus
requested changes
Jul 26, 2025
added 2 commits
July 27, 2025 14:11
iraedeus
approved these changes
Jul 27, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implementation of the M step of the EM algorithm using the method of moments for Weibull, Exponential and Gaussian distributions