[
https://issues.apache.org/jira/browse/RNG-146?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17377989#comment-17377989
]
Alex Herbert commented on RNG-146:
----------------------------------
Added detection of infinite and NaN values for both the mean and standard
deviation. I have added javadoc to indicate the use of finite values for the
mean and standard deviation will avoid NaN (e.g. by avoiding inf * 0 and inf -
inf). The javadoc states that detection of a truncated distribution is not
performed.
Commit:
6edeb102c5310895480781e14c14facaf12ed864
> GaussianSampler should not allow infinite standard deviation
> ------------------------------------------------------------
>
> Key: RNG-146
> URL: https://issues.apache.org/jira/browse/RNG-146
> Project: Commons RNG
> Issue Type: Bug
> Components: sampling
> Affects Versions: 1.3
> Reporter: Alex Herbert
> Priority: Trivial
>
> The GaussianSampler requires the standard deviation is strictly positive. It
> allows an infinite value. This will produce a NaN output if the
> NormalizedGaussianSampler returns 0:
> {code:java}
> @Test
> public void testInfiniteStdDev() {
> NormalizedGaussianSampler gauss = new NormalizedGaussianSampler() {
> @Override
> public double sample() {
> return 0;
> }
> };
> GaussianSampler s = new GaussianSampler(gauss, 0,
> Double.POSITIVE_INFINITY);
> Assert.assertEquals(Double.NaN, s.sample(), 0.0);
> }
> {code}
> A fix is to require the standard deviation is finite.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)