<p>Monte Carlo methods rely on the <strong><a href="https://en.wikipedia.org/wiki/Law_of_large_numbers">law of large numbers</a></strong>, which states that the average of a random event repeated a large number of times converges toward the expected value (if you flip a coin a gazillion times, on average you will obtain each side half the time). <strong><a href="https://en.wikipedia.org/wiki/Monte_Carlo_integration">Monte Carlo integration</a></strong> uses that law to evaluate an integral by averaging a large number of random samples.</p>

<p>Using a uniform distribution would break the algorithm because the law it is based upon wouldn't apply anymore.</p>

CC BY-SA 3.0
2016-08-19T13:10:24.670Z
Yes but mostly it can be summed as this for a unknown problem, ramdom is the best strategy. since contribution  is unknown...
joojaa
CC BY-SA 3.0
2016-08-19T14:34:15.447Z
@joojaa: oh, I realize you and I have read the question differently. Yes, Monte Carlo is a strategy that works when the analytical solution is unknown (although a math person would probably have a much more precise way of putting it).
Julien Guertault
CC BY-SA 3.0
2016-08-19T14:35:59.760Z
Said differently: even if the solution is unknown, Monte Carlo is proven to converge toward it.
Julien Guertault
CC BY-SA 3.0
2016-08-19T11:33:54.710Z
2016-08-19T11:40:21.620Z
2016-08-19T11:40:21.620Z
Julien Guertault
<p>Sample locations with a uniform pattern will create aliasing in the output, whenever there are geometric features of size comparable to or smaller than the sampling grid. That's the reason why "jaggies" exist: because images are made of a uniform square pixel grid, and when you render (for example) an angled line without antialiasing, it crosses rows/columns of pixels at regular intervals, creating a regular pattern of stairstep artifacts in the resulting image.</p>

<p>Supersampling at a finer uniform grid will improve things, but the image will still have similar artifacts—just less badly. You can see this with MSAA, as in this comparison image from an NVIDIA presentation on temporal antialiasing:</p>

<p><a href="https://i.sstatic.net/nYrym.png"><img src="https://i.sstatic.net/nYrym.png" alt="comparison of no AA, uniform-grid MSAA, and temporal AA"></a></p>

<p>The 8x MSAA image (which is <a href="https://msdn.microsoft.com/en-us/library/windows/desktop/ff476218.aspx#D3D11_MSAAPatterns_8_16">not quite a grid</a> but still has a repeating pattern) still plainly has jaggies in it, although they're antialiased jaggies. Compare to the TXAA result, which both has a higher effective sample count (due to temporal reuse) and uses a Gaussian rather than box filter for accumulating the samples.</p>

<p>On the other hand, random sampling produces noise instead of aliasing. There is no pattern to the sample locations, so no pattern to the resulting errors. Both aliasing and noise are errors due to not having enough samples to form a clean image, but arguably noise is the less visually-objectionable artifact.</p>

<p>On the <em>other</em> other hand, perfectly random sampling (in the sense of <a href="https://en.wikipedia.org/wiki/Independent_and_identically_distributed_random_variables">i.i.d. random variables</a>) tends to exhibit a certain level of clumping. Purely by chance, some areas in the domain will have denser-than-average clumps of samples, and other areas will be lacking in samples; those areas will be, respectively, over-represented and under-represented in the resulting estimate.</p>

<p>The convergence rate of the Monte Carlo process can often by improved by using things like <a href="http://cg.informatik.uni-freiburg.de/course_notes/graphics2_04_sampling.pdf#9">stratified sampling</a>, <a href="https://en.wikipedia.org/wiki/Low-discrepancy_sequence">low-discrepancy sequences</a>, or <a href="http://www.joesfer.com/?p=108">blue noise</a>. These are all strategies to generate "de-clumped" samples that are spaced out a bit more evenly than i.i.d. samples, but without creating any regular patterns that might lead to aliasing.</p>

CC BY-SA 3.0
2016-08-20T12:35:43.813Z
Ah.  And blue noise prevents the clumping by having less low frequency data in the sampling pattern.
Alan Wolfe
CC BY-SA 3.0
2016-08-20T06:48:31.657Z
2016-08-20T06:48:31.657Z
Nathan Reed
<p>Why is it that it's so common to use monte carlo randomized sample locations, instead of uniform sampling?</p>

<p>I'm assuming that taking randomized samples gives some benefit but I don't know what they could be.</p>

<p>Is anyone able to explain the advantage of randomized sample locations over uniform sample locations?</p>

