sp-monte-carlo
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
      • Invitee
    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Versions and GitHub Sync Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
Invitee
Publish Note

Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

Your note will be visible on your profile and discoverable by anyone.
Your note is now live.
This note is visible on your profile and discoverable online.
Everyone on the web can find and read all notes of this public team.
See published notes
Unpublish note
Please check the box to agree to the Community Guidelines.
View profile
Engagement control
Commenting
Permission
Disabled Forbidden Owners Signed-in users Everyone
Enable
Permission
  • Forbidden
  • Owners
  • Signed-in users
  • Everyone
Suggest edit
Permission
Disabled Forbidden Owners Signed-in users Everyone
Enable
Permission
  • Forbidden
  • Owners
  • Signed-in users
Emoji Reply
Enable
Import from Dropbox Google Drive Gist Clipboard
   owned this note    owned this note      
Published Linked with GitHub
Subscribed
  • Any changes
    Be notified of any changes
  • Mention me
    Be notified of mention me
  • Unsubscribe
Subscribe
###### tags: `mcnf` `monte carlo` `expository` # Monte Carlo Estimation of Nonlinear Functionals: Polynomials **Overview**: In this note, I will sketch the task of estimation of nonlinear functions of expectations, and the difficulties which this poses for conventional Monte Carlo methods. I will then explain how these difficulties can be addressed when the nonlinearity in question is polynomial, and hint at extensions to the general case. ## Principles of Linearity in Monte Carlo As has hopefully been well-detailed in earlier posts, the Monte Carlo method benefits greatly from linear-algebraic structure: one can estimate sums of integrals unbiasedly by estimating each integral unbiasedly, and then taking sums of the estimators. Moreover, studying the variance of these sum-based estimators is typically quite straightforward. Challenges arise when we want to compute nonlinear functions of integrals. For general nonlinear functions $\Phi$, it will not hold that $\mathbf{E} \left[ \Phi \left( X \right)\right] = \Phi \left( \mathbf{E} \left[ X \right] \right)$, and so naive modifications of standard estimators will incur some bias. It bears mentioning that *this may be fine*. Arguably, the 'real' mark of estimator quality might be mean squared error, or the narrowness of confidence intervals, or other more holistic measures of concentration around the truth. Nevertheless, the presence of bias is often symptomatic of other undesirable problems with an estimator, and so it is useful to understand how bias can be mitigated. ## A Simple Example: The Square of an Expectation A useful starting point is to consider one of the simplest nonlinear functions, namely $\Phi(x) = x^2$. One reason for this choice is that it is somehow familiar: a conventional representation for the variance of a random variable is \begin{align} \text{Var} \left[ X \right] &= \mathbf{E} \left[ X^2 \right] - \mathbf{E} \left[ X \right]^2. \end{align} Standard Monte Carlo provides a route to unbiased estimation of $\mathbf{E} \left[ X^2 \right]$, and a first course in Statistics will often teach that the same is possible for $\text{Var} \left[ X \right]$. Hence, by the aforementioned virtues of linearity in Monte Carlo, we must accept that an unbiased estimator for $\mathbf{E} \left[ X \right]^2$ exists! Now, let us try to derive such an estimator by ourselves. Begin by writing \begin{align} \mathbf{E} \left[ X \right]^2 &= \mathbf{E} \left[ X \right] \cdot \mathbf{E} \left[ X \right] \\ &= \left( \int p(dx_1) \, x_1 \right) \cdot \left( \int p(dx_2) \, x_2 \right) \\ &= \int p(dx_1) p(dx_2) \, x_1 x_2 \\ &= \mathbf{E}_{p \otimes p} [ X_1 X_2]. \end{align} This is good news: we can again write our quantity of interest as the integral of a function against a probability measure. The difference is that the probability measure in question is now constructed through considering *multiple copies* of our 'base' probability measure $p$. Now, consider the following estimator 1. Draw samples $(x_1^{(1)}, x_2^{(1)}), \ldots, (x_1^{(N)}, x_2^{(N)}) \sim p \otimes p$. 2. Form the estimator \begin{align} \hat{I}_N = \frac{1}{N} \sum_{i = 1}^N x_1^{(i)} x_2^{(i)}. \end{align} The good news is that this estimator is unbiased for the quantity of interest. The slightly strange news is that it is also very wasteful. Looking closely at the generative process, we have drawn a total of $2N$ samples from $p$, but only used them in a very limited way. Note that any quantity of the form $x_a^{(i)} x_b^{(j)}$ with $(a, i) \neq (b, j)$ is also an unbiased estimator for our quantity of interest, and we have ignored many such terms. In fact, we can improve the quality of our estimator by recycling all of the same information more carefully, along the lines of the following estimator: 1. Draw samples $x^1, \cdots, x^N \sim p$, with $N \geqslant 2$. 2. Form the estimator \begin{align} \hat{I}_N = \frac{1}{N(N-1)} \sum_{i = 1}^N \sum_{j = 1}^N \mathbf{I} \left[ i \neq j \right] x^i x^j. \end{align} The premise of this estimator is that for any $i \neq j$, the quantity $x^i x^j$ is an unbiased estimator of $\mathbf{E} \left[ X \right]^2$, and so we should include all of these terms in our estimator. With some work, one can show that this new estimator has lower variance than our first attempt. It is worth noting that this estimator is distinct from the 'naive' estimator obtained by squaring the sample mean of the $x^i$, which exhibits a systematic upwards bias of $\mathcal{O}(N^{-1})$. A slight drawback of this new estimator appears to be that it now appears to cost $\mathcal{O} \left( N^2 \right)$ to actually assemble the estimator once the samples are drawn. In fact, this is an illusion. Consider the following manipulations: \begin{align} \hat{I}_N &= \frac{1}{N(N-1)} \left( \sum_{i = 1}^N \sum_{j = 1}^N x^i x^j - \sum_{i = 1}^N \left( x^i \right)^2 \right) \\ &= \frac{1}{N(N-1)} \left( \left( \sum_{i = 1}^N x^i\right)^2 - \sum_{i = 1}^N \left( x^i \right)^2 \right) \\ &= \frac{N}{N - 1} \left(\frac{1}{N} \sum_{i = 1}^N x^i\right)^2 - \frac{1}{N-1} \left( \sum_{i = 1}^N \left(x^i\right)^2 \right), \end{align} where both of the two terms can be formed in time $\mathcal{O}(N)$. This is representative of what one can expect in the polynomial case. Note also that in order to form this unbiased estimator of $\mathbf{E} \left[ X \right]^2$, we need to draw at least $2$ samples from $p$. This will be mirrored in the forthcoming extensions. ## Towards General Polynomials of Expectations Consider now estimating a quantity of the form \begin{align} I \left( \mathbf{f}, \alpha \right) = \prod_{m = 1}^M \mathbf{E}[f_m(X)]^{\alpha_m}, \end{align} where all expectations are taken with respect to the same probability measure over $X$, and all $\alpha_m$ are nonnegative integers. A similar derivation to earlier allows us to write that \begin{align} I \left( \mathbf{f}, \alpha \right) = \int \prod_{m = 1}^M \prod_{a = 1}^{\alpha_m} f_m (x_m^a) p (dx_m^a), \end{align} where now the integral is being taken against $|\alpha| := \sum_{m = 1}^M \alpha_m$ copies of $p$. This suggests the following estimator: 1. Fix $N \geqslant |\alpha|$. 2. Draw samples $x^1, \cdots, x^N \sim p$. 3. For all ordered subsets $S$ of $[N]$ of size $|\alpha|$, $S = (a_1, \ldots, a_{|\alpha|})$, partition $S = S_1 \sqcup \cdots \sqcup S_M$, where $|S_m| = \alpha_m$, and form the sub-estimator \begin{align} \hat{I} (x^S)&= \prod_{m = 1}^M \prod_{i \in S_m} f_m (x^{a_i}) \end{align} 4. Form the estimator \begin{align} \hat{I}_N = \frac{1}{N(N-1)\cdots(N - |\alpha|+1)} \sum_{S} \hat{I} (x^S). \end{align} As before, while the naive implementation of this estimator would have a computational cost scaling like $N^{|\alpha|}$, there are typically combinatorial simplifications available which can reduce the cost to $\mathcal{O}(N)$ (though with a constant prefactor which typically grows with $|\alpha|$). ## Conclusion While the unbiased estimation of nonlinear functions of expectations is typically a challenging endeavour, when the nonlinearity in question is polynomial, there is a systematic solution available, which has been detailed above. Moreover, the procedure is in some sense optimal, in terms of making maximal use of the information contained in the samples. In essence, the enabling factor is that products of expectations can be unbiasedly estimated, provided that the expectations themselves can be. It is then somewhat disappointing to learn that for general nonlinearities and expectands, unbiased estimation from a fixed number of samples cannot generally be accomplished. This is related to the fact that from a fixed number of independent $\text{Bernoulli}(p)$ coin flips, the only functions of $p$ which can be unbiasedly estimated are polynomials, which the eager reader is invited to prove for themselves. There are two main strategies for resolving this difficulty which we will consider in upcoming posts. The first is to accept that unbiasedness is a big ask, and to simply aspire to bias mitigation, e.g. to ensure that the bias is of lower order than the Monte Carlo variance. The second is to persist in the pursuit of unbiasedness, but at the cost of drawing a random (potentially unbounded!) number of samples. ---

