You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Alex Herbert (Jira)" <ji...@apache.org> on 2022/09/26 22:47:00 UTC

[jira] [Created] (STATISTICS-55) TruncatedNormalDistribution sampler

Alex Herbert created STATISTICS-55:
--------------------------------------

             Summary: TruncatedNormalDistribution sampler
                 Key: STATISTICS-55
                 URL: https://issues.apache.org/jira/browse/STATISTICS-55
             Project: Commons Statistics
          Issue Type: New Feature
          Components: distribution
    Affects Versions: 1.0
            Reporter: Alex Herbert
             Fix For: 1.0


The TruncatedNormalDistribution currently uses inverse CDF sampling.

Sampling is also possible using a normalised Gaussian sampler to create samples and then rejecting those outside the range of the truncation. 

In the use case where the truncated normal distribution covers over 50% of the standard normal distribution, then rejection sampling will need less than 2 samples per value. This is efficiently sampled by generating fast Gaussian deviates and throwing away the few that are not in the supported bounds.

The speed of each method will be approximately equal when:
{noformat}
t1 * n = t2{noformat}
Where:
 * t1 is the speed of the normal distribution sampler;
 * n number of samples required to generate a value within the truncated range;
 * t2 is the speed of the inverse transform sampler.

Rearranging provides a switching threshold to change to rejection sampling:
{noformat}
t1 / t2 <= 1 / n{noformat}
Where {{1 / n}} is the fraction of the CDF covered by the truncated normal distribution. The threshold requires evaluation of t1 and t2.

The relative speed of sampling using Gaussian deviates and inverse CDF sampling should be investigated with the intention to use rejection sampling for certain truncated distributions.



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