CC BY-SA 3.0
2016-08-19T09:33:22.333Z
Usually to avoid getting uniform patterns everywhere, if you are using equally spaced uniform samples then you will get moire pattern effects as some pixels hit and miss features at a regular interval. Ideally some kind of importance sampling should be used to bias sampling directions.
PaulHK
CC BY-SA 3.0
2016-09-06T21:04:58.757Z
I recently read that both stratified sampling and low discrepency sequences (like halton, sobol, etc) are a middle ground between random sampling (which creates noise) and uniform sampling (which creates aliasing).
Alan Wolfe
<sampling><monte-carlo><integral>
Why random monte carlo sampling instead of uniform sampling?
Alan Wolfe
# Why random monte carlo sampling instead of uniform sampling?

(Asked by: username_0 on 2016-08-18)

Why is it that it's so common to use monte carlo randomized sample locations, instead of uniform sampling?

I'm assuming that taking randomized samples gives some benefit but I don't know what they could be.

Is anyone able to explain the advantage of randomized sample locations over uniform sample locations?

**Tags:** sampling, monte-carlo, integral

> **Comments:**
> **username_1**: Usually to avoid getting uniform patterns everywhere, if you are using equally spaced uniform samples then you will get moire pattern effects as some pixels hit and miss features at a regular interval. Ideally some kind of importance sampling should be used to bias sampling directions.  
> **username_0**: I recently read that both stratified sampling and low discrepency sequences (like halton, sobol, etc) are a middle ground between random sampling (which creates noise) and uniform sampling (which creates aliasing).  

---

## 2 answers

### Answer by username_4 on 2016-08-20. Score: 7 | Accepted answer

Sample locations with a uniform pattern will create aliasing in the output, whenever there are geometric features of size comparable to or smaller than the sampling grid. That's the reason why "jaggies" exist: because images are made of a uniform square pixel grid, and when you render (for example) an angled line without antialiasing, it crosses rows/columns of pixels at regular intervals, creating a regular pattern of stairstep artifacts in the resulting image.

Supersampling at a finer uniform grid will improve things, but the image will still have similar artifacts—just less badly. You can see this with MSAA, as in this comparison image from an NVIDIA presentation on temporal antialiasing:

[![comparison of no AA, uniform-grid MSAA, and temporal AA](https://i.sstatic.net/nYrym.png)](https://i.sstatic.net/nYrym.png)

The 8x MSAA image (which is [not quite a grid](https://msdn.microsoft.com/en-us/library/windows/desktop/ff476218.aspx#D3D11_MSAAPatterns_8_16) but still has a repeating pattern) still plainly has jaggies in it, although they're antialiased jaggies. Compare to the TXAA result, which both has a higher effective sample count (due to temporal reuse) and uses a Gaussian rather than box filter for accumulating the samples.

On the other hand, random sampling produces noise instead of aliasing. There is no pattern to the sample locations, so no pattern to the resulting errors. Both aliasing and noise are errors due to not having enough samples to form a clean image, but arguably noise is the less visually-objectionable artifact.

On the *other* other hand, perfectly random sampling (in the sense of [i.i.d. random variables](https://en.wikipedia.org/wiki/Independent_and_identically_distributed_random_variables)) tends to exhibit a certain level of clumping. Purely by chance, some areas in the domain will have denser-than-average clumps of samples, and other areas will be lacking in samples; those areas will be, respectively, over-represented and under-represented in the resulting estimate.

The convergence rate of the Monte Carlo process can often by improved by using things like [stratified sampling](http://cg.informatik.uni-freiburg.de/course_notes/graphics2_04_sampling.pdf#9), [low-discrepancy sequences](https://en.wikipedia.org/wiki/Low-discrepancy_sequence), or [blue noise](http://www.joesfer.com/?p=108). These are all strategies to generate "de-clumped" samples that are spaced out a bit more evenly than i.i.d. samples, but without creating any regular patterns that might lead to aliasing.

> **Comments:**
> **username_0**: Ah.  And blue noise prevents the clumping by having less low frequency data in the sampling pattern.  

---

### Answer by username_2 on 2016-08-19. Score: 6

Monte Carlo methods rely on the **[law of large numbers](https://en.wikipedia.org/wiki/Law_of_large_numbers)**, which states that the average of a random event repeated a large number of times converges toward the expected value (if you flip a coin a gazillion times, on average you will obtain each side half the time). **[Monte Carlo integration](https://en.wikipedia.org/wiki/Monte_Carlo_integration)** uses that law to evaluate an integral by averaging a large number of random samples.

Using a uniform distribution would break the algorithm because the law it is based upon wouldn't apply anymore.

> **Comments:**
> **username_3**: Yes but mostly it can be summed as this for a unknown problem, ramdom is the best strategy. since contribution  is unknown...  
> **username_2**: @username_3: oh, I realize you and I have read the question differently. Yes, Monte Carlo is a strategy that works when the analytical solution is unknown (although a math person would probably have a much more precise way of putting it).  
> **username_2**: Said differently: even if the solution is unknown, Monte Carlo is proven to converge toward it.  

---

