From fcbde10f9be6c88f7954ee7a5277f817836b3d26 Mon Sep 17 00:00:00 2001 From: rnhmjoj Date: Tue, 26 May 2020 10:07:30 +0200 Subject: [PATCH] notes: use \num for numbers with exponential notation --- notes/sections/1.md | 18 +++++++------- notes/sections/2.md | 60 ++++++++++++++++++++++----------------------- notes/sections/3.md | 2 +- notes/sections/5.md | 34 ++++++++++++------------- notes/sections/6.md | 16 ++++++------ 5 files changed, 65 insertions(+), 65 deletions(-) diff --git a/notes/sections/1.md b/notes/sections/1.md index bf08e46..5adb2e9 100644 --- a/notes/sections/1.md +++ b/notes/sections/1.md @@ -134,7 +134,7 @@ the mode of the Landau PDF, it was computed numerically by the *Brent* algorithm (`gsl_min_fminimizer_brent` in GSL), applied to $-f$ with a relative tolerance of $10^{-7}$, giving: $$ - \text{expected mode: } m_e = \SI{-0.22278298 \pm 0.00000006}{} + \text{expected mode: } m_e = \num{-0.22278298 \pm 0.00000006} $$ This is a minimization algorithm that begins with a bounded region known to @@ -177,7 +177,7 @@ bootstrapped. The original sample was treated as a population and used to build of the new samples, the above statistic was computed. By simply taking the mean of these statistics the following estimate was obtained: $$ - \text{observed mode: } m_o = \SI{-0.29 \pm 0.19}{} + \text{observed mode: } m_o = \num{-0.29 \pm 0.19} $$ In order to compare the values $m_e$ and $m_0$, the following compatibility @@ -236,7 +236,7 @@ $$ $$ where the absolute and relative tolerances $\varepsilon_\text{abs}$ and -$\varepsilon_\text{rel}$ were set to \SI{1e-10}{} and \SI{1e-6}{}, +$\varepsilon_\text{rel}$ were set to \num{1e-10} and \num{1e-6}, respectively. As for the QDF, this was implemented by numerically inverting the CDF. This was done by solving the equation; @@ -254,15 +254,15 @@ $$ where $a,b$ are the current interval bounds. The condition immediately gives an upper bound on the error of the root as $\varepsilon = |a-b|$. The tolerances -here were set to 0 and \SI{1e-3}{}. +here were set to 0 and \num{1e-3}. The result of the numerical computation is: $$ - \text{expected median: } m_e = \SI{1.3557804 \pm 0.0000091}{} + \text{expected median: } m_e = \num{1.3557804 \pm 0.0000091} $$ while the sample median, obtained again by bootstrapping, was found to be: $$ - \text{observed median: } m_e = \SI{1.3605 \pm 0.0062}{} + \text{observed median: } m_e = \num{1.3605 \pm 0.0062} $$ As stated above, the median is less sensitive to extreme values with respect to @@ -295,10 +295,10 @@ $$ was solved by performing the Brent-Dekker method (described before) in the ranges $[x_\text{min}, m_e]$ and $[m_e, x_\text{max}]$ yielding the two -solutions $x_\pm$. With a relative tolerance of \SI{1e-7}{}, the following +solutions $x_\pm$. With a relative tolerance of \num{1e-7}, the following result was obtained: $$ -\text{expected FWHM: } w_e = \SI{4.0186457 \pm 0.0000001}{} +\text{expected FWHM: } w_e = \num{4.0186457 \pm 0.0000001} $$ \vspace{-1em} @@ -341,7 +341,7 @@ With the empirical density estimation at hand, the FWHM can be computed by the same numerical method described for the true PDF. Again this was bootstrapped to estimate the standard error giving: $$ - \text{observed FWHM: } w_o = \SI{4.06 \pm 0.08}{} + \text{observed FWHM: } w_o = \num{4.06 \pm 0.08} $$ Applying the t-test to these two values gives diff --git a/notes/sections/2.md b/notes/sections/2.md index 9281c1a..dadbd68 100644 --- a/notes/sections/2.md +++ b/notes/sections/2.md @@ -45,38 +45,38 @@ $$ and $\gamma (n_i)$ was selected as the best result (see @tbl:1_results). ---------------------------------- -n $|\gamma(n)-\gamma|$ ------------ --------------------- -\SI{2e1}{} \SI{2.48e-02}{} +--------------------------------------------- +n $|\gamma(n)-\gamma|$ +---------------------- ---------------------- +\num{2e1} \num{2.48e-02} -\SI{2e2}{} \SI{2.50e-03}{} +\num{2e2} \num{2.50e-03} -\SI{2e3}{} \SI{2.50e-04}{} +\num{2e3} \num{2.50e-04} -\SI{2e4}{} \SI{2.50e-05}{} +\num{2e4} \num{2.50e-05} -\SI{2e5}{} \SI{2.50e-06}{} +\num{2e5} \num{2.50e-06} -\SI{2e6}{} \SI{2.50e-07}{} +\num{2e6} \num{2.50e-07} -\SI{2e7}{} \SI{2.50e-08}{} +\num{2e7} \num{2.50e-08} -\SI{2e8}{} \SI{2.50e-09}{} +\num{2e8} \num{2.50e-09} -\SI{2e9}{} \SI{2.55e-10}{} +\num{2e9} \num{2.55e-10} -\SI{2e10}{} \SI{2.42e-11}{} +\num{2e10} \num{2.42e-11} -\SI{2e11}{} \SI{1.44e-08}{} ---------------------------------- +\num{2e11} \num{1.44e-08} +--------------------------------------------- Table: Partial results using the definition of $\gamma$ with double precision. {#tbl:1_results} The convergence is logarithmic: to fix the first $d$ decimal places, about $10^d$ terms of the armonic series are needed. The double precision runs out at -the $10^{\text{th}}$ place, at $n=\SI{2e10}{}$. +the $10^{\text{th}}$ place, at $n=\num{2e10}$. Since all the number are given with double precision, there can be at best 16 correct digits, since for a double 64 bits are allocated in memory: 1 for the sign, 8 for the exponent and 55 for the mantissa: @@ -86,8 +86,8 @@ $$ Only 10 digits were correctly computed: this means that when the terms of the series start being smaller than the smallest representable double, the sum of -all the remaining terms gives a number $\propto 10^{-11}$. -Best result in @tbl:first. +all the remaining terms gives a number $\propto 10^{-11}$. The best result is +shown in @tbl:first. --------- ----------------------- true: 0.57721\ 56649\ 01533 @@ -147,7 +147,7 @@ $$ $$ The execution stops when there is no difference between two consecutive therms -of the infinite product (it happens for $k = 456565794 \sim \SI{4.6e8}{}$, +of the infinite product (it happens for $k = 456565794 \sim \num{4.6e8}$, meaning that for this value of $k$ the term of the product is equal to 1 in terms of floating points). Different values of $z$ were checked, with $z_{i+1} = z_i + 0.01$ ranging from 0 to 20, and the best result was found for $z = 9$. @@ -155,25 +155,25 @@ terms of floating points). Different values of $z$ were checked, with $z_{i+1} --------------------------------------------------------------- z $|\gamma(z) - \gamma |$ z $|\gamma(z) - \gamma |$ ----- ------------------------ ------ ------------------------ - 1 \SI{9.712e-9}{} 8.95 \SI{9.770e-9}{} + 1 \num{9.712e-9} 8.95 \num{9.770e-9} - 3 \SI{9.320e-9}{} 8.96 \SI{9.833e-9}{} + 3 \num{9.320e-9} 8.96 \num{9.833e-9} - 5 \SI{9.239e-9}{} 8.97 \SI{9.622e-9}{} + 5 \num{9.239e-9} 8.97 \num{9.622e-9} - 7 \SI{9.391e-9}{} 8.98 \SI{9.300e-9}{} + 7 \num{9.391e-9} 8.98 \num{9.300e-9} - 9 \SI{8.482e-9}{} 8.99 \SI{9.059e-9}{} + 9 \num{8.482e-9} 8.99 \num{9.059e-9} - 11 \SI{9.185e-9}{} 9.00 \SI{8.482e-9}{} + 11 \num{9.185e-9} 9.00 \num{8.482e-9} - 13 \SI{9.758e-9}{} 9.01 \SI{9.564e-9}{} + 13 \num{9.758e-9} 9.01 \num{9.564e-9} - 15 \SI{9.747e-9}{} 9.02 \SI{9.260e-9}{} + 15 \num{9.747e-9} 9.02 \num{9.260e-9} - 17 \SI{9.971e-9}{} 9.03 \SI{9.264e-9}{} + 17 \num{9.971e-9} 9.03 \num{9.264e-9} - 19 \SI{10.084e-9}{} 9.04 \SI{9.419e-9}{} + 19 \num{10.084e-9} 9.04 \num{9.419e-9} --------------------------------------------------------------- Table: Differences between some obtained values of $\gamma$ and @@ -251,7 +251,7 @@ known convergence formula (@eq:faster). {#tbl:fourth} Because of roundoff errors, the best result was obtained only for $D = 15$, for which the code accurately computes 15 digits and gives an error of -\SI{3.3e16}{}. For $D > 15$, the requested can't be fulfilled. +\num{3.3e16}. For $D > 15$, the requested can't be fulfilled. ### Arbitrary precision diff --git a/notes/sections/3.md b/notes/sections/3.md index 16cca17..651b60d 100644 --- a/notes/sections/3.md +++ b/notes/sections/3.md @@ -337,7 +337,7 @@ satisfied: 3. $\|\vec f(\vec x+ \vec\delta) - \vec f(\vec x)|| \leq \text{ftol} \cdot \max(\|\vec f(\vec x)\|, 1)$ -Where xtol, gtol and ftol are tolerance values all been set to \SI{1e-8}{}. The +Where xtol, gtol and ftol are tolerance values all been set to \num{1e-8}. The program converged in 7 iterations giving the results below. The covariance of the parameters can again been estimated through the Hessian matrix at the minimum. The following results were obtained: diff --git a/notes/sections/5.md b/notes/sections/5.md index bf6d141..542ad57 100644 --- a/notes/sections/5.md +++ b/notes/sections/5.md @@ -82,11 +82,11 @@ around the correct value.](images/5-MC_MC.pdf){#fig:MC} --------------------------------------------------------------------------- calls $I^{\text{oss}}$ $\sigma$ diff ------------------ ------------------ ------------------ ------------------ -\SI{5e5}{} 1.7166435813 0.0006955691 0.0016382472 +\num{5e5} 1.7166435813 0.0006955691 0.0016382472 -\SI{5e6}{} 1.7181231109 0.0002200309 0.0001587176 +\num{5e6} 1.7181231109 0.0002200309 0.0001587176 -\SI{5e7}{} 1.7183387184 0.0000695809 0.0000568899 +\num{5e7} 1.7183387184 0.0000695809 0.0000568899 --------------------------------------------------------------------------- Table: Some MC results with three different numbers of function calls. @@ -94,14 +94,14 @@ Table: Some MC results with three different numbers of function calls. diff. {#tbl:MC} As can be seen, $\sigma$ is always of the same order of magnitude of diff, -except for very low numbers of function calls. Even with \SI{5e7}{} calls, +except for very low numbers of function calls. Even with \num{5e7} calls, $I^{\text{oss}}$ still differs from $I$ at the fifth decimal digit, meaning that this method shows a really slow convergence. In fact, since the $\sigma$s dependence on the number $C$ of function calls is confirmed: $$ \begin{cases} - \sigma_1 = \SI{6.95569e-4}{} \longleftrightarrow C_1 = \SI{5e6}{} \\ - \sigma_2 = \SI{6.95809e-5}{} \longleftrightarrow C_1 = \SI{5e8}{} + \sigma_1 = \num{6.95569e-4} \longleftrightarrow C_1 = \num{5e6} \\ + \sigma_2 = \num{6.95809e-5} \longleftrightarrow C_1 = \num{5e8} \end{cases} $$ @@ -112,7 +112,7 @@ $$ if an error of $\sim 1^{-n}$ is required, a number $\propto 10^{2n}$ of function calls should be executed, meaning that for $\sigma \sim 1^{-10} -\rightarrow C = \SI{1e20}{}$, which would be impractical. +\rightarrow C = \num{1e20}$, which would be impractical. ## Stratified sampling @@ -229,11 +229,11 @@ the improvement with respect to the Plain MC technique (in red) is appreciable. --------------------------------------------------------------------------- calls $I^{\text{oss}}$ $\sigma$ diff ------------------ ------------------ ------------------ ------------------ -\SI{5e5}{} 1.7182850738 0.0000021829 0.0000032453 +\num{5e5} 1.7182850738 0.0000021829 0.0000032453 -\SI{5e6}{} 1.7182819143 0.0000001024 0.0000000858 +\num{5e6} 1.7182819143 0.0000001024 0.0000000858 -\SI{5e7}{} 1.7182818221 0.0000000049 0.0000000064 +\num{5e7} 1.7182818221 0.0000000049 0.0000000064 --------------------------------------------------------------------------- Table: MISER results with different numbers of function calls. Differences @@ -381,11 +381,11 @@ in @fig:MI_VE and some of them are listed in @tbl:VEGAS. ---------------------------------------------------------------------------------------------- calls $I^{\text{oss}}$ $\sigma$ diff $\chi_r^2$ ------------------ ------------------ ------------------ ------------------ ------------------ -\SI{5e5}{} 1.7182818281 0.0000000012 0.0000000004 1.457 - -\SI{5e6}{} 1.7182818284 0.0000000000 0.0000000001 0.632 - -\SI{5e7}{} 1.7182818285 0.0000000000 0.0000000000 0.884 +\num{5e5} 1.7182818281 0.0000000012 0.0000000004 1.457 + +\num{5e6} 1.7182818284 0.0000000000 0.0000000001 0.632 + +\num{5e7} 1.7182818285 0.0000000000 0.0000000000 0.884 ---------------------------------------------------------------------------------------------- Table: Some VEGAS results with different numbers of @@ -395,8 +395,8 @@ As can be appreciated in @fig:MI_VE, the VEGAS algorithm manages to compute the integral value in a most accurate way with respect to MISER. The $\chi_r^2$ turns out to be close enough to 1 to guarantee a good estimation of $I$, goodness which is also confirmed by the very small difference between estimation -and exact value, as shown in @tbl:VEGAS: with a number of \SI{5e7}{} of function -calls, the difference is smaller than \SI{1e-10}{}. +and exact value, as shown in @tbl:VEGAS: with a number of \num{5e7} of function +calls, the difference is smaller than \num{1e-10}. ![Only the most accurate results are shown in order to stress the differences between VEGAS (in gray) and MISER (in black) methods diff --git a/notes/sections/6.md b/notes/sections/6.md index 32d3b8f..deee43a 100644 --- a/notes/sections/6.md +++ b/notes/sections/6.md @@ -569,14 +569,14 @@ merely a fact of floating-points precision) and the best result is obtained for $r = 2$, meaning that the convergence of the RL algorithm is really fast and this is due to the fact that the histogram was modified pretty poorly. In @fig:rless-0.5, the curve starts to flatten at about 10 rounds, whereas in -@fig:rless-1 a minimum occurs around \SI{5e3}{} rounds, meaning that, whit such a +@fig:rless-1 a minimum occurs around \num{5e3} rounds, meaning that, whit such a large kernel, the convergence is very slow, even if the best results are close to the one found for $\sigma = 0.5$. The following $r$s were chosen as the most fitted: \begin{align*} \sigma = 0.1 \, \Delta \theta &\thus n^{\text{best}} = 2 \\ \sigma = 0.5 \, \Delta \theta &\thus n^{\text{best}} = 10 \\ - \sigma = 1 \, \Delta \theta &\thus n^{\text{best}} = \SI{5e3}{} + \sigma = 1 \, \Delta \theta &\thus n^{\text{best}} = \num{5e3} \end{align*} Note the difference between @fig:rless-0.1 and the plots resulting from $\sigma = @@ -625,15 +625,15 @@ order to check if an improvement was truly achieved. Results are shown in @fig:emd-noiseless. As expected, the FFT results are always of the same order of magnitude, -\SI{1e-15}{}, independently from the kernel width, whereas the RL deconvolution -results change a lot, ranging from \SI{1e-16}{} for $\sigma = 0.1 \, \Delta -\theta$ to \SI{1e-4}{} for $\sigma = \Delta \theta$. +\num{1e-15}, independently from the kernel width, whereas the RL deconvolution +results change a lot, ranging from \num{1e-16} for $\sigma = 0.1 \, \Delta +\theta$ to \num{1e-4} for $\sigma = \Delta \theta$. The first result was quite unexpected: for very low values of $\sigma$, the RL routine gives better results with respect to the FFT. This is because of the math which lies beneath the two methods: apparently, the RL technique is less subject to round-off errors. Then, as regards the comparison with the convolved signal, which shows always -an EMD of \SI{1e-2}{}, both RL and FFT always return results closer to the +an EMD of \num{1e-2}, both RL and FFT always return results closer to the original signal, meaning that the deconvolution is working. @@ -675,8 +675,8 @@ Hence, the most fitting values were chosen as: \end{align*} As regards the order of magnitude, as expected, the more $\sigma_n$ increases, -the more the EMD rises, ranging from $\sim$ \SI{2e-4}{} in @fig:rnoise-0.005 -to $\sim$ \SI{1.5e-3}{} in @fig:rnoise-0.05. +the more the EMD rises, ranging from $\sim$ \num{2e-4} in @fig:rnoise-0.005 +to $\sim$ \num{1.5e-3} in @fig:rnoise-0.05. Since the FFT is no more able to return the original signal as close as before, it is no more assumed to be a reference point. In fact, as shown in @fig:noisy, the FFT algorithm, when dealing with noisy signals whose noise shape is