<p>I think so. I did some numerical experiments using Monte-Carlo intergation.</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th></th>
<th>discard</th>
<th>no-discard</th>
<th>within-range uniform</th>
<th>GT</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="math-container">$x^2,x\in[0, 2)$</span></td>
<td>14.705318</td>
<td><strong>2.66772274</strong></td>
<td><strong>2.6668968</strong></td>
<td>2.666666</td>
</tr>
<tr>
<td><span class="math-container">$\sin x, x\in[0, \pi)$</span></td>
<td>7.4154146</td>
<td><strong>1.99990323</strong></td>
<td><strong>2.0004143</strong></td>
<td>2</td>
</tr>
<tr>
<td><span class="math-container">$\text{sigmoid},x\in[0, 1)$</span></td>
<td>6.5161143</td>
<td><strong>0.62023634</strong></td>
<td><strong>0.6201093</strong></td>
<td>0.620115</td>
</tr>
<tr>
<td><span class="math-container">$1 / (x+1)^2,x\in[0, 1)$</span></td>
<td>5.2540569</td>
<td><strong>0.49955521</strong></td>
<td><strong>0.4999410</strong></td>
<td>0.5</td>
</tr>
</tbody>
</table>
</div>
<p><code>discard</code> means that we discard the samples that are outside of the range, <code>no-discard</code> means that those out-of-range samples will be kept track of. <code>within-range uniform</code> means that we sample in that range with uniform distribution so it does not have out-of-range samples in the first place. The original sampling approach is exponential which means that it samples in <span class="math-container">$[0, \infty)$</span> therefore will have out-of-range samples.</p>

CC BY-SA 4.0
2023-08-22T09:15:52.937Z
Thanks for these experiments! I think they are able to verify my thoughts.
Enigmatisms
CC BY-SA 4.0
2023-08-22T06:26:13.700Z
2023-08-24T06:03:12.417Z
2023-08-24T06:03:12.417Z
Raven
<p>I recently stumbled into this question:
Say, for example, we are doing mean-free-path sampling (distance sampling) in a scattering medium and to keep it simple, let's only consider the single scattering case, but I'm only interested in part of the region, as shown in the following figure. It won't feel like it is a problem if I just <strong>discard all the samples outside of region</strong>.
<a href="https://i.sstatic.net/EFHR0.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/EFHR0.png" alt="enter image description here" /></a>
However, when I revisit the mathematical expression of the expectation, I found that:
<span class="math-container">$$
\mathbb{E}(\hat{I}) = \int_0^{+\inf} \underbrace{\frac{f(x)}{p(x)}}_{\text{estimator}} \underbrace{p(x)}_{\text{PDF}} \text{d}x
$$</span>
Yeah, if the PDF term in the denominator of the estimator and the PDF of the sample <span class="math-container">$x$</span> are the same, these two terms will cancel each other out and we are left with the integral we want. Yet, <strong>discarding all the samples outside of the interested region</strong> is seemed to alter the PDF of the samples. I think that, for now, all the recorded samples have a conditional PDF:
<span class="math-container">$$
p(x|x\text{ in region})
$$</span>
If we are using the original estimator, for example, if we sample <span class="math-container">$x$</span> from an exponential distribution, we will normally have this estimator:
<span class="math-container">$$
\frac{f(x)}{\sigma_t \exp(-\sigma_t x)}
$$</span>
Since we are expecting that when we sample <span class="math-container">$x$</span> according to <span class="math-container">$-\log(1 - x)/\sigma_t$</span>，the sample <span class="math-container">$x$</span> actually follows the same distribution, but it seems that when we discard samples, these two PDF terms can not be cancelled out.</p>
<p>My question is:</p>
<ul>
<li>Does this mean that we can should modify the PDF in the estimator according to the region we are interested? Am I right about this?</li>
<li>What should be the correct distribution of the samples? A exponential distribution &quot;confined&quot; in a small region?</li>
<li>What is the case for more bounces? If the one-bounce case is biased, does this mean that the multi-bounce case is also biased?</li>
</ul>

