This is an automated email from the ASF dual-hosted git repository.

aherbert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-statistics.git


The following commit(s) were added to refs/heads/master by this push:
     new 229def85 STATISTICS-93: Add methods to expose construction parameters
229def85 is described below

commit 229def859a92ca3f49780cdb51b2a39e31e9f97d
Author: Alex Herbert <[email protected]>
AuthorDate: Mon Mar 16 21:25:40 2026 +0000

    STATISTICS-93: Add methods to expose construction parameters
    
    Adds methods to TruncatedNormalDistribution to allow reconstruction of
    the distribution.
---
 .../distribution/TruncatedNormalDistribution.java  | 27 ++++++++++++++++++++++
 .../TruncatedNormalDistributionTest.java           |  3 +--
 src/changes/changes.xml                            |  4 ++++
 3 files changed, 32 insertions(+), 2 deletions(-)

diff --git 
a/commons-statistics-distribution/src/main/java/org/apache/commons/statistics/distribution/TruncatedNormalDistribution.java
 
b/commons-statistics-distribution/src/main/java/org/apache/commons/statistics/distribution/TruncatedNormalDistribution.java
index 92656007..2e52689f 100644
--- 
a/commons-statistics-distribution/src/main/java/org/apache/commons/statistics/distribution/TruncatedNormalDistribution.java
+++ 
b/commons-statistics-distribution/src/main/java/org/apache/commons/statistics/distribution/TruncatedNormalDistribution.java
@@ -152,6 +152,33 @@ public final class TruncatedNormalDistribution extends 
AbstractContinuousDistrib
         return new TruncatedNormalDistribution(parent, z, lower, upper);
     }
 
+    /**
+     * Gets the mean for the parent distribution.
+     *
+     * <p>Note that the mean is of the parent normal distribution,
+     * and not the true mean of the truncated normal distribution.
+     * This is the {@code mean} parameter used to construct the truncated 
distribution.
+     *
+     * @return the parent mean.
+     * @see #getMean
+     */
+    public double getParentMean() {
+        return parentNormal.getMean();
+    }
+
+    /**
+     * Gets the standard deviation for the parent distribution.
+     *
+     * <p>Note that the standard deviation (SD) is of the parent normal 
distribution,
+     * and not the true standard deviation of the truncated normal 
distribution.
+     * This is the {@code sd} parameter used to construct the truncated 
distribution.
+     *
+     * @return the parent standard deviation.
+     */
+    public double getParentStandardDeviation() {
+        return parentNormal.getStandardDeviation();
+    }
+
     /** {@inheritDoc} */
     @Override
     public double density(double x) {
diff --git 
a/commons-statistics-distribution/src/test/java/org/apache/commons/statistics/distribution/TruncatedNormalDistributionTest.java
 
b/commons-statistics-distribution/src/test/java/org/apache/commons/statistics/distribution/TruncatedNormalDistributionTest.java
index 7924b35e..7cb36e04 100644
--- 
a/commons-statistics-distribution/src/test/java/org/apache/commons/statistics/distribution/TruncatedNormalDistributionTest.java
+++ 
b/commons-statistics-distribution/src/test/java/org/apache/commons/statistics/distribution/TruncatedNormalDistributionTest.java
@@ -55,8 +55,7 @@ class TruncatedNormalDistributionTest extends 
BaseContinuousDistributionTest {
     @Override
     String[] getParameterNames() {
         // Input mean and standard deviation refer to the underlying normal 
distribution.
-        // The constructor arguments do not match the mean and SD of the 
truncated distribution.
-        return new String[] {null, null, "SupportLowerBound", 
"SupportUpperBound"};
+        return new String[] {"ParentMean", "ParentStandardDeviation", 
"SupportLowerBound", "SupportUpperBound"};
     }
 
     @Override
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 37cd3256..8cd34d11 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -53,6 +53,10 @@ If the output is not quite correct, check for invisible 
trailing spaces!
   </properties>
   <body>
     <release version="1.3" date="TBD" description="Adds new features (requires 
Java 8).">
+      <action dev="aherbert" type="update" issue="STATISTICS-93">
+        "TruncatedNormalDistribution": Add methods to expose construction
+        parameters.
+      </action>
       <action dev="aherbert" due-to="kevinmilner" type="fix" 
issue="STATISTICS-92">
         "TruncatedNormalDistribution": Fix the cases where the sampler would:
         (1) generate a biased distribution if the truncated bounds are 
fully-positive

Reply via email to