TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Monte Carlo Crash Course: Sampling

108 pointsby ibobevabout 1 month ago

2 comments

vitusabout 1 month ago
Perhaps the most commonly-cited (but not actually all that practical) example for rejection sampling is estimating the value of pi (as hinted by the first example under uniform random sampling): generate two random numbers between 0 and 1, then check the fraction of points that satisfy x^2 + y^2 &lt;= 1. As number of samples tends to infinity, this will converge to pi&#x2F;4. (You can instead take x,y from (-1,1) if you want to generate points on the full circle.)<p>&gt; However, rejection sampling is only efficient when f_Omega can make use of a significant proportion of the probability density in f_D.<p>Perhaps a more relevant example: the unit n-sphere encloses a vanishing amount of volume as the number of dimensions increases.<p><a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Volume_of_an_n-ball" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Volume_of_an_n-ball</a><p>This is one of those weird consequences that gets labeled as the curse of dimensionality, especially in ML contexts.<p>&quot;As the dimension d of the space increases, the hypersphere becomes an insignificant volume relative to that of the hypercube.&quot;<p><a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Curse_of_dimensionality#Distance_function" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Curse_of_dimensionality#Distan...</a>
评论 #43688117 未加载
atum47about 1 month ago
Slightly related, I once created an app that calculate the volume of a random shape using Monte Carlo <a href="https:&#x2F;&#x2F;github.com&#x2F;victorqribeiro&#x2F;monteCarlo">https:&#x2F;&#x2F;github.com&#x2F;victorqribeiro&#x2F;monteCarlo</a>