[ 
https://issues.apache.org/jira/browse/STATISTICS-92?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Kevin Milner updated STATISTICS-92:
-----------------------------------
    Labels: pull-request-available  (was: )

> TruncatedNormalDistribution rejection-sampler uses incorrect bounds for 
> mirroring check
> ---------------------------------------------------------------------------------------
>
>                 Key: STATISTICS-92
>                 URL: https://issues.apache.org/jira/browse/STATISTICS-92
>             Project: Commons Statistics
>          Issue Type: Bug
>          Components: distribution
>    Affects Versions: 1.0
>            Reporter: Kevin Milner
>            Priority: Major
>              Labels: pull-request-available
>
> The rejection sampler implementation of TruncatedNormalDistribution 
> incorrectly uses the original upper and lower bounds rather than the standard 
> normal bounds for the mirroring check; this leads to inaccurate sampling if 
> the original bounds are fully-positive or fully-negative, as well as infinite 
> loops if the bounds are positive but fully below the mean value or are 
> negative but fully above the mean value.
> For example, this will only return samples >1 (even though they should be in 
> the range [0.7, 1.3]:
> {code:java}
> ContinuousDistribution dist = TruncatedNormalDistribution.of(1, 0.1, 0.7, 
> 1.3).createSampler(RandomSource.XO_RO_SHI_RO_128_PP.create(123456l));{code}
> ...and this will get stuck in an infinite loop on the first sampling attempt:
> {code:java}
> ContinuousDistribution dist = TruncatedNormalDistribution.of(1, 0.1, 0.7, 
> 0.99).createSampler(RandomSource.XO_RO_SHI_RO_128_PP.create(123456l));{code}
> Similarly, this will only return samples <1:
> {code:java}
> ContinuousDistribution dist = TruncatedNormalDistribution.of(-1, 0.1, -1.3, 
> -0.7).createSampler(RandomSource.XO_RO_SHI_RO_128_PP.create(123456l));{code}
> ...and this will get stuck in an infinite loop on the first sampling attempt:
> {code:java}
> ContinuousDistribution dist = TruncatedNormalDistribution.of(-1, 0.1, -0.99, 
> -0.7).createSampler(RandomSource.XO_RO_SHI_RO_128_PP.create(123456l));{code}
> The bug seems to have been present since v1.0. It's a simple fix and I will 
> submit a PR imminently.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to