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

Alex Herbert commented on RNG-160:
----------------------------------

Added in commit:

b4929c899ea1f60d6bc7d61cfeeb7f589174e31a
 
Tested on JDK 11.0.11.

Before:
{noformat}
Benchmark                                     (randomSourceName)  (size)        
       (type)  Mode  Cnt    Score    Error  Units
ZigguratSamplerPerformance.sequentialSample  XO_RO_SHI_RO_128_PP       3        
  ModGaussian  avgt    5   16.238 ±  0.028  ns/op
ZigguratSamplerPerformance.sequentialSample  XO_RO_SHI_RO_128_PP       3        
 ModGaussian2  avgt    5   16.257 ±  0.053  ns/op
ZigguratSamplerPerformance.sequentialSample  XO_RO_SHI_RO_128_PP       3  
ModGaussianInlining  avgt    5   14.160 ±  0.031  ns/op
ZigguratSamplerPerformance.sequentialSample  XO_RO_SHI_RO_128_PP     128        
  ModGaussian  avgt    5  638.158 ±  2.507  ns/op
ZigguratSamplerPerformance.sequentialSample  XO_RO_SHI_RO_128_PP     128        
 ModGaussian2  avgt    5  636.690 ± 37.049  ns/op
ZigguratSamplerPerformance.sequentialSample  XO_RO_SHI_RO_128_PP     128  
ModGaussianInlining  avgt    5  464.307 ±  7.701  ns/op
{noformat}

After:

{noformat}
Benchmark                                     (randomSourceName)  (size)        
       (type)  Mode  Cnt    Score   Error  Units
ZigguratSamplerPerformance.sequentialSample  XO_RO_SHI_RO_128_PP       3        
  ModGaussian  avgt    5   14.241 ± 0.018  ns/op
ZigguratSamplerPerformance.sequentialSample  XO_RO_SHI_RO_128_PP       3        
 ModGaussian2  avgt    5   16.630 ± 0.036  ns/op
ZigguratSamplerPerformance.sequentialSample  XO_RO_SHI_RO_128_PP       3  
ModGaussianInlining  avgt    5   14.143 ± 0.042  ns/op
ZigguratSamplerPerformance.sequentialSample  XO_RO_SHI_RO_128_PP     128        
  ModGaussian  avgt    5  421.969 ± 3.697  ns/op
ZigguratSamplerPerformance.sequentialSample  XO_RO_SHI_RO_128_PP     128        
 ModGaussian2  avgt    5  640.591 ± 0.342  ns/op
ZigguratSamplerPerformance.sequentialSample  XO_RO_SHI_RO_128_PP     128  
ModGaussianInlining  avgt    5  463.447 ± 1.106  ns/op
{noformat}


> Performance of modified Ziggurat samplers
> -----------------------------------------
>
>                 Key: RNG-160
>                 URL: https://issues.apache.org/jira/browse/RNG-160
>             Project: Commons RNG
>          Issue Type: Improvement
>          Components: sampling
>    Affects Versions: 1.4
>            Reporter: Alex Herbert
>            Priority: Minor
>             Fix For: 1.4
>
>         Attachments: Exp.jpg, Gaussian.jpg
>
>
> The modified ziggurat algorithm implemented in RNG-151 has a variation for 
> sampling from the overhang regions at the ziggurat edges, region A below:
> {noformat}
>             \
>   ----------+\
>             | \
>      B      |A \
>   -------------+\
>                | \
> {noformat}
> Note: Region B is the ziggurat layer which is entirely within the 
> distribution PDF.
> These overhangs can be convex, concave or an inflection (change from convex 
> to concave). Samples from the region A must be below the distribution density 
> curve (PDF). When sampling from region A, the sampler will create a random 
> point (x,y) uniformly within the rectangle. This is tested to determine if it 
> is below the curve. Convex and concave curves can use a fast method that 
> knows the largest possible triangle that fits above or below the curve. If a 
> sampled point (x,y) is within these triangles then the actual curve position 
> (pdf( x)) for the point x does not need to be computed. This can save time if 
> the pdf is computationally expensive. In the case of exponential (exp(-x)) or 
> Gaussian (exp(-0.5 * x * x)) this involves a call to Math.exp.
> The current sampler implements the fast look-up method. The alternative is to 
> always compute pdf( x) and determine if y is below the curve. This is known 
> as 'simple overhangs'.
> Investigate the use of simple overhangs on the performance of the sampler.
> Note: The Marsaglia version of the ziggurat sampler uses the 'simple 
> overhangs' method.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to