From 4708bf41b0ceab7c21ab36dd0a94f62b73bce355 Mon Sep 17 00:00:00 2001 From: Jon Shimwell Date: Fri, 21 Nov 2025 11:49:14 +0100 Subject: [PATCH 1/2] added uniform integral --- openmc/stats/univariate.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/openmc/stats/univariate.py b/openmc/stats/univariate.py index c48cc00757c..61095370dc6 100644 --- a/openmc/stats/univariate.py +++ b/openmc/stats/univariate.py @@ -439,6 +439,18 @@ def mean(self) -> float: """ return 0.5 * (self.a + self.b) + def integral(self) -> float: + """Return integral of the uniform distribution + + .. versionadded:: 0.15.3 + + Returns + ------- + float + Integral of uniform distribution (width of interval) + """ + return self.b - self.a + def to_xml_element(self, element_name: str): """Return XML representation of the uniform distribution From e61396e1e4478b54e08459a23bf47a8c58c92366 Mon Sep 17 00:00:00 2001 From: shimwell Date: Fri, 21 Nov 2025 12:02:48 +0100 Subject: [PATCH 2/2] doc string improved --- openmc/stats/univariate.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openmc/stats/univariate.py b/openmc/stats/univariate.py index 61095370dc6..4960cf69231 100644 --- a/openmc/stats/univariate.py +++ b/openmc/stats/univariate.py @@ -447,7 +447,7 @@ def integral(self) -> float: Returns ------- float - Integral of uniform distribution (width of interval) + Integral of uniform distribution """ return self.b - self.a @@ -1175,7 +1175,7 @@ def integral(self): Returns ------- float - Integral of tabular distrbution + Integral of tabular distribution """ if self.interpolation == 'histogram': return np.sum(np.diff(self.x) * self.p[:self.x.size-1])