Import from clipboard

Paste your markdown or webpage here...

Advanced permission required

Your current role can only read. Ask the system administrator to acquire write and comment permission.

This team is disabled

Sorry, this team is disabled. You can't edit this note.

This note is locked

Sorry, only owner can edit this note.

Reach the limit

Sorry, you've reached the max length this note can be.
Please reduce the content or divide it to more notes, thank you!

Import from Gist

Import from Snippet

or

Export to Snippet

Are you sure?

Do you really want to delete this note?
All users will lose their connection.

Create a note from template

Create a note from template

Oops...
This template has been removed or transferred.
Upgrade
All
  • All
  • Team
No template.

Create a template

Upgrade

Delete template

Do you really want to delete this template?
Turn this template into a regular note and keep its content, versions, and comments.

This page need refresh

You have an incompatible client version.
Refresh to update.
New version available!
See releases notes here
Refresh to enjoy new features.
Your user state has changed.
Refresh to load new user state.

Sign in

Forgot password

or

By clicking below, you agree to our terms of service.

Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
Wallet ( )
Connect another wallet

New to HackMD? Sign up

Help

  • English
  • 中文
  • Français
  • Deutsch
  • 日本語
  • Español
  • Català
  • Ελληνικά
  • Português
  • italiano
  • Türkçe
  • Русский
  • Nederlands
  • hrvatski jezik
  • język polski
  • Українська
  • हिन्दी
  • svenska
  • Esperanto
  • dansk

