Closed weibullguy closed 1 month ago
This pull request refactors the statistical functions across multiple distribution types (normal, exponential, lognormal, and Weibull) to improve maintainability, abstraction, and testing. The key changes include centralizing common statistical calculations, refining distribution-specific methods, and enhancing unit test coverage.
classDiagram
class Distributions {
+calculate_hazard_rate(time: float, location: float, scale: Optional[float], shape: Optional[float], dist_type: str) float
+calculate_mtbf(shape: float, location: float, scale: float, dist_type: str) float
+calculate_survival(shape: float, time: float, location: float, scale: float, dist_type: str) float
}
class Normal {
+get_hazard_rate(location: float, scale: float, time: float) float
+get_mtbf(location: float, scale: float) float
+get_survival(location: float, scale: float, time: float) float
+do_fit(data, kwargs) Tuple[float, float]
}
class Exponential {
+get_hazard_rate(scale: float, location: float) float
+get_mtbf(rate: float, location: float) float
+get_survival(scale: float, time: float, location: float) float
+do_fit(data, kwargs) Tuple[float, float]
}
class Lognormal {
+get_hazard_rate(shape: float, location: float, scale: float, time: float) float
+get_mtbf(shape: float, location: float, scale: float) float
+get_survival(shape: float, location: float, scale: float, time: float) float
+do_fit(data, kwargs) Tuple[float, float, float]
}
class Weibull {
+get_hazard_rate(shape: float, location: float, scale: float, time: float) float
+get_mtbf(shape: float, location: float, scale: float) float
+get_survival(shape: float, location: float, scale: float, time: float) float
+do_fit(data, kwargs) Tuple[float, float, float]
}
Distributions <|-- Normal
Distributions <|-- Exponential
Distributions <|-- Lognormal
Distributions <|-- Weibull
Change | Details | Files |
---|---|---|
Centralized common statistical calculations into a new distributions.py file |
|
src/ramstk/analyses/statistics/distributions.py |
Refactored distribution-specific files to use the new centralized functions |
|
src/ramstk/analyses/statistics/exponential.py src/ramstk/analyses/statistics/lognormal.py src/ramstk/analyses/statistics/normal.py src/ramstk/analyses/statistics/weibull.py |
Enhanced unit tests for all distribution types |
|
tests/analyses/statistics/bounds_unit_test.py tests/analyses/statistics/exponential_unit_test.py tests/analyses/statistics/lognormal_unit_test.py tests/analyses/statistics/normal_unit_test.py tests/analyses/statistics/weibull_unit_test.py tests/analyses/statistics/distributions_unit_test.py |
Improved code style and documentation |
|
src/ramstk/analyses/statistics/bounds.py src/ramstk/analyses/statistics/exponential.py src/ramstk/analyses/statistics/lognormal.py src/ramstk/analyses/statistics/normal.py src/ramstk/analyses/statistics/weibull.py |
Does this pull request introduce a breaking change?
Purpose of this pull request
This pull request refactors the statistical functions across multiple distribution types (normal, exponential, lognormal, and Weibull) to improve maintainability, abstraction, and testing. The key goals include:
Benefits of the pull request
Any particular area(s) reviewers should focus on
Any other pertinent information
Pull Request Checklist
Code Style
Static Checks
Tests
Chores
Summary by Sourcery
Refactor statistical functions to centralize shared logic for hazard rate, MTBF, and survival calculations, improving maintainability and consistency across distribution types. Enhance unit test coverage by adding new test cases for edge conditions to ensure robustness.
Enhancements:
Tests: