You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ah...@apache.org on 2020/06/24 12:59:17 UTC
[commons-statistics] 09/11: Add NakagamiDistribution testMoments.
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
commit af7ad85bcc9a480594bd89df569486f7ded8538a
Author: aherbert <ah...@apache.org>
AuthorDate: Wed Jun 24 13:32:29 2020 +0100
Add NakagamiDistribution testMoments.
---
.../distribution/NakagamiDistributionTest.java | 18 ++++++++++++++----
1 file changed, 14 insertions(+), 4 deletions(-)
diff --git a/commons-statistics-distribution/src/test/java/org/apache/commons/statistics/distribution/NakagamiDistributionTest.java b/commons-statistics-distribution/src/test/java/org/apache/commons/statistics/distribution/NakagamiDistributionTest.java
index 3ed68fd..9c450e2 100644
--- a/commons-statistics-distribution/src/test/java/org/apache/commons/statistics/distribution/NakagamiDistributionTest.java
+++ b/commons-statistics-distribution/src/test/java/org/apache/commons/statistics/distribution/NakagamiDistributionTest.java
@@ -17,7 +17,6 @@
package org.apache.commons.statistics.distribution;
import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
/**
@@ -75,10 +74,21 @@ public class NakagamiDistributionTest extends ContinuousDistributionAbstractTest
}
@Test
- @Disabled
public void testMoments() {
- // TODO.
- // Currently the mean and variance are only used when solving the inverse cumulative probability.
+ // Values obtained using Matlab, e.g.
+ // format long;
+ // pd = makedist('Nakagami','mu',0.5,'omega',1.0);
+ // disp([pd.mean, pd.var])
+ NakagamiDistribution dist;
+ final double eps = 1e-9;
+
+ dist = new NakagamiDistribution(0.5, 1.0);
+ Assertions.assertEquals(0.797884560802866, dist.getMean(), eps);
+ Assertions.assertEquals(0.363380227632418, dist.getVariance(), eps);
+
+ dist = new NakagamiDistribution(1.23, 2.5);
+ Assertions.assertEquals(1.431786259006201, dist.getMean(), eps);
+ Assertions.assertEquals(0.449988108521028, dist.getVariance(), eps);
}
@Test