[ 
https://issues.apache.org/jira/browse/RNG-146?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17369134#comment-17369134
 ] 

Alex Herbert commented on RNG-146:
----------------------------------

I am undecided about whether to even limit the constructor to accept standard 
deviations that would clip the distribution. This may set a precedent that we 
should think about restricting the parameters for other distribution samplers. 
Preventing non-finite input seems sensible. But preventing bad parameters 
because we think they are bad may not be everyone's choice. I will look through 
the other distribution samplers and check which of the distributions can be 
truncated by ill chosen parameters.

 

> 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)

Reply via email to