扯淡MonteCarlo(一)

研究生期间看过很多Monte-Carlo的东西,还根据这个写了一篇小论文,单纯粹是应付毕业任务,到毕业之后我都弄不清楚Monte-Carlo是什么玩意~~只会吹吹牛逼,说我弄过那玩意,其实不然尴尬

最近水怪蜀山忽然说他要搞搞MC,我一时心血来潮,心想我自己看了那么就的MC,就是弄不懂起码也得有点感觉吧,然后翻出Global illumination,专门用公司的打印机打出MC这一章,小有启发,赶紧再次记下,省的回头又还给他。

首先先弄懂Monte-Carlo他解决了一个什么问题?为什么需要Monte-Carlo?

我们知道在计算机图形学就是为了能够更好的反应现实世界,要想呈现出更好图像必须计算光照-光照强度等等,此时就会有一系列的积分方程,通过高等数学只是可能很快的就能计算出他的积分值,但是计算机只能处理离散的量,只能通过采样然后取有限的采样点进行计算来近似这个积分值-----Monte-Carlo应运而生。

蒙特卡洛方法或称随机模拟方法,是一种基于“随机数”的计算方法。看Global Illumination中写道" Consider a problem that must be solved, for example, computing the value of the integration of a function with respect to an appropriately defined measure over a domain. The Monte Carlo approach to solving this problem would to define a random variable such that the expected value of that random variable would be the solution to the problem.”由此可以看出Monte-Carlo就是解决一些积分问题。

要想弄明白Monte-Carlo,要会概率论的那些知识(Expected value期望、Variance方差、Standard Deviation)再次就不一一解释了。给我最大启发的还是下面这几句话:

"In summary, a Monte Carlo estimator for an integral 1is1.

The variance of this estimator is

1

Mote Carlo integration is a powerful, general technique that can handle arbitrary functions. A Monte Carlo computation consists of the following steps:

  1. Sampling according to a probability distribution function.
  2. Evaluation of the function at that sample.
  3. Averaging these appropriately weighted sampled values

The user only needs to understand how to do the above three steps to be able to use Monte Carlo techniques.

上面几句话无异于画龙点睛之笔,深刻的说明了采用Monte-Carlo方法时的步骤:

  1. 根据一个概率分布函数进行取样。
  2. 使用这些采样点对要积分的函数进行评估。
  3. 根据某些权重对采样点进行处理计算。

好,就到这儿吧,这也只是对Monte-Carlo的一个初步解释,还有很多需要注意的地方比方说采样的方法、减小方差的方法等等,容后再议。

原文地址:https://www.cnblogs.com/cg_ghost/p/2211045.html