差分

このページの2つのバージョン間の差分を表示します。

この比較画面へのリンク

両方とも前のリビジョン前のリビジョン
softwares:root:convolution_by_gaussian [2018/06/16 13:46] kobayashsoftwares:root:convolution_by_gaussian [2018/06/16 13:50] (現在) kobayash
行 11: 行 11:
 y = F^{-1}(x) = \sqrt{2}\sigma\ \mathrm{erf}^{-1}\left(2x - 1\right) + \mu, y = F^{-1}(x) = \sqrt{2}\sigma\ \mathrm{erf}^{-1}\left(2x - 1\right) + \mu,
 \end{align} where $ 0 < x < 1$. Fortunately, the ROOT has an implementation of the inverse error function $\mathrm{erf}^{-1}(x)$ ([[https://root.cern.ch/root/html524/TMath.html#TMath:ErfInverse|TMath::ErfInverse()]]), and thus the random numbers filling in the normal distribution $f(x;\mu,\sigma^2)$ can be shot by "mean+sigma*sqrt(2)*TMath::ErfInverse(2*rndm-1)". In the formula, "rndm" is an uniform random number in the range (0,1). \end{align} where $ 0 < x < 1$. Fortunately, the ROOT has an implementation of the inverse error function $\mathrm{erf}^{-1}(x)$ ([[https://root.cern.ch/root/html524/TMath.html#TMath:ErfInverse|TMath::ErfInverse()]]), and thus the random numbers filling in the normal distribution $f(x;\mu,\sigma^2)$ can be shot by "mean+sigma*sqrt(2)*TMath::ErfInverse(2*rndm-1)". In the formula, "rndm" is an uniform random number in the range (0,1).
-    * At first, we have to obtain the integral of the normal (Gaussian) distribution $f(t;\mu,\sigma^2)$, $F(x)$. The integral $F(x)$ can be written as \begin{align}+    * At first, we have to obtain the integral $F(x)$ of the normal (Gaussian) distribution $f(t;\mu,\sigma^2)$. $F(x)$ can be written as \begin{align}
 F(x) = \int_{-\infty}^x f(t;\mu,\sigma^2) dt = \frac{1}{2}\left[1+\mathrm{erf}\left(\frac{x-\mu}{\sqrt{2}\sigma}\right)\right], F(x) = \int_{-\infty}^x f(t;\mu,\sigma^2) dt = \frac{1}{2}\left[1+\mathrm{erf}\left(\frac{x-\mu}{\sqrt{2}\sigma}\right)\right],
 \end{align} where $ 0 < F(x) < 1$. The derivation is the following. Assuming $T=\frac{t-\mu}{\sqrt{2}\sigma}$, $\sqrt{2}\sigma dT = dt$, and \begin{align} \end{align} where $ 0 < F(x) < 1$. The derivation is the following. Assuming $T=\frac{t-\mu}{\sqrt{2}\sigma}$, $\sqrt{2}\sigma dT = dt$, and \begin{align}
行 23: 行 23:
 F(x) = \frac{1}{2}\left[1+\mathrm{erf}\left(\frac{x-\mu}{\sqrt{2}\sigma}\right)\right]. F(x) = \frac{1}{2}\left[1+\mathrm{erf}\left(\frac{x-\mu}{\sqrt{2}\sigma}\right)\right].
 \end{align} By the way, $F(x)$ can vary in $ 0 < F(x) < 1$, because $\mathrm{erf}(x)$ can vary in $-1 < \mathrm{erf}(x) < 1$. (In fact, this is trivial, because the $f(x;\mu,\sigma^2)$ is a probability distribution and should be larger than $0$. In addition, the integral of the $f(x;\mu,\sigma^2)$ is normalized to $1$.) \end{align} By the way, $F(x)$ can vary in $ 0 < F(x) < 1$, because $\mathrm{erf}(x)$ can vary in $-1 < \mathrm{erf}(x) < 1$. (In fact, this is trivial, because the $f(x;\mu,\sigma^2)$ is a probability distribution and should be larger than $0$. In addition, the integral of the $f(x;\mu,\sigma^2)$ is normalized to $1$.)
-    * Then the inverse function of the integral of the normal distribution, $F^{-1}(x)$, can be obtained as below. From $F(x) = \frac{1}{2}\left[1+\mathrm{erf}\left(\frac{x-\mu}{\sqrt{2}\sigma}\right)\right]$, \begin{align}+    * Then the inverse function, $F^{-1}(x)$, of the integral of the normal distribution can be obtained as below. From $F(x) = \frac{1}{2}\left[1+\mathrm{erf}\left(\frac{x-\mu}{\sqrt{2}\sigma}\right)\right]$, \begin{align}
 \mathrm{erf}\left(\frac{x-\mu}{\sqrt{2}\sigma}\right) &= 2F(x) - 1\\ \mathrm{erf}\left(\frac{x-\mu}{\sqrt{2}\sigma}\right) &= 2F(x) - 1\\
 \Rightarrow \mathrm{erf}^{-1}\left[\mathrm{erf}\left(\frac{x-\mu}{\sqrt{2}\sigma}\right)\right] &= \mathrm{erf}^{-1}\left[2F(x) - 1\right]\\ \Rightarrow \mathrm{erf}^{-1}\left[\mathrm{erf}\left(\frac{x-\mu}{\sqrt{2}\sigma}\right)\right] &= \mathrm{erf}^{-1}\left[2F(x) - 1\right]\\
softwares/root/convolution_by_gaussian.1529124416.txt.gz · 最終更新: 2018/06/16 13:46 by kobayash
CC Attribution-Share Alike 4.0 International
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0