ZEMAX Users' Knowledge Base - http://www.zemax.com/kb
Understanding Sobol Sampling
http://www.zemax.com/kb/articles/66/1/Understanding-Sobol-Sampling/Page1.html
By Mark Nicholson
Published on 10 November 2005
 
This article explains
  • What Sobol sampling is,
  • What its benefits are over random ray-generation methods
  • What its limitations are

This article is also available in Japanese.


Random and Sobol Sampling Schemes

This article is also available in Japanese.

A source object generates rays with some spatial and angular probability. For example, a Source Point generates rays with exactly the same starting coordinates, but with ray direction cosines uniformly chosen over some allowable range. When we trace rays from this source, we must trace "enough" rays to accurately sample the source.

The probability function for a source is usually sampled with a random number generator. The goal of a random number generator is to produce a series of numbers which have no correlation with each other. Then by tracing lots of rays (generating lots of random numbers) we can accurately sample the source probability function.

{All computer-based random-number generation algorithms are "quasi-random" in thay they are limited (ultimately by the number of bits of the operating system, but generally by algorithm assumptions) to have a period over which the random number sequence repeats. Hence no implemented random number generator is "truly" random. In this article, I refer to ZEMAX' long-period random number generator as "truly" random to distinguish it from the Sobol algorithm.} 

Sobol sampling takes a different approach. Rather than generating random numbers, it generates a uniform distribution in probability space. This is not just a simple grid, but a distribution which appears qualitatively random, but cleverly "fills in" previously unsampled regions of the probability function.

The zip file attached (which can be downloaded from the last page of this article) shows a simple optical system. Two rectangular sources illuminate a detector. These source objects are designed to produce a uniform, rectangular distribution of rays. The bottom one uses ZEMAX' "true" random number generator, whilst the top one uses a Sobol sampling scheme.

Two sources, one Sobol, one random

If we trace just 10,000 rays per source, it is hard to see the difference between the sampling schemes:

10000 rays per source

Tracing 100,000 rays shows the differences more clearly

100k rays

The Sobol sampling scheme produces a more uniform, though still qualitatively random distribution than the truly random distribution. This shows a more "clumpy" distribution, with hot spots and darker  regions. Zooming in on a region in the random-sampled source distribution shows:

A zoomer region of the randomly illuminated region

The red pixel above indicates where three rays landed in the same pixel, and there are also regions where no rays landed. Hence this region is noisier than the Sobol-illuminated region.


Signal to Noise Ratio
Here is the result of tracing 1,000,000 rays per source:

1 million rays per source

10,000,000 rays:

10 million rays

100,000,000 (one hundred million) rays per source:

100 million rays per source

and 1,000,000,000 rays (one billion rays!) per source

One billion rays per source!

When there are very few rays (10,000) and many many rays (1 billion) the results of the random ray-trace and Sobol ray-trace are similar. Hence Sobol sampling is most useful in a "sweet-spot" region. The signal to noise ratio (SNR) of the random ray-trace is SQRT(N) where N is the average number of rays hitting a pixel. For the Sobol sampling scheme, the SNR goes linearly as N (see reference 1). This can be seen by taking a cross-section through the distribution with 1 billion rays per source:

The SNR can be seen

Note however that Sobol sampling is not a "magic bullet". In this case, we know that the source irradiance is intended to be uniform. Our prior knowledge of the intended distribution allows us to claim that Sobol sampling is "better" in this case. However, in any Monte-Carlo simulation, there is ultimately no more accurate method that making many samples with a truly random number generator. For this reason, ZEMAX allows you to select either a Sobol sampling scheme, or to use ZEMAX's long-period random number generator, in the source tab of the object properties:

Choosing the sampling scheme


Summary and References
Summary

Sobol sampling can made a significant reduction in the time taken to undertake a Monte Carlo ray-tracing simulation, and will generally produce faster convergence than truly random rays.

External References

1. Press, Flannery, Teukolsky, and Vetterling, Numerical Recipes, Cambridge Press.