CC BY-SA 4.0
2023-08-11T11:53:54.670Z
We can break down the result calculated when the interested region is infinity into non-overlapping segments. So, if every segment is biased, why they can be summed to an unbiased result?
Enigmatisms
<mathematics><sampling><importance-sampling><monte-carlo>
Confusion about the bias during Monte Carlo integration
Enigmatisms
# Confusion about the bias during Monte Carlo integration

(Asked by: username_0 on 2023-08-10)

I recently stumbled into this question:
Say, for example, we are doing mean-free-path sampling (distance sampling) in a scattering medium and to keep it simple, let's only consider the single scattering case, but I'm only interested in part of the region, as shown in the following figure. It won't feel like it is a problem if I just **discard all the samples outside of region**.
[![enter image description here](https://i.sstatic.net/EFHR0.png)](https://i.sstatic.net/EFHR0.png)
However, when I revisit the mathematical expression of the expectation, I found that:
$$
\mathbb{E}(\hat{I}) = \int\_0^{+\inf} \underbrace{\frac{f(x)}{p(x)}}\_{\text{estimator}} \underbrace{p(x)}\_{\text{PDF}} \text{d}x
$$
Yeah, if the PDF term in the denominator of the estimator and the PDF of the sample $x$ are the same, these two terms will cancel each other out and we are left with the integral we want. Yet, **discarding all the samples outside of the interested region** is seemed to alter the PDF of the samples. I think that, for now, all the recorded samples have a conditional PDF:
$$
p(x|x\text{ in region})
$$
If we are using the original estimator, for example, if we sample $x$ from an exponential distribution, we will normally have this estimator:
$$
\frac{f(x)}{\sigma\_t \exp(-\sigma\_t x)}
$$
Since we are expecting that when we sample $x$ according to $-\log(1 - x)/\sigma\_t$，the sample $x$ actually follows the same distribution, but it seems that when we discard samples, these two PDF terms can not be cancelled out.

My question is:

* Does this mean that we can should modify the PDF in the estimator according to the region we are interested? Am I right about this?
* What should be the correct distribution of the samples? A exponential distribution "confined" in a small region?
* What is the case for more bounces? If the one-bounce case is biased, does this mean that the multi-bounce case is also biased?

**Tags:** mathematics, sampling, importance-sampling, monte-carlo

> **Comments:**
> **username_0**: We can break down the result calculated when the interested region is infinity into non-overlapping segments. So, if every segment is biased, why they can be summed to an unbiased result?  

---

## 1 answers

### Answer by username_1 on 2023-08-22. Score: 2 | Accepted answer

I think so. I did some numerical experiments using Monte-Carlo intergation.

|  | discard | no-discard | within-range uniform | GT |
| --- | --- | --- | --- | --- |
| $x^2,x\in[0, 2)$ | 14.705318 | **2.66772274** | **2.6668968** | 2.666666 |
| $\sin x, x\in[0, \pi)$ | 7.4154146 | **1.99990323** | **2.0004143** | 2 |
| $\text{sigmoid},x\in[0, 1)$ | 6.5161143 | **0.62023634** | **0.6201093** | 0.620115 |
| $1 / (x+1)^2,x\in[0, 1)$ | 5.2540569 | **0.49955521** | **0.4999410** | 0.5 |

`discard` means that we discard the samples that are outside of the range, `no-discard` means that those out-of-range samples will be kept track of. `within-range uniform` means that we sample in that range with uniform distribution so it does not have out-of-range samples in the first place. The original sampling approach is exponential which means that it samples in $[0, \infty)$ therefore will have out-of-range samples.

> **Comments:**
> **username_0**: Thanks for these experiments! I think they are able to verify my thoughts.  

---