Documents

Help & Tutorial

How to use Book mode

Slide Example

API Docs

Edit in VSCode

Install browser extension

Contacts

Feedback

Discord

Send us email

Resources

Releases

Pricing

Blog

Policy

Terms

Privacy

Cheatsheet

Syntax Example Reference
# Header Header 基本排版
- Unordered List
  • Unordered List
1. Ordered List
  1. Ordered List
- [ ] Todo List
  • Todo List
> Blockquote
Blockquote
**Bold font** Bold font
*Italics font* Italics font
~~Strikethrough~~ Strikethrough
19^th^ 19th
H~2~O H2O
++Inserted text++ Inserted text
==Marked text== Marked text
[link text](https:// "title") Link
![image alt](https:// "title") Image
`Code` Code 在筆記中貼入程式碼
```javascript
var i = 0;
```
var i = 0;
:smile: :smile: Emoji list
{%youtube youtube_id %} Externals
$L^aT_eX$ LaTeX
:::info
This is a alert area.
:::

This is a alert area.

Versions and GitHub Sync
Get Full History Access

  • Edit version name
  • Delete

revision author avatar     named on  

More Less

Note content is identical to the latest version.
Compare
    Choose a version
    No search result
    Version not found
Sign in to link this note to GitHub
Learn more
This note is not linked with GitHub
 

Feedback

Submission failed, please try again

Thanks for your support.

On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

Please give us some advice and help us improve HackMD.

 

Thanks for your feedback

Remove version name

Do you want to remove this version name and description?

Transfer ownership

Transfer to
    Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

      Link with GitHub

      Please authorize HackMD on GitHub
      • Please sign in to GitHub and install the HackMD app on your GitHub repo.
      • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
      Learn more  Sign in to GitHub

      Push the note to GitHub Push to GitHub Pull a file from GitHub

        Authorize again
       

      Choose which file to push to

      Select repo
      Refresh Authorize more repos
      Select branch
      Select file
      Select branch
      Choose version(s) to push
      • Save a new version and push
      • Choose from existing versions
      Include title and tags
      Available push count

      Pull from GitHub

       
      File from GitHub
      File from HackMD

      GitHub Link Settings

      File linked

      Linked by
      File path
      Last synced branch
      Available push count

      Danger Zone

      Unlink
      You will no longer receive notification when GitHub file changes after unlink.

      Syncing

      Push failed

      Push successfully