1. 程式人生 > >PBRT_V2 總結記錄 A Quick Introduction to Monte Carlo Methods

PBRT_V2 總結記錄 A Quick Introduction to Monte Carlo Methods

參考 : https://www.scratchapixel.com/lessons/mathematics-physics-for-computer-graphics/monte-carlo-methods-mathematical-foundations

 

Monte Carlo approximation

 

For a mathematician, the height of a population would be called a random variable, because height among people making up

(組成) this population varies randomly(隨機變化). We generally denote random variables with upper case letters. The letter X is commonly used.

In statistics(統計學), the elements making up(組成) that population, which as suggested before(就像之前說明的) are random, are denoted with a lower capital letter

(小寫字母), generally x as well. For example if we write x2, this would denote the height (which is random) of the second person in the population. All these x's can also be seen as the possible outcomes of(結果) the random variable X.(所有的x可以看做是隨機變數X的可能結果) If we call X this random variable (the population height), we can express the concept of approximating the average adult population height from a sample with the following pseudo-mathematical formula:

(在數學上,人口的高度其實是一個隨機變數,因為因為每一個人得高度都是隨機的,那麼人口的高度肯定也是隨機變化的,隨機變數一般用大寫X來表示,在統計學中,人口中的某一個人得高度是隨機的,用小寫x表示,例如,x2 表示的是在人口中的第二個人,所有的x可以看做是隨機變數 X 的 可能的結果,所以 小寫x 和大寫X 之間的關係就是 上面的公式。)

 

Which you can read as, the approximation of the average value of the random variable X, (the height of the adult population of

a given country), is equal to the sum  of the height of N adults randomly chosen from that population (the samples), divided by

the number N (the sample size). This in essence(本質上), is what we call a Monte Carlo approximation. It consists

of approximating some property(它近似 一些數量非常大的東西 的性質) of a very large number of things, by averaging the

value of that property for N of these things chosen randomly among all the others. You can also say that Monte Carlo

approximation, is in fact a method for approximating things using samples. What we will learn in the next chapters, is that the

things which need approximating are called in mathematics expectations(數學期望) (more on this soon). As mentioned

before(像之前) the height of the adult population of a given country can be seen as a random variable X. However note that its

average value (which you get by averaging all the height for example of each person making up the population, where each

one of these numbers is also a random number) is unique(獨一無二) (to avoid the confusion(困惑) with the sample size which

is usually denoted with the letter N, we will use M to denote the size of the entire population):

where the x1,x2,...xM corresponds to the height of each person making up(組成) the entire population as suggested(提

及) before (if we were to take an example). In statistics, the average of the random variable X is called an expectation(期

望) and is written E(X).

 

從上面的公式可以知道, 隨機變數X的 平均值 的近似 等於 所有的x的值的和 除以 x的個數,進一步來說,上面的  就是所謂的 Monte Carlo approximation,也可以是 數學期望

 

 

To summarize, Monte Carlo approximation (which is one of the MC methods) is a technique to approximate the expectation of

random variables, using samples. It can be defined mathematically with the following formula:

The mathematical sign ≈means that the formula on the right inside of this sign only gives an "approximation" of what the

random variable X expectation E(X) actually is. Note that in a way(在某一種程度上), it's nothing else than an average of

random values (the xn s).(它只是一個隨機值的平均值)

 

If you are just interested in understanding what's hiding behind this mysterious(神祕) term Monte Carlo, then this all you may

want to know about it. However for this quick introduction to be complete, let's explain why this method is useful. It happens as

suggested before(正如之前所建議的那樣) that computing E(X) is sometimes intractable(棘手的). This means that you can't

compute E(X) exactly(精確) at least not in an efficient way. This is particularly true when very large "populations" are concerned

in (有關)the computation of E(X) such as with(例如) the case of computing the average height of the adult population of a

country. MC approximation offers(提供) in this case a very simple and quick way to at least approximate this expectation(至少

近似這個期望). It won't give you the exact value, but it might be close enough at a fraction of(一小部分) the cost of what it might

take to compute E(X) exactly(計算E(X)的代價), if or possible at all(如果可能的話).

 

Biased And Unbiased

Let's now talk about the terms biased(偏差) and unbiased(無偏差). In statistics, the rule by which we compute the

approximation of E(X) is called an estimator. The equation:

is an example of estimator (in fact, it a simplified version of what's known as a Monte Carlo estimator and we call it a basic

estimator. You can find the complete equation and a complete definition of a Monte Carlo estimator in the next lesson). An

estimator is said to be unbiased if its result gets closer to the expectation(期望值) as the sample size N increases. In fact, we

can demonstrate(證明) that this approximation converges to the actual result as N approaches infinity (check the

chapter sampling distribution). Another way of expressing this is to say that the difference(偏差) between the approximation

and the expected value converges to(收斂) 0 as N approaches infinity which we can write as:

This is actually the case of the Monte Carlo estimator. To summarize(簡而言之), the Monte Carlo estimator is an unbiased

estimator. But when the difference between the result of the estimator and the expectation is different than 0 (as N approaches

infinity) then this estimator is said to be biased. This doesn't mean though that the estimator doesn't converge to a certain

value(某一個值) as N approaches infinity (when they do they are said to be consistent(一致)), only that this value is different

than the expectation(期望的值). At first glance(第一眼) unbiased estimators look better than biased estimators. Indeed(的

確) why do we need or would use estimators which results are different than the expectation? Because some of these

estimators have interesting properties. If the bias is small enough and the estimator converges faster than unbiased estimators

for instance, this can be considered as an interesting property. The result of these biased estimators may also have less

variance(方差) than the results of unbiased estimators for the same number of samples N. In other words, if you compute the

approximation a certain number of times with a biased estimator, you might see less of a variation from one approximation to

the next, compared to what you get with(著手) an unbiased estimator (for the same number of samples used). This is also

potentially an interesting quality. To summarize, you can either have a biased or unbiased Monte Carlo ray tracer. A biased MC

ray tracer is likely to be less noisy for the same amount of sample used (or faster) compared to an unbiased MC ray tracer,

however by using a biased estimator you will introduce some small error (the bias) compared to the "true" result. Generally

though this bias is small (otherwise the estimator wouldn't really be of any good), and is not noticeable(顯著) if you don't know

it's there.