diff --git a/doc/pub/Introduction/html/Introduction-bs.html b/doc/pub/Introduction/html/Introduction-bs.html index 2cee96b01..bfac8f3e2 100644 --- a/doc/pub/Introduction/html/Introduction-bs.html +++ b/doc/pub/Introduction/html/Introduction-bs.html @@ -43,29 +43,23 @@ Automatically generated HTML file from DocOnce source {'highest level': 2, 'sections': [('Introduction', 2, None, '___sec0'), ('Learning outcomes', 2, None, '___sec1'), - ('Machine Learning, short overview', 2, None, '___sec2'), ('Machine Learning, a small (and probably biased) introduction', 2, None, - '___sec3'), - ('Machine Learning, an extremely rich field', 2, None, '___sec4'), - ('A multidisciplinary approach', 2, None, '___sec5'), - ('Types of Machine Learning', 2, None, '___sec6'), - ('Essential elements of ML', 2, None, '___sec7'), - ('An optimization/minimization problem', 2, None, '___sec8'), - ('A Frequentist approach to data analysis', 2, None, '___sec9'), - ('What is a good model?', 2, None, '___sec10'), - ('What is a good model? Can we define it?', 2, None, '___sec11'), - ('Practicalities, choice of programming language and other ' - 'computational issues', - 2, - None, - '___sec12'), - ('Choice of Programming Language', 2, None, '___sec13'), + '___sec2'), + ('Machine Learning, an extremely rich field', 2, None, '___sec3'), + ('A multidisciplinary approach', 2, None, '___sec4'), + ('Types of Machine Learning', 2, None, '___sec5'), + ('Essential elements of ML', 2, None, '___sec6'), + ('An optimization/minimization problem', 2, None, '___sec7'), + ('A Frequentist approach to data analysis', 2, None, '___sec8'), + ('What is a good model?', 2, None, '___sec9'), + ('What is a good model? Can we define it?', 2, None, '___sec10'), + ('Choice of Programming Language', 2, None, '___sec11'), ('Data handling, machine learning and ethical aspects', 2, None, - '___sec14')]} + '___sec12')]} end of tocinfo --> @@ -75,7 +69,7 @@ end of tocinfo --> -

+The latter distribution is used to generate random numbers. For other PDFs, one needs normally a mapping from this distribution to say for example the exponential distribution. @@ -478,7 +438,7 @@ plt.show()

  • 18
  • 19
  • ...
  • -
  • 75
  • +
  • 76
  • »
  • diff --git a/doc/pub/Statistics/html/._Statistics-bs010.html b/doc/pub/Statistics/html/._Statistics-bs010.html index 05666b1f4..a9bb83621 100644 --- a/doc/pub/Statistics/html/._Statistics-bs010.html +++ b/doc/pub/Statistics/html/._Statistics-bs010.html @@ -6,6 +6,7 @@ Automatically generated HTML file from DocOnce source + Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis @@ -55,43 +56,40 @@ $(function () { @@ -296,80 +298,81 @@ MathJax.Hub.Config({ @@ -385,16 +388,70 @@ MathJax.Hub.Config({ -

    Exponential distribution

    +

    Gaussian distribution

    -Another important distribution in science is the exponential distribution +The second one is the Gaussian Distribution $$ \begin{equation*} -p(x) = \alpha\exp{-(\alpha x)}. +p(x) = \frac{1}{\sigma\sqrt{2\pi}} \exp{(-\frac{(x-\mu)^2}{2\sigma^2})}, \end{equation*} $$ + +with mean value \( \mu \) and standard deviation \( \sigma \). If \( \mu=0 \) and \( \sigma=1 \), it is normally called the standard normal distribution +$$ +\begin{equation*} +p(x) = \frac{1}{\sqrt{2\pi}} \exp{(-\frac{x^2}{2})}, +\end{equation*} +$$ + +

    +The following simple Python code plots the above distribution for different values of \( \mu \) and \( \sigma \). +

    + + +

    +

    @@ -425,7 +482,7 @@ $$
  • 19
  • 20
  • ...
  • -
  • 75
  • +
  • 76
  • »
  • diff --git a/doc/pub/Statistics/html/._Statistics-bs011.html b/doc/pub/Statistics/html/._Statistics-bs011.html index 1235cd6b5..df44d116c 100644 --- a/doc/pub/Statistics/html/._Statistics-bs011.html +++ b/doc/pub/Statistics/html/._Statistics-bs011.html @@ -6,6 +6,7 @@ Automatically generated HTML file from DocOnce source + Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis @@ -55,43 +56,40 @@ $(function () { @@ -296,80 +298,81 @@ MathJax.Hub.Config({ @@ -385,29 +388,14 @@ MathJax.Hub.Config({ -

    Expectation values

    +

    Exponential distribution

    -Let \( h(x) \) be an arbitrary continuous function on the domain of the stochastic -variable \( X \) whose PDF is \( p(x) \). We define the expectation value -of \( h \) with respect to \( p \) as follows - -$$ -\begin{equation} -\langle h \rangle_X \equiv \int\! h(x)p(x)\,dx -\tag{2} -\end{equation} -$$ - -Whenever the PDF is known implicitly, like in this case, we will drop -the index \( X \) for clarity. -A particularly useful class of special expectation values are the -moments. The \( n \)-th moment of the PDF \( p \) is defined as -follows +Another important distribution in science is the exponential distribution $$ \begin{equation*} -\langle x^n \rangle \equiv \int\! x^n p(x)\,dx +p(x) = \alpha\exp{-(\alpha x)}. \end{equation*} $$

    @@ -440,7 +428,7 @@ $$
  • 20
  • 21
  • ...
  • -
  • 75
  • +
  • 76
  • »
  • diff --git a/doc/pub/Statistics/html/._Statistics-bs012.html b/doc/pub/Statistics/html/._Statistics-bs012.html index c15ba8ea1..346338464 100644 --- a/doc/pub/Statistics/html/._Statistics-bs012.html +++ b/doc/pub/Statistics/html/._Statistics-bs012.html @@ -6,6 +6,7 @@ Automatically generated HTML file from DocOnce source + Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis @@ -55,43 +56,40 @@ $(function () { @@ -296,80 +298,81 @@ MathJax.Hub.Config({ @@ -385,29 +388,31 @@ MathJax.Hub.Config({ -

    Stochastic variables and the main concepts, mean values

    +

    Expectation values

    -The zero-th moment \( \langle 1\rangle \) is just the normalization condition of -\( p \). The first moment, \( \langle x\rangle \), is called the mean of \( p \) -and often denoted by the letter \( \mu \) +Let \( h(x) \) be an arbitrary continuous function on the domain of the stochastic +variable \( X \) whose PDF is \( p(x) \). We define the expectation value +of \( h \) with respect to \( p \) as follows + $$ -\begin{equation*} -\langle x\rangle = \mu \equiv \int x p(x)dx, -\end{equation*} +\begin{equation} +\langle h \rangle_X \equiv \int\! h(x)p(x)\,dx +\tag{2} +\end{equation} $$ -for a continuous distribution and +Whenever the PDF is known implicitly, like in this case, we will drop +the index \( X \) for clarity. +A particularly useful class of special expectation values are the +moments. The \( n \)-th moment of the PDF \( p \) is defined as +follows $$ \begin{equation*} -\langle x\rangle = \mu \equiv \sum_{i=1}^N x_i p(x_i), +\langle x^n \rangle \equiv \int\! x^n p(x)\,dx \end{equation*} $$ - -for a discrete distribution. -Qualitatively it represents the centroid or the average value of the -PDF and is therefore simply called the expectation value of \( p(x) \).

    @@ -438,7 +443,7 @@ PDF and is therefore simply called the expectation value of \( p(x) \).
  • 21
  • 22
  • ...
  • -
  • 75
  • +
  • 76
  • »
  • diff --git a/doc/pub/Statistics/html/._Statistics-bs013.html b/doc/pub/Statistics/html/._Statistics-bs013.html index e25313478..0b4df3dc3 100644 --- a/doc/pub/Statistics/html/._Statistics-bs013.html +++ b/doc/pub/Statistics/html/._Statistics-bs013.html @@ -6,6 +6,7 @@ Automatically generated HTML file from DocOnce source + Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis @@ -55,43 +56,40 @@ $(function () { @@ -296,80 +298,81 @@ MathJax.Hub.Config({ @@ -385,37 +388,29 @@ MathJax.Hub.Config({ -

    Stochastic variables and the main concepts, central moments, the variance

    +

    Stochastic variables and the main concepts, mean values

    - -

    -A special version of the moments is the set of central moments, the n-th central moment defined as +The zero-th moment \( \langle 1\rangle \) is just the normalization condition of +\( p \). The first moment, \( \langle x\rangle \), is called the mean of \( p \) +and often denoted by the letter \( \mu \) $$ \begin{equation*} -\langle (x-\langle x\rangle )^n\rangle \equiv \int\! (x-\langle x\rangle)^n p(x)\,dx +\langle x\rangle = \mu \equiv \int x p(x)dx, \end{equation*} $$ -The zero-th and first central moments are both trivial, equal \( 1 \) and -\( 0 \), respectively. But the second central moment, known as the -variance of \( p \), is of particular interest. For the stochastic -variable \( X \), the variance is denoted as \( \sigma^2_X \) or \( \mathrm{Var}(X) \) +for a continuous distribution and $$ -\begin{align*} -\sigma^2_X &=\mathrm{Var}(X) = \langle (x-\langle x\rangle)^2\rangle = -\int (x-\langle x\rangle)^2 p(x)dx\\ -& = \int\left(x^2 - 2 x \langle x\rangle^{2} +\langle x\rangle^2\right)p(x)dx\\ -& = \langle x^2\rangle - 2 \langle x\rangle\langle x\rangle + \langle x\rangle^2\\ -& = \langle x^2 \rangle - \langle x\rangle^2 -\end{align*} +\begin{equation*} +\langle x\rangle = \mu \equiv \sum_{i=1}^N x_i p(x_i), +\end{equation*} $$ -The square root of the variance, \( \sigma =\sqrt{\langle (x-\langle x\rangle)^2\rangle} \) is called the -standard deviation of \( p \). It is the RMS (root-mean-square) -value of the deviation of the PDF from its mean value, interpreted -qualitatively as the "spread" of \( p \) around its mean. +for a discrete distribution. +Qualitatively it represents the centroid or the average value of the +PDF and is therefore simply called the expectation value of \( p(x) \).

    @@ -446,7 +441,7 @@ qualitatively as the "spread" of \( p \) around its mean.
  • 22
  • 23
  • ...
  • -
  • 75
  • +
  • 76
  • »
  • diff --git a/doc/pub/Statistics/html/._Statistics-bs014.html b/doc/pub/Statistics/html/._Statistics-bs014.html index 20db32c95..1e73e7007 100644 --- a/doc/pub/Statistics/html/._Statistics-bs014.html +++ b/doc/pub/Statistics/html/._Statistics-bs014.html @@ -6,6 +6,7 @@ Automatically generated HTML file from DocOnce source + Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis @@ -55,43 +56,40 @@ $(function () { @@ -296,80 +298,81 @@ MathJax.Hub.Config({ @@ -385,37 +388,37 @@ MathJax.Hub.Config({ -

    Probability Distribution Functions

    +

    Stochastic variables and the main concepts, central moments, the variance

    -The following table collects properties of probability distribution functions. -In our notation we reserve the label \( p(x) \) for the probability of a certain event, -while \( P(x) \) is the cumulative probability. +A special version of the moments is the set of central moments, the n-th central moment defined as +$$ +\begin{equation*} +\langle (x-\langle x\rangle )^n\rangle \equiv \int\! (x-\langle x\rangle)^n p(x)\,dx +\end{equation*} +$$ -

    +The zero-th and first central moments are both trivial, equal \( 1 \) and +\( 0 \), respectively. But the second central moment, known as the +variance of \( p \), is of particular interest. For the stochastic +variable \( X \), the variance is denoted as \( \sigma^2_X \) or \( \mathrm{Var}(X) \) +$$ +\begin{align*} +\sigma^2_X &=\mathrm{Var}(X) = \langle (x-\langle x\rangle)^2\rangle = +\int (x-\langle x\rangle)^2 p(x)dx\\ +& = \int\left(x^2 - 2 x \langle x\rangle^{2} +\langle x\rangle^2\right)p(x)dx\\ +& = \langle x^2\rangle - 2 \langle x\rangle\langle x\rangle + \langle x\rangle^2\\ +& = \langle x^2 \rangle - \langle x\rangle^2 +\end{align*} +$$ -

    -
    - - - - - - - - - - - - - -
    Discrete PDF Continuous PDF
    Domain \( \left\{x_1, x_2, x_3, \dots, x_N\right\} \) \( [a,b] \)
    Probability \( p(x_i) \) \( p(x)dx \)
    Cumulative \( P_i=\sum_{l=1}^ip(x_l) \) \( P(x)=\int_a^xp(t)dt \)
    Positivity \( 0 \le p(x_i) \le 1 \) \( p(x) \ge 0 \)
    Positivity \( 0 \le P_i \le 1 \) \( 0 \le P(x) \le 1 \)
    Monotonic \( P_i \ge P_j \) if \( x_i \ge x_j \) \( P(x_i) \ge P(x_j) \) if \( x_i \ge x_j \)
    Normalization \( P_N=1 \) \( P(b)=1 \)
    -
    -
    -

    +The square root of the variance, \( \sigma =\sqrt{\langle (x-\langle x\rangle)^2\rangle} \) is called the +standard deviation of \( p \). It is the RMS (root-mean-square) +value of the deviation of the PDF from its mean value, interpreted +qualitatively as the "spread" of \( p \) around its mean.

    @@ -446,7 +449,7 @@ while \( P(x) \) is the cumulative probability.
  • 23
  • 24
  • ...
  • -
  • 75
  • +
  • 76
  • »
  • diff --git a/doc/pub/Statistics/html/._Statistics-bs015.html b/doc/pub/Statistics/html/._Statistics-bs015.html index 95d080b23..2ba7757ec 100644 --- a/doc/pub/Statistics/html/._Statistics-bs015.html +++ b/doc/pub/Statistics/html/._Statistics-bs015.html @@ -6,6 +6,7 @@ Automatically generated HTML file from DocOnce source + Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis @@ -55,43 +56,40 @@ $(function () { @@ -296,80 +298,81 @@ MathJax.Hub.Config({ @@ -389,24 +392,33 @@ MathJax.Hub.Config({

    -With a PDF we can compute expectation values of selected quantities such as -$$ -\begin{equation*} - \langle x^k\rangle=\sum_{i=1}^{N}x_i^kp(x_i), -\end{equation*} -$$ +

    +The following table collects properties of probability distribution functions. +In our notation we reserve the label \( p(x) \) for the probability of a certain event, +while \( P(x) \) is the cumulative probability. -if we have a discrete PDF or +

    -$$ -\begin{equation*} - \langle x^k\rangle=\int_a^b x^kp(x)dx, -\end{equation*} -$$ - -in the case of a continuous PDF. We have already defined the mean value \( \mu \) -and the variance \( \sigma^2 \). +

    +
    + + + + + + + + + + + + + +
    Discrete PDF Continuous PDF
    Domain \( \left\{x_1, x_2, x_3, \dots, x_N\right\} \) \( [a,b] \)
    Probability \( p(x_i) \) \( p(x)dx \)
    Cumulative \( P_i=\sum_{l=1}^ip(x_l) \) \( P(x)=\int_a^xp(t)dt \)
    Positivity \( 0 \le p(x_i) \le 1 \) \( p(x) \ge 0 \)
    Positivity \( 0 \le P_i \le 1 \) \( 0 \le P(x) \le 1 \)
    Monotonic \( P_i \ge P_j \) if \( x_i \ge x_j \) \( P(x_i) \ge P(x_j) \) if \( x_i \ge x_j \)
    Normalization \( P_N=1 \) \( P(b)=1 \)
    +
    +
    +

    @@ -437,7 +449,7 @@ and the variance \( \sigma^2 \).
  • 24
  • 25
  • ...
  • -
  • 75
  • +
  • 76
  • »
  • diff --git a/doc/pub/Statistics/html/._Statistics-bs016.html b/doc/pub/Statistics/html/._Statistics-bs016.html index 6a0dd83c7..662f48413 100644 --- a/doc/pub/Statistics/html/._Statistics-bs016.html +++ b/doc/pub/Statistics/html/._Statistics-bs016.html @@ -6,6 +6,7 @@ Automatically generated HTML file from DocOnce source + Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis @@ -55,43 +56,40 @@ $(function () { @@ -296,80 +298,81 @@ MathJax.Hub.Config({ @@ -385,48 +388,32 @@ MathJax.Hub.Config({ -

    The three famous Probability Distribution Functions

    +

    Probability Distribution Functions

    +With a PDF we can compute expectation values of selected quantities such as -

    -There are at least three PDFs which one may encounter. These are the - -

    -Uniform distribution -$$ -\begin{equation*} -p(x)=\frac{1}{b-a}\Theta(x-a)\Theta(b-x), -\end{equation*} -$$ - -yielding probabilities different from zero in the interval \( [a,b] \). - -

    -The exponential distribution -$$ -\begin{equation*} -p(x)=\alpha \exp{(-\alpha x)}, -\end{equation*} -$$ - -yielding probabilities different from zero in the interval \( [0,\infty) \) and with mean value -$$ -\begin{equation*} -\mu = \int_0^{\infty}xp(x)dx=\int_0^{\infty}x\alpha \exp{(-\alpha x)}dx=\frac{1}{\alpha}, -\end{equation*} -$$ -

    -
    - -with variance $$ \begin{equation*} -\sigma^2=\int_0^{\infty}x^2p(x)dx-\mu^2 = \frac{1}{\alpha^2}. + \langle x^k\rangle=\sum_{i=1}^{N}x_i^kp(x_i), \end{equation*} $$ +if we have a discrete PDF or + +$$ +\begin{equation*} + \langle x^k\rangle=\int_a^b x^kp(x)dx, +\end{equation*} +$$ + +in the case of a continuous PDF. We have already defined the mean value \( \mu \) +and the variance \( \sigma^2 \). +
    + + +

    @@ -453,7 +440,7 @@ $$

  • 25
  • 26
  • ...
  • -
  • 75
  • +
  • 76
  • »
  • diff --git a/doc/pub/Statistics/html/._Statistics-bs017.html b/doc/pub/Statistics/html/._Statistics-bs017.html index 3a16b71ac..2fe9cd5d9 100644 --- a/doc/pub/Statistics/html/._Statistics-bs017.html +++ b/doc/pub/Statistics/html/._Statistics-bs017.html @@ -6,6 +6,7 @@ Automatically generated HTML file from DocOnce source + Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis @@ -55,43 +56,40 @@ $(function () { @@ -296,80 +298,81 @@ MathJax.Hub.Config({ @@ -385,36 +388,47 @@ MathJax.Hub.Config({ -

    Probability Distribution Functions, the normal distribution

    +

    The three famous Probability Distribution Functions

    -Finally, we have the so-called univariate normal distribution, or just the normal distribution + +

    +There are at least three PDFs which one may encounter. These are the + +

    +Uniform distribution $$ -\begin{equation*} -p(x)=\frac{1}{b\sqrt{2\pi}}\exp{\left(-\frac{(x-a)^2}{2b^2}\right)} +\begin{equation*} +p(x)=\frac{1}{b-a}\Theta(x-a)\Theta(b-x), \end{equation*} $$ -with probabilities different from zero in the interval \( (-\infty,\infty) \). -The integral \( \int_{-\infty}^{\infty}\exp{\left(-(x^2\right)}dx \) appears in many calculations, its value -is \( \sqrt{\pi} \), a result we will need when we compute the mean value and the variance. -The mean value is +yielding probabilities different from zero in the interval \( [a,b] \). + +

    +The exponential distribution $$ -\begin{equation*} - \mu = \int_0^{\infty}xp(x)dx=\frac{1}{b\sqrt{2\pi}}\int_{-\infty}^{\infty}x \exp{\left(-\frac{(x-a)^2}{2b^2}\right)}dx, +\begin{equation*} +p(x)=\alpha \exp{(-\alpha x)}, \end{equation*} $$ -which becomes with a suitable change of variables +yielding probabilities different from zero in the interval \( [0,\infty) \) and with mean value $$ -\begin{equation*} - \mu =\frac{1}{b\sqrt{2\pi}}\int_{-\infty}^{\infty}b\sqrt{2}(a+b\sqrt{2}y)\exp{-y^2}dy=a. +\begin{equation*} +\mu = \int_0^{\infty}xp(x)dx=\int_0^{\infty}x\alpha \exp{(-\alpha x)}dx=\frac{1}{\alpha}, \end{equation*} $$

    +with variance +$$ +\begin{equation*} +\sigma^2=\int_0^{\infty}x^2p(x)dx-\mu^2 = \frac{1}{\alpha^2}. +\end{equation*} +$$

    @@ -442,7 +456,7 @@ $$

  • 26
  • 27
  • ...
  • -
  • 75
  • +
  • 76
  • »
  • diff --git a/doc/pub/Statistics/html/._Statistics-bs018.html b/doc/pub/Statistics/html/._Statistics-bs018.html index f0fc25bed..1883777d5 100644 --- a/doc/pub/Statistics/html/._Statistics-bs018.html +++ b/doc/pub/Statistics/html/._Statistics-bs018.html @@ -6,6 +6,7 @@ Automatically generated HTML file from DocOnce source + Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis @@ -55,43 +56,40 @@ $(function () { @@ -296,80 +298,81 @@ MathJax.Hub.Config({ @@ -389,31 +392,28 @@ MathJax.Hub.Config({

    -Similarly, the variance becomes +Finally, we have the so-called univariate normal distribution, or just the normal distribution $$ -\begin{equation*} - \sigma^2 = \frac{1}{b\sqrt{2\pi}}\int_{-\infty}^{\infty}(x-\mu)^2 \exp{\left(-\frac{(x-a)^2}{2b^2}\right)}dx, +\begin{equation*} +p(x)=\frac{1}{b\sqrt{2\pi}}\exp{\left(-\frac{(x-a)^2}{2b^2}\right)} \end{equation*} $$ -and inserting the mean value and performing a variable change we obtain - +with probabilities different from zero in the interval \( (-\infty,\infty) \). +The integral \( \int_{-\infty}^{\infty}\exp{\left(-(x^2\right)}dx \) appears in many calculations, its value +is \( \sqrt{\pi} \), a result we will need when we compute the mean value and the variance. +The mean value is $$ \begin{equation*} - \sigma^2 = \frac{1}{b\sqrt{2\pi}}\int_{-\infty}^{\infty}b\sqrt{2}(b\sqrt{2}y)^2\exp{\left(-y^2\right)}dy= -\frac{2b^2}{\sqrt{\pi}}\int_{-\infty}^{\infty}y^2\exp{\left(-y^2\right)}dy, + \mu = \int_0^{\infty}xp(x)dx=\frac{1}{b\sqrt{2\pi}}\int_{-\infty}^{\infty}x \exp{\left(-\frac{(x-a)^2}{2b^2}\right)}dx, \end{equation*} $$ -and performing a final integration by parts we obtain the well-known result \( \sigma^2=b^2 \). -It is useful to introduce the standard normal distribution as well, defined by \( \mu=a=0 \), viz. a distribution -centered around zero and with a variance \( \sigma^2=1 \), leading to - +which becomes with a suitable change of variables $$ -\begin{equation} - p(x)=\frac{1}{\sqrt{2\pi}}\exp{\left(-\frac{x^2}{2}\right)}. -\tag{3} -\end{equation} +\begin{equation*} + \mu =\frac{1}{b\sqrt{2\pi}}\int_{-\infty}^{\infty}b\sqrt{2}(a+b\sqrt{2}y)\exp{-y^2}dy=a. +\end{equation*} $$

    @@ -445,7 +445,7 @@ $$
  • 27
  • 28
  • ...
  • -
  • 75
  • +
  • 76
  • »
  • diff --git a/doc/pub/Statistics/html/._Statistics-bs019.html b/doc/pub/Statistics/html/._Statistics-bs019.html index a7a789348..152c66df4 100644 --- a/doc/pub/Statistics/html/._Statistics-bs019.html +++ b/doc/pub/Statistics/html/._Statistics-bs019.html @@ -6,6 +6,7 @@ Automatically generated HTML file from DocOnce source + Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis @@ -55,43 +56,40 @@ $(function () { @@ -296,80 +298,81 @@ MathJax.Hub.Config({ @@ -385,23 +388,36 @@ MathJax.Hub.Config({ -

    Probability Distribution Functions, the cumulative distribution

    +

    Probability Distribution Functions, the normal distribution

    - -

    -The exponential and uniform distributions have simple cumulative functions, -whereas the normal distribution does not, being proportional to the so-called -error function \( erf(x) \), given by - +Similarly, the variance becomes $$ -\begin{equation*} -P(x) = \frac{1}{\sqrt{2\pi}}\int_{-\infty}^x\exp{\left(-\frac{t^2}{2}\right)}dt, +\begin{equation*} + \sigma^2 = \frac{1}{b\sqrt{2\pi}}\int_{-\infty}^{\infty}(x-\mu)^2 \exp{\left(-\frac{(x-a)^2}{2b^2}\right)}dx, \end{equation*} $$ -which is difficult to evaluate in a quick way. +and inserting the mean value and performing a variable change we obtain + +$$ +\begin{equation*} + \sigma^2 = \frac{1}{b\sqrt{2\pi}}\int_{-\infty}^{\infty}b\sqrt{2}(b\sqrt{2}y)^2\exp{\left(-y^2\right)}dy= +\frac{2b^2}{\sqrt{\pi}}\int_{-\infty}^{\infty}y^2\exp{\left(-y^2\right)}dy, +\end{equation*} +$$ + +and performing a final integration by parts we obtain the well-known result \( \sigma^2=b^2 \). +It is useful to introduce the standard normal distribution as well, defined by \( \mu=a=0 \), viz. a distribution +centered around zero and with a variance \( \sigma^2=1 \), leading to + +$$ +\begin{equation} + p(x)=\frac{1}{\sqrt{2\pi}}\exp{\left(-\frac{x^2}{2}\right)}. +\tag{3} +\end{equation} +$$

    @@ -432,7 +448,7 @@ which is difficult to evaluate in a quick way.
  • 28
  • 29
  • ...
  • -
  • 75
  • +
  • 76
  • »
  • diff --git a/doc/pub/Statistics/html/._Statistics-bs020.html b/doc/pub/Statistics/html/._Statistics-bs020.html index bddf2f667..152806b76 100644 --- a/doc/pub/Statistics/html/._Statistics-bs020.html +++ b/doc/pub/Statistics/html/._Statistics-bs020.html @@ -6,6 +6,7 @@ Automatically generated HTML file from DocOnce source + Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis @@ -55,43 +56,40 @@ $(function () { @@ -296,80 +298,81 @@ MathJax.Hub.Config({ @@ -385,30 +388,23 @@ MathJax.Hub.Config({ -

    Probability Distribution Functions, other important distribution

    +

    Probability Distribution Functions, the cumulative distribution

    -Some other PDFs which one encounters often in the natural sciences are the binomial distribution +The exponential and uniform distributions have simple cumulative functions, +whereas the normal distribution does not, being proportional to the so-called +error function \( erf(x) \), given by + $$ -\begin{equation*} - p(x) = \left(\begin{array}{c} n \\ x\end{array}\right)y^x(1-y)^{n-x} \hspace{0.5cm}x=0,1,\dots,n, +\begin{equation*} +P(x) = \frac{1}{\sqrt{2\pi}}\int_{-\infty}^x\exp{\left(-\frac{t^2}{2}\right)}dt, \end{equation*} $$ -where \( y \) is the probability for a specific event, such as the tossing of a coin or moving left or right -in case of a random walker. Note that \( x \) is a discrete stochastic variable. - -

    -The sequence of binomial trials is characterized by the following definitions - -

    +which is difficult to evaluate in a quick way.
    @@ -439,7 +435,7 @@ The sequence of binomial trials is characterized by the following definitions
  • 29
  • 30
  • ...
  • -
  • 75
  • +
  • 76
  • »
  • diff --git a/doc/pub/Statistics/html/._Statistics-bs021.html b/doc/pub/Statistics/html/._Statistics-bs021.html index b81b133a7..e397783f7 100644 --- a/doc/pub/Statistics/html/._Statistics-bs021.html +++ b/doc/pub/Statistics/html/._Statistics-bs021.html @@ -6,6 +6,7 @@ Automatically generated HTML file from DocOnce source + Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis @@ -55,43 +56,40 @@ $(function () { @@ -296,80 +298,81 @@ MathJax.Hub.Config({ @@ -385,56 +388,33 @@ MathJax.Hub.Config({ -

    Probability Distribution Functions, the binomial distribution

    +

    Probability Distribution Functions, other important distribution

    -In order to compute the mean and variance we need to recall Newton's binomial -formula +Some other PDFs which one encounters often in the natural sciences are the binomial distribution $$ \begin{equation*} - (a+b)^m=\sum_{n=0}^m \left(\begin{array}{c} m \\ n\end{array}\right)a^nb^{m-n}, + p(x) = \left(\begin{array}{c} n \\ x\end{array}\right)y^x(1-y)^{n-x} \hspace{0.5cm}x=0,1,\dots,n, \end{equation*} $$ -which can be used to show that +where \( y \) is the probability for a specific event, such as the tossing of a coin or moving left or right +in case of a random walker. Note that \( x \) is a discrete stochastic variable. -$$ -\begin{equation*} -\sum_{x=0}^n\left(\begin{array}{c} n \\ x\end{array}\right)y^x(1-y)^{n-x} = (y+1-y)^n = 1, -\end{equation*} -$$ +

    +The sequence of binomial trials is characterized by the following definitions -the PDF is normalized to one. -The mean value is -$$ -\begin{equation*} -\mu = \sum_{x=0}^n x\left(\begin{array}{c} n \\ x\end{array}\right)y^x(1-y)^{n-x} = -\sum_{x=0}^n x\frac{n!}{x!(n-x)!}y^x(1-y)^{n-x}, -\end{equation*} -$$ - -resulting in -$$ -\begin{equation*} -\mu = -\sum_{x=0}^n x\frac{(n-1)!}{(x-1)!(n-1-(x-1))!}y^{x-1}(1-y)^{n-1-(x-1)}, -\end{equation*} -$$ - -which we rewrite as - -$$ -\begin{equation*} -\mu=ny\sum_{\nu=0}^n\left(\begin{array}{c} n-1 \\ \nu\end{array}\right)y^{\nu}(1-y)^{n-1-\nu} =ny(y+1-y)^{n-1}=ny. -\end{equation*} -$$ +

    -The variance is slightly trickier to get. It reads \( \sigma^2=ny(1-y) \).

    @@ -462,7 +442,7 @@ The variance is slightly trickier to get. It reads \( \sigma^2=ny(1-y) \).

  • 30
  • 31
  • ...
  • -
  • 75
  • +
  • 76
  • »
  • diff --git a/doc/pub/Statistics/html/._Statistics-bs022.html b/doc/pub/Statistics/html/._Statistics-bs022.html index b7be84176..e9e83aed2 100644 --- a/doc/pub/Statistics/html/._Statistics-bs022.html +++ b/doc/pub/Statistics/html/._Statistics-bs022.html @@ -6,6 +6,7 @@ Automatically generated HTML file from DocOnce source + Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis @@ -55,43 +56,40 @@ $(function () { @@ -296,80 +298,81 @@ MathJax.Hub.Config({ @@ -385,33 +388,56 @@ MathJax.Hub.Config({ -

    Probability Distribution Functions, Poisson's distribution

    +

    Probability Distribution Functions, the binomial distribution

    -Another important distribution with discrete stochastic variables \( x \) is -the Poisson model, which resembles the exponential distribution and reads +In order to compute the mean and variance we need to recall Newton's binomial +formula $$ \begin{equation*} - p(x) = \frac{\lambda^x}{x!} e^{-\lambda} \hspace{0.5cm}x=0,1,\dots,;\lambda > 0. + (a+b)^m=\sum_{n=0}^m \left(\begin{array}{c} m \\ n\end{array}\right)a^nb^{m-n}, \end{equation*} $$ -In this case both the mean value and the variance are easier to calculate, +which can be used to show that $$ \begin{equation*} -\mu = \sum_{x=0}^{\infty} x \frac{\lambda^x}{x!} e^{-\lambda} = \lambda e^{-\lambda}\sum_{x=1}^{\infty} -\frac{\lambda^{x-1}}{(x-1)!}=\lambda, +\sum_{x=0}^n\left(\begin{array}{c} n \\ x\end{array}\right)y^x(1-y)^{n-x} = (y+1-y)^n = 1, \end{equation*} $$ -and the variance is \( \sigma^2=\lambda \). +the PDF is normalized to one. +The mean value is +$$ +\begin{equation*} +\mu = \sum_{x=0}^n x\left(\begin{array}{c} n \\ x\end{array}\right)y^x(1-y)^{n-x} = +\sum_{x=0}^n x\frac{n!}{x!(n-x)!}y^x(1-y)^{n-x}, +\end{equation*} +$$ + +resulting in +$$ +\begin{equation*} +\mu = +\sum_{x=0}^n x\frac{(n-1)!}{(x-1)!(n-1-(x-1))!}y^{x-1}(1-y)^{n-1-(x-1)}, +\end{equation*} +$$ + +which we rewrite as + +$$ +\begin{equation*} +\mu=ny\sum_{\nu=0}^n\left(\begin{array}{c} n-1 \\ \nu\end{array}\right)y^{\nu}(1-y)^{n-1-\nu} =ny(y+1-y)^{n-1}=ny. +\end{equation*} +$$

    +The variance is slightly trickier to get. It reads \( \sigma^2=ny(1-y) \).

    @@ -439,7 +465,7 @@ and the variance is \( \sigma^2=\lambda \).

  • 31
  • 32
  • ...
  • -
  • 75
  • +
  • 76
  • »
  • diff --git a/doc/pub/Statistics/html/._Statistics-bs023.html b/doc/pub/Statistics/html/._Statistics-bs023.html index 9e6c696c0..357041f5e 100644 --- a/doc/pub/Statistics/html/._Statistics-bs023.html +++ b/doc/pub/Statistics/html/._Statistics-bs023.html @@ -6,6 +6,7 @@ Automatically generated HTML file from DocOnce source + Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis @@ -55,43 +56,40 @@ $(function () { @@ -296,80 +298,81 @@ MathJax.Hub.Config({ @@ -389,17 +392,26 @@ MathJax.Hub.Config({

    -An example of applications of the Poisson distribution could be the counting -of the number of \( \alpha \)-particles emitted from a radioactive source in a given time interval. -In the limit of \( n\rightarrow \infty \) and for small probabilities \( y \), the binomial distribution -approaches the Poisson distribution. Setting \( \lambda = ny \), with \( y \) the probability for an event in -the binomial distribution we can show that +

    +Another important distribution with discrete stochastic variables \( x \) is +the Poisson model, which resembles the exponential distribution and reads $$ -\begin{equation*} -\lim_{n\rightarrow \infty}\left(\begin{array}{c} n \\ x\end{array}\right)y^x(1-y)^{n-x} e^{-\lambda}=\sum_{x=1}^{\infty}\frac{\lambda^x}{x!} e^{-\lambda}. +\begin{equation*} + p(x) = \frac{\lambda^x}{x!} e^{-\lambda} \hspace{0.5cm}x=0,1,\dots,;\lambda > 0. \end{equation*} $$ + +In this case both the mean value and the variance are easier to calculate, + +$$ +\begin{equation*} +\mu = \sum_{x=0}^{\infty} x \frac{\lambda^x}{x!} e^{-\lambda} = \lambda e^{-\lambda}\sum_{x=1}^{\infty} +\frac{\lambda^{x-1}}{(x-1)!}=\lambda, +\end{equation*} +$$ + +and the variance is \( \sigma^2=\lambda \).

    @@ -430,7 +442,7 @@ $$
  • 32
  • 33
  • ...
  • -
  • 75
  • +
  • 76
  • »
  • diff --git a/doc/pub/Statistics/html/._Statistics-bs024.html b/doc/pub/Statistics/html/._Statistics-bs024.html index e045d4db9..79cc09c42 100644 --- a/doc/pub/Statistics/html/._Statistics-bs024.html +++ b/doc/pub/Statistics/html/._Statistics-bs024.html @@ -6,6 +6,7 @@ Automatically generated HTML file from DocOnce source + Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis @@ -55,43 +56,40 @@ $(function () { @@ -296,80 +298,81 @@ MathJax.Hub.Config({ @@ -385,32 +388,19 @@ MathJax.Hub.Config({ -

    Meet the covariance!

    +

    Probability Distribution Functions, Poisson's distribution

    -An important quantity in a statistical analysis is the so-called covariance. - -

    -Consider the set \( \{X_i\} \) of \( n \) -stochastic variables (not necessarily uncorrelated) with the -multivariate PDF \( P(x_1,\dots,x_n) \). The covariance of two -of the stochastic variables, \( X_i \) and \( X_j \), is defined as follows +An example of applications of the Poisson distribution could be the counting +of the number of \( \alpha \)-particles emitted from a radioactive source in a given time interval. +In the limit of \( n\rightarrow \infty \) and for small probabilities \( y \), the binomial distribution +approaches the Poisson distribution. Setting \( \lambda = ny \), with \( y \) the probability for an event in +the binomial distribution we can show that $$ -\begin{align} -\mathrm{Cov}(X_i,\,X_j) & = \langle (x_i-\langle x_i\rangle)(x_j-\langle x_j\rangle)\rangle -\tag{4}\\ -&=\int\cdots\int (x_i-\langle x_i\rangle)(x_j-\langle x_j\rangle)P(x_1,\dots,x_n)\,dx_1\dots dx_n, -\tag{5} -\end{align} -$$ - -with -$$ -\begin{equation*} -\langle x_i\rangle = -\int\cdots\int x_i P(x_1,\dots,x_n)\,dx_1\dots dx_n. +\begin{equation*} +\lim_{n\rightarrow \infty}\left(\begin{array}{c} n \\ x\end{array}\right)y^x(1-y)^{n-x} e^{-\lambda}=\sum_{x=1}^{\infty}\frac{\lambda^x}{x!} e^{-\lambda}. \end{equation*} $$

    @@ -443,7 +433,7 @@ $$
  • 33
  • 34
  • ...
  • -
  • 75
  • +
  • 76
  • »
  • diff --git a/doc/pub/Statistics/html/._Statistics-bs025.html b/doc/pub/Statistics/html/._Statistics-bs025.html index cd2a65058..54917205d 100644 --- a/doc/pub/Statistics/html/._Statistics-bs025.html +++ b/doc/pub/Statistics/html/._Statistics-bs025.html @@ -6,6 +6,7 @@ Automatically generated HTML file from DocOnce source + Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis @@ -55,43 +56,40 @@ $(function () { @@ -296,80 +298,81 @@ MathJax.Hub.Config({ @@ -385,19 +388,34 @@ MathJax.Hub.Config({ -

    Meet the covariance in matrix disguise

    +

    Meet the covariance!

    -If we consider the above covariance as a matrix +An important quantity in a statistical analysis is the so-called covariance. + +

    +Consider the set \( \{X_i\} \) of \( n \) +stochastic variables (not necessarily uncorrelated) with the +multivariate PDF \( P(x_1,\dots,x_n) \). The covariance of two +of the stochastic variables, \( X_i \) and \( X_j \), is defined as follows + $$ -C_{ij} =\mathrm{Cov}(X_i,\,X_j), +\begin{align} +\mathrm{Cov}(X_i,\,X_j) & = \langle (x_i-\langle x_i\rangle)(x_j-\langle x_j\rangle)\rangle +\tag{4}\\ +&=\int\cdots\int (x_i-\langle x_i\rangle)(x_j-\langle x_j\rangle)P(x_1,\dots,x_n)\,dx_1\dots dx_n, +\tag{5} +\end{align} $$ -then the diagonal elements are just the familiar -variances, \( C_{ii} = \mathrm{Cov}(X_i,\,X_i) = \mathrm{Var}(X_i) \). It turns out that -all the off-diagonal elements are zero if the stochastic variables are -uncorrelated. +with +$$ +\begin{equation*} +\langle x_i\rangle = +\int\cdots\int x_i P(x_1,\dots,x_n)\,dx_1\dots dx_n. +\end{equation*} +$$

    @@ -428,7 +446,7 @@ uncorrelated.
  • 34
  • 35
  • ...
  • -
  • 75
  • +
  • 76
  • »
  • diff --git a/doc/pub/Statistics/html/._Statistics-bs026.html b/doc/pub/Statistics/html/._Statistics-bs026.html index 1a685ef7d..266953522 100644 --- a/doc/pub/Statistics/html/._Statistics-bs026.html +++ b/doc/pub/Statistics/html/._Statistics-bs026.html @@ -6,6 +6,7 @@ Automatically generated HTML file from DocOnce source + Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis @@ -55,43 +56,40 @@ $(function () { @@ -296,80 +298,81 @@ MathJax.Hub.Config({ @@ -385,35 +388,23 @@ MathJax.Hub.Config({ -

    Covariance

    -

    +

    Meet the covariance in matrix disguise

    +
    +
    +

    +If we consider the above covariance as a matrix +$$ +C_{ij} =\mathrm{Cov}(X_i,\,X_j), +$$ - -

    # Importing various packages
    -from math import exp, sqrt
    -from random import random, seed
    -import numpy as np
    -import matplotlib.pyplot as plt
    +then the diagonal elements are just the familiar
    +variances, \( C_{ii} = \mathrm{Cov}(X_i,\,X_i) = \mathrm{Var}(X_i) \). It turns out that
    +all the off-diagonal elements are zero if the stochastic variables are
    +uncorrelated.
    +
    +
    -def covariance(x, y, n): - sum = 0.0 - mean_x = np.mean(x) - mean_y = np.mean(y) - for i in range(0, n): - sum += (x[(i)]-mean_x)*(y[i]-mean_y) - return sum/n -n = 10 - -x=np.random.normal(size=n) -y = 4+3*x+np.random.normal(size=n) -covxy = covariance(x,y,n) -print(covxy) -z = np.vstack((x, y)) -c = np.cov(z.T) - -print(c) -

    @@ -440,7 +431,7 @@ c = np.c

  • 35
  • 36
  • ...
  • -
  • 75
  • +
  • 76
  • »
  • diff --git a/doc/pub/Statistics/html/._Statistics-bs027.html b/doc/pub/Statistics/html/._Statistics-bs027.html index 465b002e5..9a266a461 100644 --- a/doc/pub/Statistics/html/._Statistics-bs027.html +++ b/doc/pub/Statistics/html/._Statistics-bs027.html @@ -6,6 +6,7 @@ Automatically generated HTML file from DocOnce source + Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis @@ -55,43 +56,40 @@ $(function () { @@ -296,80 +298,81 @@ MathJax.Hub.Config({ @@ -385,38 +388,35 @@ MathJax.Hub.Config({ -

    Meet the covariance, uncorrelated events

    -
    -
    -

    - +

    Covariance

    -Consider the stochastic variables \( X_i \) and \( X_j \), (\( i\neq j \)). We have -$$ -\begin{align*} -Cov(X_i,\,X_j) &= \langle (x_i-\langle x_i\rangle)(x_j-\langle x_j\rangle)\rangle\\ -&=\langle x_i x_j - x_i\langle x_j\rangle - \langle x_i\rangle x_j + \langle x_i\rangle\langle x_j\rangle\rangle\\ -&=\langle x_i x_j\rangle - \langle x_i\langle x_j\rangle\rangle - \langle \langle x_i\rangle x_j \rangle + -\langle \langle x_i\rangle\langle x_j\rangle\rangle \\ -&=\langle x_i x_j\rangle - \langle x_i\rangle\langle x_j\rangle - \langle x_i\rangle\langle x_j\rangle + -\langle x_i\rangle\langle x_j\rangle \\ -&=\langle x_i x_j\rangle - \langle x_i\rangle\langle x_j\rangle -\end{align*} -$$ -If \( X_i \) and \( X_j \) are independent (assuming \( i \neq j \)), we have that -$$ -\langle x_i x_j\rangle = \langle x_i\rangle\langle x_j\rangle, -$$ + +

    # Importing various packages
    +from math import exp, sqrt
    +from random import random, seed
    +import numpy as np
    +import matplotlib.pyplot as plt
     
    -leading to 
    -$$
    -Cov(X_i, X_j) = 0 \hspace{0.1cm} (i\neq j).
    -$$
    -
    -
    +def covariance(x, y, n): + sum = 0.0 + mean_x = np.mean(x) + mean_y = np.mean(y) + for i in range(0, n): + sum += (x[(i)]-mean_x)*(y[i]-mean_y) + return sum/n +n = 10 +x=np.random.normal(size=n) +y = 4+3*x+np.random.normal(size=n) +covxy = covariance(x,y,n) +print(covxy) +z = np.vstack((x, y)) +c = np.cov(z.T) + +print(c) +

    @@ -443,7 +443,7 @@ $$

  • 36
  • 37
  • ...
  • -
  • 75
  • +
  • 76
  • »
  • diff --git a/doc/pub/Statistics/html/._Statistics-bs028.html b/doc/pub/Statistics/html/._Statistics-bs028.html index 41ab5be0c..a993de1f1 100644 --- a/doc/pub/Statistics/html/._Statistics-bs028.html +++ b/doc/pub/Statistics/html/._Statistics-bs028.html @@ -6,6 +6,7 @@ Automatically generated HTML file from DocOnce source + Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis @@ -55,43 +56,40 @@ $(function () { @@ -296,80 +298,81 @@ MathJax.Hub.Config({ @@ -385,25 +388,33 @@ MathJax.Hub.Config({ -

    Numerical experiments and the covariance

    +

    Meet the covariance, uncorrelated events

    -Now that we have constructed an idealized mathematical framework, let -us try to apply it to empirical observations. Examples of relevant -physical phenomena may be spontaneous decays of nuclei, or a purely -mathematical set of numbers produced by some deterministic -mechanism. It is the latter we will deal with, using so-called pseudo-random -number generators. In general our observations will contain only a limited set of -observables. We remind the reader that -a stochastic process is a process that produces sequentially a -chain of values +Consider the stochastic variables \( X_i \) and \( X_j \), (\( i\neq j \)). We have $$ -\begin{equation*} -\{x_1, x_2,\dots\,x_k,\dots\}. -\end{equation*} +\begin{align*} +Cov(X_i,\,X_j) &= \langle (x_i-\langle x_i\rangle)(x_j-\langle x_j\rangle)\rangle\\ +&=\langle x_i x_j - x_i\langle x_j\rangle - \langle x_i\rangle x_j + \langle x_i\rangle\langle x_j\rangle\rangle\\ +&=\langle x_i x_j\rangle - \langle x_i\langle x_j\rangle\rangle - \langle \langle x_i\rangle x_j \rangle + +\langle \langle x_i\rangle\langle x_j\rangle\rangle \\ +&=\langle x_i x_j\rangle - \langle x_i\rangle\langle x_j\rangle - \langle x_i\rangle\langle x_j\rangle + +\langle x_i\rangle\langle x_j\rangle \\ +&=\langle x_i x_j\rangle - \langle x_i\rangle\langle x_j\rangle +\end{align*} +$$ + +If \( X_i \) and \( X_j \) are independent (assuming \( i \neq j \)), we have that +$$ +\langle x_i x_j\rangle = \langle x_i\rangle\langle x_j\rangle, +$$ + +leading to +$$ +Cov(X_i, X_j) = 0 \hspace{0.1cm} (i\neq j). $$

    @@ -435,7 +446,7 @@ $$
  • 37
  • 38
  • ...
  • -
  • 75
  • +
  • 76
  • »
  • diff --git a/doc/pub/Statistics/html/._Statistics-bs029.html b/doc/pub/Statistics/html/._Statistics-bs029.html index 048ee3d97..ea87fbee2 100644 --- a/doc/pub/Statistics/html/._Statistics-bs029.html +++ b/doc/pub/Statistics/html/._Statistics-bs029.html @@ -6,6 +6,7 @@ Automatically generated HTML file from DocOnce source + Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis @@ -55,43 +56,40 @@ $(function () { @@ -296,80 +298,81 @@ MathJax.Hub.Config({ @@ -389,18 +392,22 @@ MathJax.Hub.Config({

    -We will call these -values our measurements and the entire set as our measured -sample. The action of measuring all the elements of a sample -we will call a stochastic experiment (since, operationally, -they are often associated with results of empirical observation of -some physical or mathematical phenomena; precisely an experiment). We -assume that these values are distributed according to some -PDF \( p_X^{\phantom X}(x) \), where \( X \) is just the formal symbol for the -stochastic variable whose PDF is \( p_X^{\phantom X}(x) \). Instead of -trying to determine the full distribution \( p \) we are often only -interested in finding the few lowest moments, like the mean -\( \mu_X^{\phantom X} \) and the variance \( \sigma_X^{\phantom X} \). + +

    +Now that we have constructed an idealized mathematical framework, let +us try to apply it to empirical observations. Examples of relevant +physical phenomena may be spontaneous decays of nuclei, or a purely +mathematical set of numbers produced by some deterministic +mechanism. It is the latter we will deal with, using so-called pseudo-random +number generators. In general our observations will contain only a limited set of +observables. We remind the reader that +a stochastic process is a process that produces sequentially a +chain of values +$$ +\begin{equation*} +\{x_1, x_2,\dots\,x_k,\dots\}. +\end{equation*} +$$

    @@ -431,7 +438,7 @@ interested in finding the few lowest moments, like the mean
  • 38
  • 39
  • ...
  • -
  • 75
  • +
  • 76
  • »
  • diff --git a/doc/pub/Statistics/html/._Statistics-bs030.html b/doc/pub/Statistics/html/._Statistics-bs030.html index 79d5545b7..54f34bf28 100644 --- a/doc/pub/Statistics/html/._Statistics-bs030.html +++ b/doc/pub/Statistics/html/._Statistics-bs030.html @@ -6,6 +6,7 @@ Automatically generated HTML file from DocOnce source + Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis @@ -55,43 +56,40 @@ $(function () { @@ -296,80 +298,81 @@ MathJax.Hub.Config({ @@ -385,26 +388,22 @@ MathJax.Hub.Config({ -

    Numerical experiments and the covariance, actual situations

    +

    Numerical experiments and the covariance

    -In practical situations however, a sample is always of finite size. Let that -size be \( n \). The expectation value of a sample \( \alpha \), the sample mean, is then defined as follows -$$ -\begin{equation*} -\langle x_{\alpha} \rangle \equiv \frac{1}{n}\sum_{k=1}^n x_{\alpha,k}. -\end{equation*} -$$ - -The sample variance is: -$$ -\begin{equation*} -\mathrm{Var}(x) \equiv \frac{1}{n}\sum_{k=1}^n (x_{\alpha,k} - \langle x_{\alpha} \rangle)^2, -\end{equation*} -$$ - -with its square root being the standard deviation of the sample. +We will call these +values our measurements and the entire set as our measured +sample. The action of measuring all the elements of a sample +we will call a stochastic experiment (since, operationally, +they are often associated with results of empirical observation of +some physical or mathematical phenomena; precisely an experiment). We +assume that these values are distributed according to some +PDF \( p_X^{\phantom X}(x) \), where \( X \) is just the formal symbol for the +stochastic variable whose PDF is \( p_X^{\phantom X}(x) \). Instead of +trying to determine the full distribution \( p \) we are often only +interested in finding the few lowest moments, like the mean +\( \mu_X^{\phantom X} \) and the variance \( \sigma_X^{\phantom X} \).

    @@ -435,7 +434,7 @@ with its square root being the standard deviation of the sample.
  • 39
  • 40
  • ...
  • -
  • 75
  • +
  • 76
  • »
  • diff --git a/doc/pub/Statistics/html/._Statistics-bs031.html b/doc/pub/Statistics/html/._Statistics-bs031.html index 365d30697..2e6a838e3 100644 --- a/doc/pub/Statistics/html/._Statistics-bs031.html +++ b/doc/pub/Statistics/html/._Statistics-bs031.html @@ -6,6 +6,7 @@ Automatically generated HTML file from DocOnce source + Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis @@ -55,43 +56,40 @@ $(function () { @@ -296,80 +298,81 @@ MathJax.Hub.Config({ @@ -385,35 +388,26 @@ MathJax.Hub.Config({ -

    Numerical experiments and the covariance, our observables

    +

    Numerical experiments and the covariance, actual situations

    -You can think of the above observables as a set of quantities which define -a given experiment. This experiment is then repeated several times, say \( m \) times. -The total average is then -$$ -\begin{equation} -\langle X_m \rangle= \frac{1}{m}\sum_{\alpha=1}^mx_{\alpha}=\frac{1}{mn}\sum_{\alpha, k} x_{\alpha,k}, -\tag{6} -\end{equation} -$$ - -where the last sums end at \( m \) and \( n \). -The total variance is +In practical situations however, a sample is always of finite size. Let that +size be \( n \). The expectation value of a sample \( \alpha \), the sample mean, is then defined as follows $$ \begin{equation*} -\sigma^2_m= \frac{1}{mn^2}\sum_{\alpha=1}^m(\langle x_{\alpha} \rangle-\langle X_m \rangle)^2, +\langle x_{\alpha} \rangle \equiv \frac{1}{n}\sum_{k=1}^n x_{\alpha,k}. \end{equation*} $$ -which we rewrite as +The sample variance is: $$ -\begin{equation} -\sigma^2_m=\frac{1}{m}\sum_{\alpha=1}^m\sum_{kl=1}^n (x_{\alpha,k}-\langle X_m \rangle)(x_{\alpha,l}-\langle X_m \rangle). -\tag{7} -\end{equation} +\begin{equation*} +\mathrm{Var}(x) \equiv \frac{1}{n}\sum_{k=1}^n (x_{\alpha,k} - \langle x_{\alpha} \rangle)^2, +\end{equation*} $$ + +with its square root being the standard deviation of the sample.

    @@ -444,7 +438,7 @@ $$
  • 40
  • 41
  • ...
  • -
  • 75
  • +
  • 76
  • »
  • diff --git a/doc/pub/Statistics/html/._Statistics-bs032.html b/doc/pub/Statistics/html/._Statistics-bs032.html index 7a798b8a5..9da982cd0 100644 --- a/doc/pub/Statistics/html/._Statistics-bs032.html +++ b/doc/pub/Statistics/html/._Statistics-bs032.html @@ -6,6 +6,7 @@ Automatically generated HTML file from DocOnce source + Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis @@ -55,43 +56,40 @@ $(function () { @@ -296,80 +298,81 @@ MathJax.Hub.Config({ @@ -385,26 +388,35 @@ MathJax.Hub.Config({ -

    Numerical experiments and the covariance, the sample variance

    +

    Numerical experiments and the covariance, our observables

    - -

    -We define also the sample variance \( \sigma^2 \) of all \( mn \) individual experiments as +You can think of the above observables as a set of quantities which define +a given experiment. This experiment is then repeated several times, say \( m \) times. +The total average is then $$ \begin{equation} -\sigma^2=\frac{1}{mn}\sum_{\alpha=1}^m\sum_{k=1}^n (x_{\alpha,k}-\langle X_m \rangle)^2. -\tag{8} +\langle X_m \rangle= \frac{1}{m}\sum_{\alpha=1}^mx_{\alpha}=\frac{1}{mn}\sum_{\alpha, k} x_{\alpha,k}, +\tag{6} \end{equation} $$ -

    -These quantities, being known experimental values or the results from our calculations, -may differ, in some cases -significantly, from the similarly named -exact values for the mean value \( \mu_X \), the variance \( \mathrm{Var}(X) \) -and the covariance \( \mathrm{Cov}(X,Y) \). +where the last sums end at \( m \) and \( n \). +The total variance is +$$ +\begin{equation*} +\sigma^2_m= \frac{1}{mn^2}\sum_{\alpha=1}^m(\langle x_{\alpha} \rangle-\langle X_m \rangle)^2, +\end{equation*} +$$ + +which we rewrite as +$$ +\begin{equation} +\sigma^2_m=\frac{1}{m}\sum_{\alpha=1}^m\sum_{kl=1}^n (x_{\alpha,k}-\langle X_m \rangle)(x_{\alpha,l}-\langle X_m \rangle). +\tag{7} +\end{equation} +$$

    @@ -435,7 +447,7 @@ and the covariance \( \mathrm{Cov}(X,Y) \).
  • 41
  • 42
  • ...
  • -
  • 75
  • +
  • 76
  • »
  • diff --git a/doc/pub/Statistics/html/._Statistics-bs033.html b/doc/pub/Statistics/html/._Statistics-bs033.html index 251e479cc..0b59bf4fe 100644 --- a/doc/pub/Statistics/html/._Statistics-bs033.html +++ b/doc/pub/Statistics/html/._Statistics-bs033.html @@ -6,6 +6,7 @@ Automatically generated HTML file from DocOnce source + Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis @@ -55,43 +56,40 @@ $(function () { @@ -296,80 +298,81 @@ MathJax.Hub.Config({ @@ -385,30 +388,26 @@ MathJax.Hub.Config({ -

    Numerical experiments and the covariance, central limit theorem

    +

    Numerical experiments and the covariance, the sample variance

    -The central limit theorem states that the PDF \( \tilde{p}(z) \) of -the average of \( m \) random values corresponding to a PDF \( p(x) \) -is a normal distribution whose mean is the -mean value of the PDF \( p(x) \) and whose variance is the variance -of the PDF \( p(x) \) divided by \( m \), the number of values used to compute \( z \). - -

    -The central limit theorem leads then to the well-known expression for the -standard deviation, given by +We define also the sample variance \( \sigma^2 \) of all \( mn \) individual experiments as $$ -\begin{equation*} - \sigma_m= -\frac{\sigma}{\sqrt{m}}. -\end{equation*} +\begin{equation} +\sigma^2=\frac{1}{mn}\sum_{\alpha=1}^m\sum_{k=1}^n (x_{\alpha,k}-\langle X_m \rangle)^2. +\tag{8} +\end{equation} $$

    -In many cases the above estimate for the standard deviation, in particular if correlations are strong, may be too simplistic. We need therefore a more precise defintion of the error and the variance in our results. +These quantities, being known experimental values or the results from our calculations, +may differ, in some cases +significantly, from the similarly named +exact values for the mean value \( \mu_X \), the variance \( \mathrm{Var}(X) \) +and the covariance \( \mathrm{Cov}(X,Y) \).

    @@ -439,7 +438,7 @@ In many cases the above estimate for the standard deviation, in particular if co
  • 42
  • 43
  • ...
  • -
  • 75
  • +
  • 76
  • »
  • diff --git a/doc/pub/Statistics/html/._Statistics-bs034.html b/doc/pub/Statistics/html/._Statistics-bs034.html index 9ccf1a224..beef06f3a 100644 --- a/doc/pub/Statistics/html/._Statistics-bs034.html +++ b/doc/pub/Statistics/html/._Statistics-bs034.html @@ -6,6 +6,7 @@ Automatically generated HTML file from DocOnce source + Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis @@ -55,43 +56,40 @@ $(function () { @@ -296,80 +298,81 @@ MathJax.Hub.Config({ @@ -385,35 +388,30 @@ MathJax.Hub.Config({ -

    Definition of Correlation Functions and Standard Deviation

    +

    Numerical experiments and the covariance, central limit theorem

    -Our estimate of the true average \( \mu_{X} \) is the sample mean \( \langle X_m \rangle \) +

    +The central limit theorem states that the PDF \( \tilde{p}(z) \) of +the average of \( m \) random values corresponding to a PDF \( p(x) \) +is a normal distribution whose mean is the +mean value of the PDF \( p(x) \) and whose variance is the variance +of the PDF \( p(x) \) divided by \( m \), the number of values used to compute \( z \). + +

    +The central limit theorem leads then to the well-known expression for the +standard deviation, given by $$ \begin{equation*} -\mu_{X}^{\phantom X} \approx X_m=\frac{1}{mn}\sum_{\alpha=1}^m\sum_{k=1}^n x_{\alpha,k}. + \sigma_m= +\frac{\sigma}{\sqrt{m}}. \end{equation*} $$

    -We can then use Eq. (7) -$$ -\begin{equation*} -\sigma^2_m=\frac{1}{mn^2}\sum_{\alpha=1}^m\sum_{kl=1}^n (x_{\alpha,k}-\langle X_m \rangle)(x_{\alpha,l}-\langle X_m \rangle), -\end{equation*} -$$ - -and rewrite it as -$$ -\begin{equation*} -\sigma^2_m=\frac{\sigma^2}{n}+\frac{2}{mn^2}\sum_{\alpha=1}^m\sum_{k < l}^n (x_{\alpha,k}-\langle X_m \rangle)(x_{\alpha,l}-\langle X_m \rangle), -\end{equation*} -$$ - -where the first term is the sample variance of all \( mn \) experiments divided by \( n \) -and the last term is nothing but the covariance which arises when \( k\ne l \). +In many cases the above estimate for the standard deviation, in particular if correlations are strong, may be too simplistic. We need therefore a more precise defintion of the error and the variance in our results.

    @@ -444,7 +442,7 @@ and the last term is nothing but the covariance which arises when \( k\ne l \).
  • 43
  • 44
  • ...
  • -
  • 75
  • +
  • 76
  • »
  • diff --git a/doc/pub/Statistics/html/._Statistics-bs035.html b/doc/pub/Statistics/html/._Statistics-bs035.html index 9be7ce46f..8a9d5f43d 100644 --- a/doc/pub/Statistics/html/._Statistics-bs035.html +++ b/doc/pub/Statistics/html/._Statistics-bs035.html @@ -6,6 +6,7 @@ Automatically generated HTML file from DocOnce source + Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis @@ -55,43 +56,40 @@ $(function () { @@ -296,80 +298,81 @@ MathJax.Hub.Config({ @@ -391,18 +394,29 @@ MathJax.Hub.Config({

    Our estimate of the true average \( \mu_{X} \) is the sample mean \( \langle X_m \rangle \) +$$ +\begin{equation*} +\mu_{X}^{\phantom X} \approx X_m=\frac{1}{mn}\sum_{\alpha=1}^m\sum_{k=1}^n x_{\alpha,k}. +\end{equation*} +$$ +

    -If the -observables are uncorrelated, then the covariance is zero and we obtain a total variance -which agrees with the central limit theorem. Correlations may often be present in our data set, resulting in a non-zero covariance. The first term is normally called the uncorrelated -contribution. -Computationally the uncorrelated first term is much easier to treat -efficiently than the second. -We just accumulate separately the values \( x^2 \) and \( x \) for every -measurement \( x \) we receive. The correlation term, though, has to be -calculated at the end of the experiment since we need all the -measurements to calculate the cross terms. Therefore, all measurements -have to be stored throughout the experiment. +We can then use Eq. (7) +$$ +\begin{equation*} +\sigma^2_m=\frac{1}{mn^2}\sum_{\alpha=1}^m\sum_{kl=1}^n (x_{\alpha,k}-\langle X_m \rangle)(x_{\alpha,l}-\langle X_m \rangle), +\end{equation*} +$$ + +and rewrite it as +$$ +\begin{equation*} +\sigma^2_m=\frac{\sigma^2}{n}+\frac{2}{mn^2}\sum_{\alpha=1}^m\sum_{k < l}^n (x_{\alpha,k}-\langle X_m \rangle)(x_{\alpha,l}-\langle X_m \rangle), +\end{equation*} +$$ + +where the first term is the sample variance of all \( mn \) experiments divided by \( n \) +and the last term is nothing but the covariance which arises when \( k\ne l \).

    @@ -433,7 +447,7 @@ have to be stored throughout the experiment.
  • 44
  • 45
  • ...
  • -
  • 75
  • +
  • 76
  • »
  • diff --git a/doc/pub/Statistics/html/._Statistics-bs036.html b/doc/pub/Statistics/html/._Statistics-bs036.html index 9b5444177..f99fc6748 100644 --- a/doc/pub/Statistics/html/._Statistics-bs036.html +++ b/doc/pub/Statistics/html/._Statistics-bs036.html @@ -6,6 +6,7 @@ Automatically generated HTML file from DocOnce source + Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis @@ -55,43 +56,40 @@ $(function () { @@ -296,80 +298,81 @@ MathJax.Hub.Config({ @@ -389,26 +392,20 @@ MathJax.Hub.Config({

    +Our estimate of the true average \( \mu_{X} \) is the sample mean \( \langle X_m \rangle \)

    -Let us analyze the problem by splitting up the correlation term into -partial sums of the form - -$$ -\begin{equation*} -f_d = \frac{1}{nm}\sum_{\alpha=1}^m\sum_{k=1}^{n-d}(x_{\alpha,k}-\langle X_m \rangle)(x_{\alpha,k+d}-\langle X_m \rangle), -\end{equation*} -$$ - -The correlation term of the total variance can now be rewritten in terms of -\( f_d \) - -$$ -\begin{equation*} -\frac{2}{mn^2}\sum_{\alpha=1}^m\sum_{k < l}^n (x_{\alpha,k}-\langle X_m \rangle)(x_{\alpha,l}-\langle X_m \rangle)= -\frac{2}{n}\sum_{d=1}^{n-1} f_d -\end{equation*} -$$ +If the +observables are uncorrelated, then the covariance is zero and we obtain a total variance +which agrees with the central limit theorem. Correlations may often be present in our data set, resulting in a non-zero covariance. The first term is normally called the uncorrelated +contribution. +Computationally the uncorrelated first term is much easier to treat +efficiently than the second. +We just accumulate separately the values \( x^2 \) and \( x \) for every +measurement \( x \) we receive. The correlation term, though, has to be +calculated at the end of the experiment since we need all the +measurements to calculate the cross terms. Therefore, all measurements +have to be stored throughout the experiment.

    @@ -439,7 +436,7 @@ $$
  • 45
  • 46
  • ...
  • -
  • 75
  • +
  • 76
  • »
  • diff --git a/doc/pub/Statistics/html/._Statistics-bs037.html b/doc/pub/Statistics/html/._Statistics-bs037.html index e621d7aea..d51f68d2a 100644 --- a/doc/pub/Statistics/html/._Statistics-bs037.html +++ b/doc/pub/Statistics/html/._Statistics-bs037.html @@ -6,6 +6,7 @@ Automatically generated HTML file from DocOnce source + Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis @@ -55,43 +56,40 @@ $(function () { @@ -296,80 +298,81 @@ MathJax.Hub.Config({ @@ -389,20 +392,26 @@ MathJax.Hub.Config({

    -The value of \( f_d \) reflects the correlation between measurements -separated by the distance \( d \) in the samples. Notice that for -\( d=0 \), \( f \) is just the sample variance, \( \sigma^2 \). If we divide \( f_d \) -by \( \sigma^2 \), we arrive at the so called autocorrelation function + +

    +Let us analyze the problem by splitting up the correlation term into +partial sums of the form $$ -\begin{equation} -\kappa_d = \frac{f_d}{\sigma^2} -\tag{9} -\end{equation} +\begin{equation*} +f_d = \frac{1}{nm}\sum_{\alpha=1}^m\sum_{k=1}^{n-d}(x_{\alpha,k}-\langle X_m \rangle)(x_{\alpha,k+d}-\langle X_m \rangle), +\end{equation*} $$ -which gives us a useful measure of the correlation pair correlation -starting always at \( 1 \) for \( d=0 \). +The correlation term of the total variance can now be rewritten in terms of +\( f_d \) + +$$ +\begin{equation*} +\frac{2}{mn^2}\sum_{\alpha=1}^m\sum_{k < l}^n (x_{\alpha,k}-\langle X_m \rangle)(x_{\alpha,l}-\langle X_m \rangle)= +\frac{2}{n}\sum_{d=1}^{n-1} f_d +\end{equation*} +$$

    @@ -433,7 +442,7 @@ starting always at \( 1 \) for \( d=0 \).
  • 46
  • 47
  • ...
  • -
  • 75
  • +
  • 76
  • »
  • diff --git a/doc/pub/Statistics/html/._Statistics-bs038.html b/doc/pub/Statistics/html/._Statistics-bs038.html index 2d63f6b93..94d33ede2 100644 --- a/doc/pub/Statistics/html/._Statistics-bs038.html +++ b/doc/pub/Statistics/html/._Statistics-bs038.html @@ -6,6 +6,7 @@ Automatically generated HTML file from DocOnce source + Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis @@ -55,43 +56,40 @@ $(function () { @@ -296,80 +298,81 @@ MathJax.Hub.Config({ @@ -385,39 +388,24 @@ MathJax.Hub.Config({ -

    Definition of Correlation Functions and Standard Deviation, sample variance

    +

    Definition of Correlation Functions and Standard Deviation

    - -

    -The sample variance of the \( mn \) experiments can now be -written in terms of the autocorrelation function +The value of \( f_d \) reflects the correlation between measurements +separated by the distance \( d \) in the samples. Notice that for +\( d=0 \), \( f \) is just the sample variance, \( \sigma^2 \). If we divide \( f_d \) +by \( \sigma^2 \), we arrive at the so called autocorrelation function $$ \begin{equation} -\sigma_m^2=\frac{\sigma^2}{n}+\frac{2}{n}\cdot\sigma^2\sum_{d=1}^{n-1} -\frac{f_d}{\sigma^2}=\left(1+2\sum_{d=1}^{n-1}\kappa_d\right)\frac{1}{n}\sigma^2=\frac{\tau}{n}\cdot\sigma^2 -\tag{10} +\kappa_d = \frac{f_d}{\sigma^2} +\tag{9} \end{equation} $$ -and we see that \( \sigma_m \) can be expressed in terms of the -uncorrelated sample variance times a correction factor \( \tau \) which -accounts for the correlation between measurements. We call this -correction factor the autocorrelation time - -$$ -\begin{equation} -\tau = 1+2\sum_{d=1}^{n-1}\kappa_d -\tag{11} -\end{equation} -$$ - - - -For a correlation free experiment, \( \tau \) -equals 1. +which gives us a useful measure of the correlation pair correlation +starting always at \( 1 \) for \( d=0 \).

    @@ -448,7 +436,7 @@ equals 1.
  • 47
  • 48
  • ...
  • -
  • 75
  • +
  • 76
  • »
  • diff --git a/doc/pub/Statistics/html/._Statistics-bs039.html b/doc/pub/Statistics/html/._Statistics-bs039.html index 3311b7e18..307c2ff5b 100644 --- a/doc/pub/Statistics/html/._Statistics-bs039.html +++ b/doc/pub/Statistics/html/._Statistics-bs039.html @@ -6,6 +6,7 @@ Automatically generated HTML file from DocOnce source + Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis @@ -55,43 +56,40 @@ $(function () { @@ -296,80 +298,81 @@ MathJax.Hub.Config({ @@ -385,28 +388,39 @@ MathJax.Hub.Config({ -

    Definition of Correlation Functions and Standard Deviation

    +

    Definition of Correlation Functions and Standard Deviation, sample variance

    -From the point of view of -Eq. (10) we can interpret a sequential -correlation as an effective reduction of the number of measurements by -a factor \( \tau \). The effective number of measurements becomes + +

    +The sample variance of the \( mn \) experiments can now be +written in terms of the autocorrelation function + $$ -\begin{equation*} -n_\mathrm{eff} = \frac{n}{\tau} -\end{equation*} +\begin{equation} +\sigma_m^2=\frac{\sigma^2}{n}+\frac{2}{n}\cdot\sigma^2\sum_{d=1}^{n-1} +\frac{f_d}{\sigma^2}=\left(1+2\sum_{d=1}^{n-1}\kappa_d\right)\frac{1}{n}\sigma^2=\frac{\tau}{n}\cdot\sigma^2 +\tag{10} +\end{equation} $$ -To neglect the autocorrelation time \( \tau \) will always cause our -simple uncorrelated estimate of \( \sigma_m^2\approx \sigma^2/n \) to -be less than the true sample error. The estimate of the error will be -too "good". On the other hand, the calculation of the full -autocorrelation time poses an efficiency problem if the set of -measurements is very large. The solution to this problem is given by -more practically oriented methods like the blocking technique. - +and we see that \( \sigma_m \) can be expressed in terms of the +uncorrelated sample variance times a correction factor \( \tau \) which +accounts for the correlation between measurements. We call this +correction factor the autocorrelation time + +$$ +\begin{equation} +\tau = 1+2\sum_{d=1}^{n-1}\kappa_d +\tag{11} +\end{equation} +$$ + + + +For a correlation free experiment, \( \tau \) +equals 1.

    @@ -437,7 +451,7 @@ more practically oriented methods like the blocking technique.
  • 48
  • 49
  • ...
  • -
  • 75
  • +
  • 76
  • »
  • diff --git a/doc/pub/Statistics/html/._Statistics-bs040.html b/doc/pub/Statistics/html/._Statistics-bs040.html index 739be52ba..941422df7 100644 --- a/doc/pub/Statistics/html/._Statistics-bs040.html +++ b/doc/pub/Statistics/html/._Statistics-bs040.html @@ -6,6 +6,7 @@ Automatically generated HTML file from DocOnce source + Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis @@ -55,43 +56,40 @@ $(function () { @@ -296,80 +298,81 @@ MathJax.Hub.Config({ @@ -383,50 +386,34 @@ MathJax.Hub.Config({

     

     

     

    - + -

    Code to compute the Covariance matrix and the Covariance

    -

    +

    Definition of Correlation Functions and Standard Deviation

    +
    +
    +

    +From the point of view of +Eq. (10) we can interpret a sequential +correlation as an effective reduction of the number of measurements by +a factor \( \tau \). The effective number of measurements becomes +$$ +\begin{equation*} +n_\mathrm{eff} = \frac{n}{\tau} +\end{equation*} +$$ - -

    # Importing various packages
    -from math import exp, sqrt
    -from random import random, seed
    -import numpy as np
    -import matplotlib.pyplot as plt
    +To neglect the autocorrelation time \( \tau \) will always cause our
    +simple uncorrelated estimate of \( \sigma_m^2\approx \sigma^2/n \) to
    +be less than the true sample error. The estimate of the error will be
    +too "good". On the other hand, the calculation of the full
    +autocorrelation time poses an efficiency problem if the set of
    +measurements is very large.  The solution to this problem is given by 
    +more practically oriented methods like the blocking technique.
    +
    +
    +
    -# Sample covariance, note the factor 1/(n-1) -def covariance(x, y, n): - sum = 0.0 - mean_x = np.mean(x) - mean_y = np.mean(y) - for i in range(0, n): - sum += (x[(i)]-mean_x)*(y[i]-mean_y) - return sum/(n-1.) -n = 100 -x = np.random.normal(size=n) -print(np.mean(x)) -y = 4+3*x+np.random.normal(size=n) -print(np.mean(y)) -z = x**3+np.random.normal(size=n) -print(np.mean(z)) -covxx = covariance(x,x,n) -covyy = covariance(y,y,n) -covzz = covariance(z,z,n) -covxy = covariance(x,y,n) -covxz = covariance(x,z,n) -covyz = covariance(y,z,n) -print(covxx,covyy, covzz) -print(covxy,covxz, covyz) -w = np.vstack((x, y, z)) -#print(w) -c = np.cov(w) -print(c) -#eigen = np.zeros(n) -Eigvals, Eigvecs = np.linalg.eig(c) -print(Eigvals) -

    @@ -453,7 +440,7 @@ Eigvals, Eigvecs = np49

  • 50
  • ...
  • -
  • 75
  • +
  • 76
  • »
  • diff --git a/doc/pub/Statistics/html/._Statistics-bs041.html b/doc/pub/Statistics/html/._Statistics-bs041.html index 70d0977ec..79a97ba40 100644 --- a/doc/pub/Statistics/html/._Statistics-bs041.html +++ b/doc/pub/Statistics/html/._Statistics-bs041.html @@ -6,6 +6,7 @@ Automatically generated HTML file from DocOnce source + Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis @@ -55,43 +56,40 @@ $(function () { @@ -296,80 +298,81 @@ MathJax.Hub.Config({ @@ -383,28 +386,50 @@ MathJax.Hub.Config({

     

     

     

    - - -

    Random Numbers

    -
    -
    -

    + +

    Code to compute the Covariance matrix and the Covariance

    -Uniform deviates are just random numbers that lie within a specified range -(typically 0 to 1), with any one number in the range just as likely as any other. They -are, in other words, what you probably think random numbers are. However, -we want to distinguish uniform deviates from other sorts of random numbers, for -example numbers drawn from a normal (Gaussian) distribution of specified mean -and standard deviation. These other sorts of deviates are almost always generated by -performing appropriate operations on one or more uniform deviates, as we will see -in subsequent sections. So, a reliable source of random uniform deviates, the subject -of this section, is an essential building block for any sort of stochastic modeling -or Monte Carlo computer work. -

    -
    + +
    # Importing various packages
    +from math import exp, sqrt
    +from random import random, seed
    +import numpy as np
    +import matplotlib.pyplot as plt
     
    +# Sample covariance, note the factor 1/(n-1)
    +def covariance(x, y, n):
    +    sum = 0.0
    +    mean_x = np.mean(x)
    +    mean_y = np.mean(y)
    +    for i in range(0, n):
    +        sum += (x[(i)]-mean_x)*(y[i]-mean_y)
    +    return  sum/(n-1.)
    +
    +n = 100
    +x = np.random.normal(size=n)
    +print(np.mean(x))
    +y = 4+3*x+np.random.normal(size=n)
    +print(np.mean(y))
    +z = x**3+np.random.normal(size=n)
    +print(np.mean(z))
    +covxx = covariance(x,x,n)
    +covyy = covariance(y,y,n)
    +covzz = covariance(z,z,n)
    +covxy = covariance(x,y,n)
    +covxz = covariance(x,z,n)
    +covyz = covariance(y,z,n)
    +print(covxx,covyy, covzz)
    +print(covxy,covxz, covyz)
    +w = np.vstack((x, y, z))
    +#print(w)
    +c = np.cov(w)
    +print(c)
    +#eigen = np.zeros(n)
    +Eigvals, Eigvecs = np.linalg.eig(c)
    +print(Eigvals)
    +

    @@ -431,7 +456,7 @@ or Monte Carlo computer work.

  • 50
  • 51
  • ...
  • -
  • 75
  • +
  • 76
  • »
  • diff --git a/doc/pub/Statistics/html/._Statistics-bs042.html b/doc/pub/Statistics/html/._Statistics-bs042.html index 54031d712..841231973 100644 --- a/doc/pub/Statistics/html/._Statistics-bs042.html +++ b/doc/pub/Statistics/html/._Statistics-bs042.html @@ -6,6 +6,7 @@ Automatically generated HTML file from DocOnce source + Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis @@ -55,43 +56,40 @@ $(function () { @@ -296,80 +298,81 @@ MathJax.Hub.Config({ @@ -385,25 +388,22 @@ MathJax.Hub.Config({ -

    Random Numbers, better name: pseudo random numbers

    +

    Random Numbers

    -A disclaimer is however appropriate. It should be fairly obvious that -something as deterministic as a computer cannot generate purely random numbers. - -

    -Numbers generated by any of the standard algorithms are in reality pseudo random -numbers, hopefully abiding to the following criteria: - -

    +Uniform deviates are just random numbers that lie within a specified range +(typically 0 to 1), with any one number in the range just as likely as any other. They +are, in other words, what you probably think random numbers are. However, +we want to distinguish uniform deviates from other sorts of random numbers, for +example numbers drawn from a normal (Gaussian) distribution of specified mean +and standard deviation. These other sorts of deviates are almost always generated by +performing appropriate operations on one or more uniform deviates, as we will see +in subsequent sections. So, a reliable source of random uniform deviates, the subject +of this section, is an essential building block for any sort of stochastic modeling +or Monte Carlo computer work.
    @@ -434,7 +434,7 @@ numbers, hopefully abiding to the following criteria:
  • 51
  • 52
  • ...
  • -
  • 75
  • +
  • 76
  • »
  • diff --git a/doc/pub/Statistics/html/._Statistics-bs043.html b/doc/pub/Statistics/html/._Statistics-bs043.html index d1964dd09..053ab1fa6 100644 --- a/doc/pub/Statistics/html/._Statistics-bs043.html +++ b/doc/pub/Statistics/html/._Statistics-bs043.html @@ -6,6 +6,7 @@ Automatically generated HTML file from DocOnce source + Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis @@ -55,43 +56,40 @@ $(function () { @@ -296,80 +298,81 @@ MathJax.Hub.Config({ @@ -385,34 +388,25 @@ MathJax.Hub.Config({ -

    Random number generator RNG

    +

    Random Numbers, better name: pseudo random numbers

    - The most common random number generators are based on so-called -Linear congruential relations of the type - -$$ -\begin{equation*} - N_i=(aN_{i-1}+c) \mathrm{MOD} (M), -\end{equation*} -$$ - -which yield a number in the interval [0,1] through - -$$ -\begin{equation*} - x_i=N_i/M -\end{equation*} -$$

    -The number -\( M \) is called the period and it should be as large as possible - and -\( N_0 \) is the starting value, or seed. The function \( \mathrm{MOD} \) means the remainder, -that is if we were to evaluate \( (13)\mathrm{MOD}(9) \), the outcome is the remainder -of the division \( 13/9 \), namely \( 4 \). +A disclaimer is however appropriate. It should be fairly obvious that +something as deterministic as a computer cannot generate purely random numbers. + +

    +Numbers generated by any of the standard algorithms are in reality pseudo random +numbers, hopefully abiding to the following criteria: + +

    @@ -443,7 +437,7 @@ of the division \( 13/9 \), namely \( 4 \).
  • 52
  • 53
  • ...
  • -
  • 75
  • +
  • 76
  • »
  • diff --git a/doc/pub/Statistics/html/._Statistics-bs044.html b/doc/pub/Statistics/html/._Statistics-bs044.html index c80457105..de64e0afa 100644 --- a/doc/pub/Statistics/html/._Statistics-bs044.html +++ b/doc/pub/Statistics/html/._Statistics-bs044.html @@ -6,6 +6,7 @@ Automatically generated HTML file from DocOnce source + Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis @@ -55,43 +56,40 @@ $(function () { @@ -296,80 +298,81 @@ MathJax.Hub.Config({ @@ -385,39 +388,34 @@ MathJax.Hub.Config({ -

    Random number generator RNG and periodic outputs

    +

    Random number generator RNG

    - -

    -The problem with such generators is that their outputs are periodic; -they -will start to repeat themselves with a period that is at most \( M \). If however -the parameters \( a \) and \( c \) are badly chosen, the period may be even shorter. - -

    -Consider the following example + The most common random number generators are based on so-called +Linear congruential relations of the type $$ \begin{equation*} - N_i=(6N_{i-1}+7) \mathrm{MOD} (5), + N_i=(aN_{i-1}+c) \mathrm{MOD} (M), \end{equation*} $$ -with a seed \( N_0=2 \). This generator produces the sequence -\( 4,1,3,0,2,4,1,3,0,2,...\dots \), i.e., a sequence with period \( 5 \). -However, increasing \( M \) may not guarantee a larger period as the following -example shows +which yield a number in the interval [0,1] through $$ \begin{equation*} - N_i=(27N_{i-1}+11) \mathrm{MOD} (54), + x_i=N_i/M \end{equation*} $$ -which still, with \( N_0=2 \), results in \( 11,38,11,38,11,38,\dots \), a period of -just \( 2 \). +

    +The number +\( M \) is called the period and it should be as large as possible + and +\( N_0 \) is the starting value, or seed. The function \( \mathrm{MOD} \) means the remainder, +that is if we were to evaluate \( (13)\mathrm{MOD}(9) \), the outcome is the remainder +of the division \( 13/9 \), namely \( 4 \).

    @@ -448,7 +446,7 @@ just \( 2 \).
  • 53
  • 54
  • ...
  • -
  • 75
  • +
  • 76
  • »
  • diff --git a/doc/pub/Statistics/html/._Statistics-bs045.html b/doc/pub/Statistics/html/._Statistics-bs045.html index 41d00404d..a566d78c0 100644 --- a/doc/pub/Statistics/html/._Statistics-bs045.html +++ b/doc/pub/Statistics/html/._Statistics-bs045.html @@ -6,6 +6,7 @@ Automatically generated HTML file from DocOnce source + Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis @@ -55,43 +56,40 @@ $(function () { @@ -296,80 +298,81 @@ MathJax.Hub.Config({ @@ -385,23 +388,39 @@ MathJax.Hub.Config({ -

    Random number generator RNG and its period

    +

    Random number generator RNG and periodic outputs

    -Typical periods for the random generators provided in the program library -are of the order of \( \sim 10^9 \) or larger. Other random number generators which have -become increasingly popular are so-called shift-register generators. -In these generators each successive number depends on many preceding -values (rather than the last values as in the linear congruential -generator). -For example, you could make a shift register generator whose $l$th -number is the sum of the $l-i$th and $l-j$th values with modulo \( M \), + +

    +The problem with such generators is that their outputs are periodic; +they +will start to repeat themselves with a period that is at most \( M \). If however +the parameters \( a \) and \( c \) are badly chosen, the period may be even shorter. + +

    +Consider the following example + $$ \begin{equation*} - N_l=(aN_{l-i}+cN_{l-j})\mathrm{MOD}(M). + N_i=(6N_{i-1}+7) \mathrm{MOD} (5), \end{equation*} $$ + +with a seed \( N_0=2 \). This generator produces the sequence +\( 4,1,3,0,2,4,1,3,0,2,...\dots \), i.e., a sequence with period \( 5 \). +However, increasing \( M \) may not guarantee a larger period as the following +example shows + +$$ +\begin{equation*} + N_i=(27N_{i-1}+11) \mathrm{MOD} (54), +\end{equation*} +$$ + +which still, with \( N_0=2 \), results in \( 11,38,11,38,11,38,\dots \), a period of +just \( 2 \).

    @@ -432,7 +451,7 @@ $$
  • 54
  • 55
  • ...
  • -
  • 75
  • +
  • 76
  • »
  • diff --git a/doc/pub/Statistics/html/._Statistics-bs046.html b/doc/pub/Statistics/html/._Statistics-bs046.html index dab8fb3ec..1b5d92f74 100644 --- a/doc/pub/Statistics/html/._Statistics-bs046.html +++ b/doc/pub/Statistics/html/._Statistics-bs046.html @@ -6,6 +6,7 @@ Automatically generated HTML file from DocOnce source + Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis @@ -55,43 +56,40 @@ $(function () { @@ -296,80 +298,81 @@ MathJax.Hub.Config({ @@ -385,33 +388,23 @@ MathJax.Hub.Config({ -

    Random number generator RNG, other examples

    +

    Random number generator RNG and its period

    -Such a generator again produces a sequence of pseudorandom numbers -but this time with a period much larger than \( M \). -It is also possible to construct more elaborate algorithms by including -more than two past terms in the sum of each iteration. -One example is the generator of Marsaglia and Zaman -which consists of two congruential relations - +Typical periods for the random generators provided in the program library +are of the order of \( \sim 10^9 \) or larger. Other random number generators which have +become increasingly popular are so-called shift-register generators. +In these generators each successive number depends on many preceding +values (rather than the last values as in the linear congruential +generator). +For example, you could make a shift register generator whose $l$th +number is the sum of the $l-i$th and $l-j$th values with modulo \( M \), $$ -\begin{equation} - N_l=(N_{l-3}-N_{l-1})\mathrm{MOD}(2^{31}-69), -\tag{12} -\end{equation} +\begin{equation*} + N_l=(aN_{l-i}+cN_{l-j})\mathrm{MOD}(M). +\end{equation*} $$ - -followed by -$$ -\begin{equation} - N_l=(69069N_{l-1}+1013904243)\mathrm{MOD}(2^{32}), -\tag{13} -\end{equation} -$$ - -which according to the authors has a period larger than \( 2^{94} \).

    @@ -442,7 +435,7 @@ which according to the authors has a period larger than \( 2^{94} \).
  • 55
  • 56
  • ...
  • -
  • 75
  • +
  • 76
  • »
  • diff --git a/doc/pub/Statistics/html/._Statistics-bs047.html b/doc/pub/Statistics/html/._Statistics-bs047.html index 9f991e549..fc659153b 100644 --- a/doc/pub/Statistics/html/._Statistics-bs047.html +++ b/doc/pub/Statistics/html/._Statistics-bs047.html @@ -6,6 +6,7 @@ Automatically generated HTML file from DocOnce source + Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis @@ -55,43 +56,40 @@ $(function () { @@ -296,80 +298,81 @@ MathJax.Hub.Config({ @@ -389,26 +392,29 @@ MathJax.Hub.Config({

    -Instead of using modular addition, we could use the bitwise -exclusive-OR (\( \oplus \)) operation so that +Such a generator again produces a sequence of pseudorandom numbers +but this time with a period much larger than \( M \). +It is also possible to construct more elaborate algorithms by including +more than two past terms in the sum of each iteration. +One example is the generator of Marsaglia and Zaman +which consists of two congruential relations $$ -\begin{equation*} - N_l=(N_{l-i})\oplus (N_{l-j}) -\end{equation*} +\begin{equation} + N_l=(N_{l-3}-N_{l-1})\mathrm{MOD}(2^{31}-69), +\tag{12} +\end{equation} $$ -where the bitwise action of \( \oplus \) means that if \( N_{l-i}=N_{l-j} \) the result is -\( 0 \) whereas if \( N_{l-i}\ne N_{l-j} \) the result is -\( 1 \). As an example, consider the case where \( N_{l-i}=6 \) and \( N_{l-j}=11 \). The first -one has a bit representation (using 4 bits only) which reads \( 0110 \) whereas the -second number is \( 1011 \). Employing the \( \oplus \) operator yields -\( 1101 \), or \( 2^3+2^2+2^0=13 \). +followed by +$$ +\begin{equation} + N_l=(69069N_{l-1}+1013904243)\mathrm{MOD}(2^{32}), +\tag{13} +\end{equation} +$$ -

    -In Fortran90, the bitwise \( \oplus \) operation is coded through the intrinsic -function \( \mathrm{IEOR}(m,n) \) where \( m \) and \( n \) are the input numbers, while in \( C \) -it is given by \( m\wedge n \). +which according to the authors has a period larger than \( 2^{94} \).

    @@ -439,7 +445,7 @@ it is given by \( m\wedge n \).
  • 56
  • 57
  • ...
  • -
  • 75
  • +
  • 76
  • »
  • diff --git a/doc/pub/Statistics/html/._Statistics-bs048.html b/doc/pub/Statistics/html/._Statistics-bs048.html index 2ff5c7903..7987ca36a 100644 --- a/doc/pub/Statistics/html/._Statistics-bs048.html +++ b/doc/pub/Statistics/html/._Statistics-bs048.html @@ -6,6 +6,7 @@ Automatically generated HTML file from DocOnce source + Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis @@ -55,43 +56,40 @@ $(function () { @@ -296,80 +298,81 @@ MathJax.Hub.Config({ @@ -385,46 +388,30 @@ MathJax.Hub.Config({ -

    Random number generator RNG, RAN0

    +

    Random number generator RNG, other examples

    +Instead of using modular addition, we could use the bitwise +exclusive-OR (\( \oplus \)) operation so that + +$$ +\begin{equation*} + N_l=(N_{l-i})\oplus (N_{l-j}) +\end{equation*} +$$ + +where the bitwise action of \( \oplus \) means that if \( N_{l-i}=N_{l-j} \) the result is +\( 0 \) whereas if \( N_{l-i}\ne N_{l-j} \) the result is +\( 1 \). As an example, consider the case where \( N_{l-i}=6 \) and \( N_{l-j}=11 \). The first +one has a bit representation (using 4 bits only) which reads \( 0110 \) whereas the +second number is \( 1011 \). Employing the \( \oplus \) operator yields +\( 1101 \), or \( 2^3+2^2+2^0=13 \).

    -We show here how the linear congruential algorithm can be implemented, namely -$$ -\begin{equation*} - N_i=(aN_{i-1}) \mathrm{MOD} (M). -\end{equation*} -$$ - -However, since \( a \) and \( N_{i-1} \) are integers and their multiplication -could become greater than the standard 32 bit integer, there is a trick via -Schrage's algorithm which approximates the multiplication -of large integers through the factorization -$$ -\begin{equation*} - M=aq+r, -\end{equation*} -$$ - -where we have defined - -$$ -\begin{equation*} - q=[M/a], -\end{equation*} -$$ - -and -$$ -\begin{equation*} - r = M\hspace{0.1cm}\mathrm{MOD} \hspace{0.1cm}a. -\end{equation*} -$$ - -where the brackets denote integer division. In the code below the numbers -\( q \) and \( r \) are chosen so that \( r < q \). +In Fortran90, the bitwise \( \oplus \) operation is coded through the intrinsic +function \( \mathrm{IEOR}(m,n) \) where \( m \) and \( n \) are the input numbers, while in \( C \) +it is given by \( m\wedge n \).

    @@ -455,7 +442,7 @@ where the brackets denote integer division. In the code below the numbers
  • 57
  • 58
  • ...
  • -
  • 75
  • +
  • 76
  • »
  • diff --git a/doc/pub/Statistics/html/._Statistics-bs049.html b/doc/pub/Statistics/html/._Statistics-bs049.html index 39f90ae7d..6a11dc639 100644 --- a/doc/pub/Statistics/html/._Statistics-bs049.html +++ b/doc/pub/Statistics/html/._Statistics-bs049.html @@ -6,6 +6,7 @@ Automatically generated HTML file from DocOnce source + Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis @@ -55,43 +56,40 @@ $(function () { @@ -296,80 +298,81 @@ MathJax.Hub.Config({ @@ -391,17 +394,40 @@ MathJax.Hub.Config({

    -To see how this works we note first that +We show here how the linear congruential algorithm can be implemented, namely $$ -\begin{equation} -(aN_{i-1}) \mathrm{MOD} (M)= (aN_{i-1}-[N_{i-1}/q]M)\mathrm{MOD} (M), -\tag{14} -\end{equation} +\begin{equation*} + N_i=(aN_{i-1}) \mathrm{MOD} (M). +\end{equation*} $$ -since we can add or subtract any integer multiple of \( M \) from \( aN_{i-1} \). -The last term \( [N_{i-1}/q]M\mathrm{MOD}(M) \) is zero since the integer division -\( [N_{i-1}/q] \) just yields a constant which is multiplied with \( M \). +However, since \( a \) and \( N_{i-1} \) are integers and their multiplication +could become greater than the standard 32 bit integer, there is a trick via +Schrage's algorithm which approximates the multiplication +of large integers through the factorization +$$ +\begin{equation*} + M=aq+r, +\end{equation*} +$$ + +where we have defined + +$$ +\begin{equation*} + q=[M/a], +\end{equation*} +$$ + +and +$$ +\begin{equation*} + r = M\hspace{0.1cm}\mathrm{MOD} \hspace{0.1cm}a. +\end{equation*} +$$ + +where the brackets denote integer division. In the code below the numbers +\( q \) and \( r \) are chosen so that \( r < q \). @@ -432,7 +458,7 @@ The last term \( [N_{i-1}/q]M\mathrm{MOD}(M) \) is zero since the integer divisi

  • 58
  • 59
  • ...
  • -
  • 75
  • +
  • 76
  • »
  • diff --git a/doc/pub/Statistics/html/._Statistics-bs050.html b/doc/pub/Statistics/html/._Statistics-bs050.html index b8ea7a3b1..83a2cde5a 100644 --- a/doc/pub/Statistics/html/._Statistics-bs050.html +++ b/doc/pub/Statistics/html/._Statistics-bs050.html @@ -6,6 +6,7 @@ Automatically generated HTML file from DocOnce source + Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis @@ -55,43 +56,40 @@ $(function () { @@ -296,80 +298,81 @@ MathJax.Hub.Config({ @@ -389,32 +392,19 @@ MathJax.Hub.Config({

    -We can now rewrite Eq. (14) as +

    +To see how this works we note first that $$ \begin{equation} -(aN_{i-1}) \mathrm{MOD} (M)= (aN_{i-1}-[N_{i-1}/q](aq+r))\mathrm{MOD} (M), -\tag{15} +(aN_{i-1}) \mathrm{MOD} (M)= (aN_{i-1}-[N_{i-1}/q]M)\mathrm{MOD} (M), +\tag{14} \end{equation} $$ -which results -in - -$$ -\begin{equation} -(aN_{i-1}) \mathrm{MOD} (M)= \left(a(N_{i-1}-[N_{i-1}/q]q)-[N_{i-1}/q]r)\right)\mathrm{MOD} (M), -\tag{16} -\end{equation} -$$ - -yielding -$$ -\begin{equation} -(aN_{i-1}) \mathrm{MOD} (M)= \left(a(N_{i-1}\mathrm{MOD} (q)) -[N_{i-1}/q]r)\right)\mathrm{MOD} (M). -\tag{17} -\end{equation} -$$ +since we can add or subtract any integer multiple of \( M \) from \( aN_{i-1} \). +The last term \( [N_{i-1}/q]M\mathrm{MOD}(M) \) is zero since the integer division +\( [N_{i-1}/q] \) just yields a constant which is multiplied with \( M \).

    @@ -445,7 +435,7 @@ $$
  • 59
  • 60
  • ...
  • -
  • 75
  • +
  • 76
  • »
  • diff --git a/doc/pub/Statistics/html/._Statistics-bs051.html b/doc/pub/Statistics/html/._Statistics-bs051.html index 1b2c4e393..82b9d26f6 100644 --- a/doc/pub/Statistics/html/._Statistics-bs051.html +++ b/doc/pub/Statistics/html/._Statistics-bs051.html @@ -6,6 +6,7 @@ Automatically generated HTML file from DocOnce source + Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis @@ -55,43 +56,40 @@ $(function () { @@ -296,80 +298,81 @@ MathJax.Hub.Config({ @@ -389,18 +392,32 @@ MathJax.Hub.Config({

    -The term \( [N_{i-1}/q]r \) is always smaller or equal \( N_{i-1}(r/q) \) and with \( r < q \) we obtain always a -number smaller than \( N_{i-1} \), which is smaller than \( M \). -And since the number \( N_{i-1}\mathrm{MOD} (q) \) is between zero and \( q-1 \) then -\( a(N_{i-1}\mathrm{MOD} (q)) < aq \). Combined with our definition of \( q=[M/a] \) ensures that -this term is also smaller than \( M \) meaning that both terms fit into a -32-bit signed integer. None of these two terms can be negative, but their difference could. -The algorithm below adds \( M \) if their difference is negative. -Note that the program uses the bitwise \( \oplus \) operator to generate -the starting point for each generation of a random number. The period -of \( ran0 \) is \( \sim 2.1\times 10^{9} \). A special feature of this -algorithm is that is should never be called with the initial seed -set to \( 0 \). +We can now rewrite Eq. (14) as + +$$ +\begin{equation} +(aN_{i-1}) \mathrm{MOD} (M)= (aN_{i-1}-[N_{i-1}/q](aq+r))\mathrm{MOD} (M), +\tag{15} +\end{equation} +$$ + +which results +in + +$$ +\begin{equation} +(aN_{i-1}) \mathrm{MOD} (M)= \left(a(N_{i-1}-[N_{i-1}/q]q)-[N_{i-1}/q]r)\right)\mathrm{MOD} (M), +\tag{16} +\end{equation} +$$ + +yielding +$$ +\begin{equation} +(aN_{i-1}) \mathrm{MOD} (M)= \left(a(N_{i-1}\mathrm{MOD} (q)) -[N_{i-1}/q]r)\right)\mathrm{MOD} (M). +\tag{17} +\end{equation} +$$

    @@ -431,7 +448,7 @@ set to \( 0 \).
  • 60
  • 61
  • ...
  • -
  • 75
  • +
  • 76
  • »
  • diff --git a/doc/pub/Statistics/html/._Statistics-bs052.html b/doc/pub/Statistics/html/._Statistics-bs052.html index 5f0160769..fab83de1c 100644 --- a/doc/pub/Statistics/html/._Statistics-bs052.html +++ b/doc/pub/Statistics/html/._Statistics-bs052.html @@ -6,6 +6,7 @@ Automatically generated HTML file from DocOnce source + Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis @@ -55,43 +56,40 @@ $(function () { @@ -296,80 +298,81 @@ MathJax.Hub.Config({ @@ -385,42 +388,22 @@ MathJax.Hub.Config({ -

    Random number generator RNG, RAN0 code

    +

    Random number generator RNG, RAN0

    - -

    - - -

        /*
    -     ** The function
    -     **           ran0()
    -     ** is an "Minimal" random number generator of Park and Miller
    -     ** Set or reset the input value
    -     ** idum to any integer value (except the unlikely value MASK)
    -     ** to initialize the sequence; idum must not be altered between
    -     ** calls for sucessive deviates in a sequence.
    -     ** The function returns a uniform deviate between 0.0 and 1.0.
    -     */
    -double ran0(long &idum)
    -{
    -   const int a = 16807, m = 2147483647, q = 127773;
    -   const int r = 2836, MASK = 123459876;
    -   const double am = 1./m;
    -   long     k;
    -   double   ans;
    -   idum ^= MASK;
    -   k = (*idum)/q;
    -   idum = a*(idum - k*q) - r*k;
    -   // add m if negative difference
    -   if(idum < 0) idum += m;
    -   ans=am*(idum);
    -   idum ^= MASK;
    -   return ans;
    -} // End: function ran0() 
    -
    -

    +The term \( [N_{i-1}/q]r \) is always smaller or equal \( N_{i-1}(r/q) \) and with \( r < q \) we obtain always a +number smaller than \( N_{i-1} \), which is smaller than \( M \). +And since the number \( N_{i-1}\mathrm{MOD} (q) \) is between zero and \( q-1 \) then +\( a(N_{i-1}\mathrm{MOD} (q)) < aq \). Combined with our definition of \( q=[M/a] \) ensures that +this term is also smaller than \( M \) meaning that both terms fit into a +32-bit signed integer. None of these two terms can be negative, but their difference could. +The algorithm below adds \( M \) if their difference is negative. +Note that the program uses the bitwise \( \oplus \) operator to generate +the starting point for each generation of a random number. The period +of \( ran0 \) is \( \sim 2.1\times 10^{9} \). A special feature of this +algorithm is that is should never be called with the initial seed +set to \( 0 \).

    @@ -451,7 +434,7 @@ MathJax.Hub.Config({
  • 61
  • 62
  • ...
  • -
  • 75
  • +
  • 76
  • »
  • diff --git a/doc/pub/Statistics/html/._Statistics-bs053.html b/doc/pub/Statistics/html/._Statistics-bs053.html index 0756a324f..6c7491a10 100644 --- a/doc/pub/Statistics/html/._Statistics-bs053.html +++ b/doc/pub/Statistics/html/._Statistics-bs053.html @@ -6,6 +6,7 @@ Automatically generated HTML file from DocOnce source + Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis @@ -55,43 +56,40 @@ $(function () { @@ -296,80 +298,81 @@ MathJax.Hub.Config({ @@ -385,27 +388,42 @@ MathJax.Hub.Config({ -

    Properties of Selected Random Number Generators

    +

    Random number generator RNG, RAN0 code

    -As mentioned previously, the underlying PDF for the generation of -random numbers is the uniform distribution, meaning that the -probability for finding a number \( x \) in the interval [0,1] is \( p(x)=1 \). + +

        /*
    +     ** The function
    +     **           ran0()
    +     ** is an "Minimal" random number generator of Park and Miller
    +     ** Set or reset the input value
    +     ** idum to any integer value (except the unlikely value MASK)
    +     ** to initialize the sequence; idum must not be altered between
    +     ** calls for sucessive deviates in a sequence.
    +     ** The function returns a uniform deviate between 0.0 and 1.0.
    +     */
    +double ran0(long &idum)
    +{
    +   const int a = 16807, m = 2147483647, q = 127773;
    +   const int r = 2836, MASK = 123459876;
    +   const double am = 1./m;
    +   long     k;
    +   double   ans;
    +   idum ^= MASK;
    +   k = (*idum)/q;
    +   idum = a*(idum - k*q) - r*k;
    +   // add m if negative difference
    +   if(idum < 0) idum += m;
    +   ans=am*(idum);
    +   idum ^= MASK;
    +   return ans;
    +} // End: function ran0() 
    +

    -A random number generator should produce numbers which are uniformly distributed -in this interval. The table shows the distribution of \( N=10000 \) random -numbers generated by the functions in the program library. -We note in this table that the number of points in the various -intervals \( 0.0-0.1 \), \( 0.1-0.2 \) etc are fairly close to \( 1000 \), with some minor -deviations. - -

    -Two additional measures are the standard deviation \( \sigma \) and the mean -\( \mu=\langle x\rangle \).

    @@ -436,7 +454,7 @@ Two additional measures are the standard deviation \( \sigma \) and the mean
  • 62
  • 63
  • ...
  • -
  • 75
  • +
  • 76
  • »
  • diff --git a/doc/pub/Statistics/html/._Statistics-bs054.html b/doc/pub/Statistics/html/._Statistics-bs054.html index f31f1200c..c3d0702dd 100644 --- a/doc/pub/Statistics/html/._Statistics-bs054.html +++ b/doc/pub/Statistics/html/._Statistics-bs054.html @@ -6,6 +6,7 @@ Automatically generated HTML file from DocOnce source + Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis @@ -55,43 +56,40 @@ $(function () { @@ -296,80 +298,81 @@ MathJax.Hub.Config({ @@ -389,21 +392,23 @@ MathJax.Hub.Config({

    -For the uniform distribution, the mean value \( \mu \) is then -$$ -\begin{equation*} - \mu=\langle x\rangle=\frac{1}{2} -\end{equation*} -$$ +

    +As mentioned previously, the underlying PDF for the generation of +random numbers is the uniform distribution, meaning that the +probability for finding a number \( x \) in the interval [0,1] is \( p(x)=1 \). -while the standard deviation is +

    +A random number generator should produce numbers which are uniformly distributed +in this interval. The table shows the distribution of \( N=10000 \) random +numbers generated by the functions in the program library. +We note in this table that the number of points in the various +intervals \( 0.0-0.1 \), \( 0.1-0.2 \) etc are fairly close to \( 1000 \), with some minor +deviations. -$$ -\begin{equation*} - \sigma=\sqrt{\langle x^2\rangle-\mu^2}=\frac{1}{\sqrt{12}}=0.2886. -\end{equation*} -$$ +

    +Two additional measures are the standard deviation \( \sigma \) and the mean +\( \mu=\langle x\rangle \).

    @@ -434,7 +439,7 @@ $$
  • 63
  • 64
  • ...
  • -
  • 75
  • +
  • 76
  • »
  • diff --git a/doc/pub/Statistics/html/._Statistics-bs055.html b/doc/pub/Statistics/html/._Statistics-bs055.html index 15e4f5c5e..213b8d3f5 100644 --- a/doc/pub/Statistics/html/._Statistics-bs055.html +++ b/doc/pub/Statistics/html/._Statistics-bs055.html @@ -6,6 +6,7 @@ Automatically generated HTML file from DocOnce source + Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis @@ -55,43 +56,40 @@ $(function () { @@ -296,80 +298,81 @@ MathJax.Hub.Config({ @@ -389,35 +392,21 @@ MathJax.Hub.Config({

    -The various random number generators produce results which agree rather well with -these limiting values. +For the uniform distribution, the mean value \( \mu \) is then -

    +$$ +\begin{equation*} + \mu=\langle x\rangle=\frac{1}{2} +\end{equation*} +$$ -

    -
    - - - - - - - - - - - - - - - - - - -
    \( x \)-bin ran0 ran1 ran2 ran3
    0.0-0.1 1013 991 938 1047
    0.1-0.2 1002 1009 1040 1030
    0.2-0.3 989 999 1030 993
    0.3-0.4 939 960 1023 937
    0.4-0.5 1038 1001 1002 992
    0.5-0.6 1037 1047 1009 1009
    0.6-0.7 1005 989 1003 989
    0.7-0.8 986 962 985 954
    0.8-0.9 1000 1027 1009 1023
    0.9-1.0 991 1015 961 1026
    \( \mu \) 0.4997 0.5018 0.4992 0.4990
    \( \sigma \) 0.2882 0.2892 0.2861 0.2915
    -
    -
    -

    +while the standard deviation is + +$$ +\begin{equation*} + \sigma=\sqrt{\langle x^2\rangle-\mu^2}=\frac{1}{\sqrt{12}}=0.2886. +\end{equation*} +$$

    @@ -448,7 +437,7 @@ these limiting values.
  • 64
  • 65
  • ...
  • -
  • 75
  • +
  • 76
  • »
  • diff --git a/doc/pub/Statistics/html/._Statistics-bs056.html b/doc/pub/Statistics/html/._Statistics-bs056.html index ddcefa5ca..f53b8e4c6 100644 --- a/doc/pub/Statistics/html/._Statistics-bs056.html +++ b/doc/pub/Statistics/html/._Statistics-bs056.html @@ -6,6 +6,7 @@ Automatically generated HTML file from DocOnce source + Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis @@ -55,43 +56,40 @@ $(function () { @@ -296,80 +298,81 @@ MathJax.Hub.Config({ @@ -385,39 +388,38 @@ MathJax.Hub.Config({ -

    Simple demonstration of RNGs using python

    +

    Properties of Selected Random Number Generators

    -The following simple Python code plots the distribution of the produced random numbers using the linear congruential RNG employed by Python. The trend displayed in the previous table is seen rather clearly. +The various random number generators produce results which agree rather well with +these limiting values. +

    - -

    +
    +
    + + + + + + + + + + + + + + + + + + +
    \( x \)-bin ran0 ran1 ran2 ran3
    0.0-0.1 1013 991 938 1047
    0.1-0.2 1002 1009 1040 1030
    0.2-0.3 989 999 1030 993
    0.3-0.4 939 960 1023 937
    0.4-0.5 1038 1001 1002 992
    0.5-0.6 1037 1047 1009 1009
    0.6-0.7 1005 989 1003 989
    0.7-0.8 986 962 985 954
    0.8-0.9 1000 1027 1009 1023
    0.9-1.0 991 1015 961 1026
    \( \mu \) 0.4997 0.5018 0.4992 0.4990
    \( \sigma \) 0.2882 0.2892 0.2861 0.2915
    +
    +

    @@ -449,7 +451,7 @@ plt.show()
  • 65
  • 66
  • ...
  • -
  • 75
  • +
  • 76
  • »
  • diff --git a/doc/pub/Statistics/html/._Statistics-bs057.html b/doc/pub/Statistics/html/._Statistics-bs057.html index 5935bca55..ba4a9c026 100644 --- a/doc/pub/Statistics/html/._Statistics-bs057.html +++ b/doc/pub/Statistics/html/._Statistics-bs057.html @@ -6,6 +6,7 @@ Automatically generated HTML file from DocOnce source + Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis @@ -55,43 +56,40 @@ $(function () { @@ -296,80 +298,81 @@ MathJax.Hub.Config({ @@ -385,36 +388,39 @@ MathJax.Hub.Config({ -

    Properties of Selected Random Number Generators

    +

    Simple demonstration of RNGs using python

    -Since our random numbers, which are typically generated via a linear congruential algorithm, -are never fully independent, we can then define -an important test which measures the degree of correlation, namely the so-called -auto-correlation function defined previously, see again Eq. (9). -We rewrite it here as -$$ -\begin{equation*} - C_k=\frac{f_d} - {\sigma^2}, -\end{equation*} -$$ - -with \( C_0=1 \). Recall that -\( \sigma^2=\langle x_i^2\rangle-\langle x_i\rangle^2 \) and that -$$ -\begin{equation*} -f_d = \frac{1}{nm}\sum_{\alpha=1}^m\sum_{k=1}^{n-d}(x_{\alpha,k}-\langle X_m \rangle)(x_{\alpha,k+d}-\langle X_m \rangle), -\end{equation*} -$$ - +The following simple Python code plots the distribution of the produced random numbers using the linear congruential RNG employed by Python. The trend displayed in the previous table is seen rather clearly.

    -The non-vanishing of \( C_k \) for \( k\ne 0 \) means that the random -numbers are not independent. The independence of the random numbers is crucial -in the evaluation of other expectation values. If they are not independent, our -assumption for approximating \( \sigma_N \) is no longer valid. + +

    @@ -446,7 +452,7 @@ assumption for approximating \( \sigma_N \) is no longer valid.
  • 66
  • 67
  • ...
  • -
  • 75
  • +
  • 76
  • »
  • diff --git a/doc/pub/Statistics/html/._Statistics-bs058.html b/doc/pub/Statistics/html/._Statistics-bs058.html index 6fa85950c..b02ceadb8 100644 --- a/doc/pub/Statistics/html/._Statistics-bs058.html +++ b/doc/pub/Statistics/html/._Statistics-bs058.html @@ -6,6 +6,7 @@ Automatically generated HTML file from DocOnce source + Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis @@ -55,43 +56,40 @@ $(function () { @@ -296,80 +298,81 @@ MathJax.Hub.Config({ @@ -385,44 +388,40 @@ MathJax.Hub.Config({ -

    Autocorrelation function

    -This program computes the autocorrelation function as discussed in the equation on the previous slide for random numbers generated with the normal distribution \( N(0,1) \). +

    Properties of Selected Random Number Generators

    +
    +
    +

    +Since our random numbers, which are typically generated via a linear congruential algorithm, +are never fully independent, we can then define +an important test which measures the degree of correlation, namely the so-called +auto-correlation function defined previously, see again Eq. (9). +We rewrite it here as +$$ +\begin{equation*} + C_k=\frac{f_d} + {\sigma^2}, +\end{equation*} +$$ + +with \( C_0=1 \). Recall that +\( \sigma^2=\langle x_i^2\rangle-\langle x_i\rangle^2 \) and that +$$ +\begin{equation*} +f_d = \frac{1}{nm}\sum_{\alpha=1}^m\sum_{k=1}^{n-d}(x_{\alpha,k}-\langle X_m \rangle)(x_{\alpha,k+d}-\langle X_m \rangle), +\end{equation*} +$$ +

    +The non-vanishing of \( C_k \) for \( k\ne 0 \) means that the random +numbers are not independent. The independence of the random numbers is crucial +in the evaluation of other expectation values. If they are not independent, our +assumption for approximating \( \sigma_N \) is no longer valid. - -

    # Importing various packages
    -from math import exp, sqrt
    -from random import random, seed
    -import numpy as np
    -import matplotlib.pyplot as plt
    -
    -def autocovariance(x, n, k, mean_x):
    -    sum = 0.0
    -    for i in range(0, n-k):
    -        sum += (x[(i+k)]-mean_x)*(x[i]-mean_x)
    -    return  sum/n
    -
    -n = 1000
    -x=np.random.normal(size=n)
    -autocor = np.zeros(n)
    -figaxis = np.zeros(n)
    -mean_x=np.mean(x)
    -var_x = np.var(x)
    -print(mean_x, var_x)
    -for i in range (0, n):
    -    figaxis[i] = i
    -    autocor[i]=(autocovariance(x, n, i, mean_x))/var_x    
    -
    -plt.plot(figaxis, autocor, "r-")
    -plt.axis([0,n,-0.1, 1.0])
    -plt.xlabel(r'$i$')
    -plt.ylabel(r'$\gamma_i$')
    -plt.title(r'Autocorrelation function')
    -plt.show()
    -

    -As can be seen from the plot, the first point gives back the variance and a value of one. -For the remaining values we notice that there are still non-zero values for the auto-correlation function. +

    +
    +

    @@ -450,7 +449,7 @@ For the remaining values we notice that there are still non-zero values for the

  • 67
  • 68
  • ...
  • -
  • 75
  • +
  • 76
  • »
  • diff --git a/doc/pub/Statistics/html/._Statistics-bs059.html b/doc/pub/Statistics/html/._Statistics-bs059.html index e3aa089f6..f0b2969c6 100644 --- a/doc/pub/Statistics/html/._Statistics-bs059.html +++ b/doc/pub/Statistics/html/._Statistics-bs059.html @@ -6,6 +6,7 @@ Automatically generated HTML file from DocOnce source + Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis @@ -55,43 +56,40 @@ $(function () { @@ -296,80 +298,81 @@ MathJax.Hub.Config({ @@ -385,85 +388,44 @@ MathJax.Hub.Config({ -

    Correlation function and which random number generators should I use

    -
    -
    -

    -The program here computes the correlation function for one of the standard functions included with the c++ compiler. +

    Autocorrelation function

    +This program computes the autocorrelation function as discussed in the equation on the previous slide for random numbers generated with the normal distribution \( N(0,1) \).

    - -

    //  This function computes the autocorrelation function for 
    -//  the standard c++ random number generator
    +
    +
    # Importing various packages
    +from math import exp, sqrt
    +from random import random, seed
    +import numpy as np
    +import matplotlib.pyplot as plt
     
    -#include <fstream>
    -#include <iomanip>
    -#include <iostream>
    -#include <cmath>
    -using namespace std;
    -// output file as global variable
    -ofstream ofile;  
    +def autocovariance(x, n, k, mean_x):
    +    sum = 0.0
    +    for i in range(0, n-k):
    +        sum += (x[(i+k)]-mean_x)*(x[i]-mean_x)
    +    return  sum/n
     
    -//     Main function begins here     
    -int main(int argc, char* argv[])
    -{
    -     int n;
    -     char *outfilename;
    +n = 1000
    +x=np.random.normal(size=n)
    +autocor = np.zeros(n)
    +figaxis = np.zeros(n)
    +mean_x=np.mean(x)
    +var_x = np.var(x)
    +print(mean_x, var_x)
    +for i in range (0, n):
    +    figaxis[i] = i
    +    autocor[i]=(autocovariance(x, n, i, mean_x))/var_x    
     
    -     cin >> n;
    -     double MCint = 0.;      double MCintsqr2=0.;
    -     double invers_period = 1./RAND_MAX; // initialise the random number generator
    -     srand(time(NULL));  // This produces the so-called seed in MC jargon
    -     // Compute the variance and the mean value of the uniform distribution
    -     // Compute also the specific values x for each cycle in order to be able to
    -     // the covariance and the correlation function  
    -     // Read in output file, abort if there are too few command-line arguments
    -     if( argc <= 2 ){
    -       cout << "Bad Usage: " << argv[0] << 
    -	 " read also output file and number of cycles on same line" << endl;
    -       exit(1);
    -     }
    -     else{
    -       outfilename=argv[1];
    -     }
    -     ofile.open(outfilename); 
    -     // Get  the number of Monte-Carlo samples
    -     n = atoi(argv[2]);
    -     double *X;  
    -     X = new double[n];
    -     for (int i = 0;  i < n; i++){
    -           double x = double(rand())*invers_period; 
    -           X[i] = x;
    -           MCint += x;
    -           MCintsqr2 += x*x;
    -     }
    -     double Mean = MCint/((double) n );
    -     MCintsqr2 = MCintsqr2/((double) n );
    -     double STDev = sqrt(MCintsqr2-Mean*Mean);
    -     double Variance = MCintsqr2-Mean*Mean;
    -//   Write mean value and standard deviation 
    -     cout << " Standard deviation= " << STDev << " Integral = " << Mean << endl;
    -
    -     // Now we compute the autocorrelation function
    -     double *autocor;  autocor = new double[n];
    -     for (int j = 0; j < n; j++){
    -       double sum = 0.0;
    -       for (int k = 0; k < (n-j); k++){
    -	 sum  += (X[k]-Mean)*(X[k+j]-Mean); 
    -       }
    -       autocor[j] = sum/Variance/((double) n );
    -       ofile << setiosflags(ios::showpoint | ios::uppercase);
    -       ofile << setw(15) << setprecision(8) << j;
    -       ofile << setw(15) << setprecision(8) << autocor[j] << endl;
    -     }
    -     ofile.close();  // close output file
    -     return 0;
    -}  // end of main program 
    +plt.plot(figaxis, autocor, "r-")
    +plt.axis([0,n,-0.1, 1.0])
    +plt.xlabel(r'$i$')
    +plt.ylabel(r'$\gamma_i$')
    +plt.title(r'Autocorrelation function')
    +plt.show()
     

    -

    -
    - +As can be seen from the plot, the first point gives back the variance and a value of one. +For the remaining values we notice that there are still non-zero values for the auto-correlation function.

    @@ -491,7 +453,7 @@ ofstream ofile;

  • 68
  • 69
  • ...
  • -
  • 75
  • +
  • 76
  • »
  • diff --git a/doc/pub/Statistics/html/._Statistics-bs060.html b/doc/pub/Statistics/html/._Statistics-bs060.html index c57063634..032098c40 100644 --- a/doc/pub/Statistics/html/._Statistics-bs060.html +++ b/doc/pub/Statistics/html/._Statistics-bs060.html @@ -6,6 +6,7 @@ Automatically generated HTML file from DocOnce source + Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis @@ -55,43 +56,40 @@ $(function () { @@ -296,80 +298,81 @@ MathJax.Hub.Config({ @@ -385,15 +388,82 @@ MathJax.Hub.Config({ -

    Which RNG should I use?

    +

    Correlation function and which random number generators should I use

    +The program here computes the correlation function for one of the standard functions included with the c++ compiler. +

    -

      -
    • C++ has a class called random. The random class contains a large selection of RNGs and is highly recommended. Some of these RNGs have very large periods making it thereby very safe to use these RNGs in case one is performing large calculations. In particular, the Mersenne twister random number engine has a period of \( 2^{19937} \).
    • -
    • Add RNGs in Python
    • -
    + +
    //  This function computes the autocorrelation function for 
    +//  the standard c++ random number generator
    +
    +#include <fstream>
    +#include <iomanip>
    +#include <iostream>
    +#include <cmath>
    +using namespace std;
    +// output file as global variable
    +ofstream ofile;  
    +
    +//     Main function begins here     
    +int main(int argc, char* argv[])
    +{
    +     int n;
    +     char *outfilename;
    +
    +     cin >> n;
    +     double MCint = 0.;      double MCintsqr2=0.;
    +     double invers_period = 1./RAND_MAX; // initialise the random number generator
    +     srand(time(NULL));  // This produces the so-called seed in MC jargon
    +     // Compute the variance and the mean value of the uniform distribution
    +     // Compute also the specific values x for each cycle in order to be able to
    +     // the covariance and the correlation function  
    +     // Read in output file, abort if there are too few command-line arguments
    +     if( argc <= 2 ){
    +       cout << "Bad Usage: " << argv[0] << 
    +	 " read also output file and number of cycles on same line" << endl;
    +       exit(1);
    +     }
    +     else{
    +       outfilename=argv[1];
    +     }
    +     ofile.open(outfilename); 
    +     // Get  the number of Monte-Carlo samples
    +     n = atoi(argv[2]);
    +     double *X;  
    +     X = new double[n];
    +     for (int i = 0;  i < n; i++){
    +           double x = double(rand())*invers_period; 
    +           X[i] = x;
    +           MCint += x;
    +           MCintsqr2 += x*x;
    +     }
    +     double Mean = MCint/((double) n );
    +     MCintsqr2 = MCintsqr2/((double) n );
    +     double STDev = sqrt(MCintsqr2-Mean*Mean);
    +     double Variance = MCintsqr2-Mean*Mean;
    +//   Write mean value and standard deviation 
    +     cout << " Standard deviation= " << STDev << " Integral = " << Mean << endl;
    +
    +     // Now we compute the autocorrelation function
    +     double *autocor;  autocor = new double[n];
    +     for (int j = 0; j < n; j++){
    +       double sum = 0.0;
    +       for (int k = 0; k < (n-j); k++){
    +	 sum  += (X[k]-Mean)*(X[k+j]-Mean); 
    +       }
    +       autocor[j] = sum/Variance/((double) n );
    +       ofile << setiosflags(ios::showpoint | ios::uppercase);
    +       ofile << setw(15) << setprecision(8) << j;
    +       ofile << setw(15) << setprecision(8) << autocor[j] << endl;
    +     }
    +     ofile.close();  // close output file
    +     return 0;
    +}  // end of main program 
    +
    +

    @@ -424,7 +494,7 @@ MathJax.Hub.Config({
  • 69
  • 70
  • ...
  • -
  • 75
  • +
  • 76
  • »
  • diff --git a/doc/pub/Statistics/html/._Statistics-bs061.html b/doc/pub/Statistics/html/._Statistics-bs061.html index 6ddd0f5bc..668fe7383 100644 --- a/doc/pub/Statistics/html/._Statistics-bs061.html +++ b/doc/pub/Statistics/html/._Statistics-bs061.html @@ -6,6 +6,7 @@ Automatically generated HTML file from DocOnce source + Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis @@ -55,43 +56,40 @@ $(function () { @@ -296,80 +298,81 @@ MathJax.Hub.Config({ @@ -385,29 +388,15 @@ MathJax.Hub.Config({ -

    How to use the Mersenne generator

    +

    Which RNG should I use?

    -The following part of a c++ code (from project 4) sets up the uniform distribution for \( x\in [0,1] \). -

    - -

    /*
    -
    -//  You need this 
    -#include <random>
    -
    -// Initialize the seed and call the Mersienne algo
    -std::random_device rd;
    -std::mt19937_64 gen(rd());
    -// Set up the uniform distribution for x \in [[0, 1]
    -std::uniform_real_distribution<double> RandomNumberGenerator(0.0,1.0);
    -
    -// Now use the RNG
    -int ix = (int) (RandomNumberGenerator(gen)*NSpins);
    -
    -

    +

      +
    • C++ has a class called random. The random class contains a large selection of RNGs and is highly recommended. Some of these RNGs have very large periods making it thereby very safe to use these RNGs in case one is performing large calculations. In particular, the Mersenne twister random number engine has a period of \( 2^{19937} \).
    • +
    • Add RNGs in Python
    • +
    @@ -438,7 +427,7 @@ The following part of a c++ code (from project 4) sets up the uniform distributi
  • 70
  • 71
  • ...
  • -
  • 75
  • +
  • 76
  • »
  • diff --git a/doc/pub/Statistics/html/._Statistics-bs062.html b/doc/pub/Statistics/html/._Statistics-bs062.html index e9e92e740..43717379f 100644 --- a/doc/pub/Statistics/html/._Statistics-bs062.html +++ b/doc/pub/Statistics/html/._Statistics-bs062.html @@ -6,6 +6,7 @@ Automatically generated HTML file from DocOnce source + Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis @@ -55,43 +56,40 @@ $(function () { @@ -296,80 +298,81 @@ MathJax.Hub.Config({ @@ -385,19 +388,28 @@ MathJax.Hub.Config({ -

    Why blocking?

    +

    How to use the Mersenne generator

    +The following part of a c++ code (from project 4) sets up the uniform distribution for \( x\in [0,1] \). +

    -

      -
    • Monte Carlo simulations can be treated as computer experiments
    • -
    • The results can be analysed with the same statistical tools as we would use analysing experimental data.
    • -
    • As in all experiments, we are looking for expectation values and an estimate of how accurate they are, i.e., possible sources for errors.
    • -
    + +
    /*
     
    -A very good article which explains blocking is H. Flyvbjerg and H. G. Petersen, Error estimates on averages of correlated data,  Journal of Chemical Physics 91, 461-466 (1989).
    +//  You need this 
    +#include <random>
     
    +// Initialize the seed and call the Mersienne algo
    +std::random_device rd;
    +std::mt19937_64 gen(rd());
    +// Set up the uniform distribution for x \in [[0, 1]
    +std::uniform_real_distribution<double> RandomNumberGenerator(0.0,1.0);
    +
    +// Now use the RNG
    +int ix = (int) (RandomNumberGenerator(gen)*NSpins);
    +

    @@ -429,7 +441,7 @@ A very good article which explains blocking is H. Flyvbjerg and H. G. Petersen,
  • 71
  • 72
  • ...
  • -
  • 75
  • +
  • 76
  • »
  • diff --git a/doc/pub/Statistics/html/._Statistics-bs063.html b/doc/pub/Statistics/html/._Statistics-bs063.html index cf9b3be9e..359e21b86 100644 --- a/doc/pub/Statistics/html/._Statistics-bs063.html +++ b/doc/pub/Statistics/html/._Statistics-bs063.html @@ -6,6 +6,7 @@ Automatically generated HTML file from DocOnce source + Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis @@ -55,43 +56,40 @@ $(function () { @@ -296,80 +298,81 @@ MathJax.Hub.Config({ @@ -391,16 +394,14 @@ MathJax.Hub.Config({

    +A very good article which explains blocking is H. Flyvbjerg and H. G. Petersen, Error estimates on averages of correlated data, Journal of Chemical Physics 91, 461-466 (1989). + +

    @@ -431,7 +432,7 @@ MathJax.Hub.Config({
  • 72
  • 73
  • ...
  • -
  • 75
  • +
  • 76
  • »
  • diff --git a/doc/pub/Statistics/html/._Statistics-bs064.html b/doc/pub/Statistics/html/._Statistics-bs064.html index 536a1adca..14c5e10cd 100644 --- a/doc/pub/Statistics/html/._Statistics-bs064.html +++ b/doc/pub/Statistics/html/._Statistics-bs064.html @@ -6,6 +6,7 @@ Automatically generated HTML file from DocOnce source + Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis @@ -55,43 +56,40 @@ $(function () { @@ -296,80 +298,81 @@ MathJax.Hub.Config({ @@ -385,91 +388,26 @@ MathJax.Hub.Config({ -

    Code to demonstrate the calculation of the autocorrelation function

    -The following code computes the autocorrelation function, the covariance and the standard deviation -for standard RNG. -The following file gives the code. -

    +

    Why blocking?

    +
    +
    +

    - -

    //  This function computes the autocorrelation function for 
    -//  the Mersenne random number generator with a uniform distribution
    -#include <iostream>
    -#include <fstream>
    -#include <iomanip>
    -#include <cstdlib>
    -#include <random>
    -#include <armadillo>
    -#include <string>
    -#include <cmath>
    -using namespace  std;
    -using namespace arma;
    -// output file
    -ofstream ofile;
    +
      +
    • As in other experiments, Monte Carlo experiments have two classes of errors:
    • -// Main function begins here -int main(int argc, char* argv[]) -{ - int MonteCarloCycles; - string filename; - if (argc > 1) { - filename=argv[1]; - MonteCarloCycles = atoi(argv[2]); - string fileout = filename; - string argument = to_string(MonteCarloCycles); - fileout.append(argument); - ofile.open(fileout); - } +
        +
      • Statistical errors
      • +
      • Systematical errors
      • +
      - // Compute the variance and the mean value of the uniform distribution - // Compute also the specific values x for each cycle in order to be able to - // compute the covariance and the correlation function +
    • Statistical errors can be estimated using standard tools from statistics
    • +
    • Systematical errors are method specific and must be treated differently from case to case. (In VMC a common source is the step length or time step in importance sampling)
    • +
    +
    +
    - vec X = zeros<vec>(MonteCarloCycles); - double MCint = 0.; double MCintsqr2=0.; - std::random_device rd; - std::mt19937_64 gen(rd()); - // Set up the uniform distribution for x \in [[0, 1] - std::uniform_real_distribution<double> RandomNumberGenerator(0.0,1.0); - for (int i = 0; i < MonteCarloCycles; i++){ - double x = RandomNumberGenerator(gen); - X(i) = x; - MCint += x; - MCintsqr2 += x*x; - } - double Mean = MCint/((double) MonteCarloCycles ); - MCintsqr2 = MCintsqr2/((double) MonteCarloCycles ); - double STDev = sqrt(MCintsqr2-Mean*Mean); - double Variance = MCintsqr2-Mean*Mean; - // Write mean value and variance - cout << " Sample variance= " << Variance << " Mean value = " << Mean << endl; - // Now we compute the autocorrelation function - vec autocorrelation = zeros<vec>(MonteCarloCycles); - for (int j = 0; j < MonteCarloCycles; j++){ - double sum = 0.0; - for (int k = 0; k < (MonteCarloCycles-j); k++){ - sum += (X(k)-Mean)*(X(k+j)-Mean); - } - autocorrelation(j) = sum/Variance/((double) MonteCarloCycles ); - ofile << setiosflags(ios::showpoint | ios::uppercase); - ofile << setw(15) << setprecision(8) << j; - ofile << setw(15) << setprecision(8) << autocorrelation(j) << endl; - } - // Now compute the exact covariance using the autocorrelation function - double Covariance = 0.0; - for (int j = 0; j < MonteCarloCycles; j++){ - Covariance += autocorrelation(j); - } - Covariance *= 2.0/((double) MonteCarloCycles); - // Compute now the total variance, including the covariance, and obtain the standard deviation - double TotalVariance = (Variance/((double) MonteCarloCycles ))+Covariance; - cout << "Covariance =" << Covariance << "Totalvariance= " << TotalVariance << "Sample Variance/n= " << (Variance/((double) MonteCarloCycles )) << endl; - cout << " STD from sample variance= " << sqrt(Variance/((double) MonteCarloCycles )) << " STD with covariance = " << sqrt(TotalVariance) << endl; - ofile.close(); // close output file - return 0; -} // end of main program -

    @@ -496,7 +434,7 @@ ofstream ofile;

  • 73
  • 74
  • ...
  • -
  • 75
  • +
  • 76
  • »
  • diff --git a/doc/pub/Statistics/html/._Statistics-bs065.html b/doc/pub/Statistics/html/._Statistics-bs065.html index c21de1405..0403e0e4a 100644 --- a/doc/pub/Statistics/html/._Statistics-bs065.html +++ b/doc/pub/Statistics/html/._Statistics-bs065.html @@ -6,6 +6,7 @@ Automatically generated HTML file from DocOnce source + Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis @@ -55,43 +56,40 @@ $(function () { @@ -296,80 +298,81 @@ MathJax.Hub.Config({ @@ -385,34 +388,91 @@ MathJax.Hub.Config({ -

    What is blocking?

    -
    -
    -

    +

    Code to demonstrate the calculation of the autocorrelation function

    +The following code computes the autocorrelation function, the covariance and the standard deviation +for standard RNG. +The following file gives the code. +

    -

    + +
    //  This function computes the autocorrelation function for 
    +//  the Mersenne random number generator with a uniform distribution
    +#include <iostream>
    +#include <fstream>
    +#include <iomanip>
    +#include <cstdlib>
    +#include <random>
    +#include <armadillo>
    +#include <string>
    +#include <cmath>
    +using namespace  std;
    +using namespace arma;
    +// output file
    +ofstream ofile;
     
    -$$
    -\sigma=\sqrt{\frac{1}{n}\left(\langle \mathbf{M}^2\rangle-\langle \mathbf{M}\rangle^2\right)} 
    -$$
    +//     Main function begins here     
    +int main(int argc, char* argv[])
    +{
    +  int MonteCarloCycles;
    +  string filename;
    +  if (argc > 1) {
    +    filename=argv[1];
    +    MonteCarloCycles = atoi(argv[2]);
    +    string fileout = filename;
    +    string argument = to_string(MonteCarloCycles);
    +    fileout.append(argument);
    +    ofile.open(fileout);
    +  }
     
    +  // Compute the variance and the mean value of the uniform distribution
    +  // Compute also the specific values x for each cycle in order to be able to
    +  // compute the covariance and the correlation function  
     
    -
      -
    • If the samples are correlated we can rewrite our results to show that
    • -
    - -$$ -\sigma=\sqrt{\frac{1+2\tau/\Delta t}{n}\left(\langle \mathbf{M}^2\rangle-\langle \mathbf{M}\rangle^2\right)} -$$ - - where \( \tau \) is the correlation time (the time between a sample and the next uncorrelated sample) and \( \Delta t \) is time between each sample -
    -
    - + vec X = zeros<vec>(MonteCarloCycles); + double MCint = 0.; double MCintsqr2=0.; + std::random_device rd; + std::mt19937_64 gen(rd()); + // Set up the uniform distribution for x \in [[0, 1] + std::uniform_real_distribution<double> RandomNumberGenerator(0.0,1.0); + for (int i = 0; i < MonteCarloCycles; i++){ + double x = RandomNumberGenerator(gen); + X(i) = x; + MCint += x; + MCintsqr2 += x*x; + } + double Mean = MCint/((double) MonteCarloCycles ); + MCintsqr2 = MCintsqr2/((double) MonteCarloCycles ); + double STDev = sqrt(MCintsqr2-Mean*Mean); + double Variance = MCintsqr2-Mean*Mean; + // Write mean value and variance + cout << " Sample variance= " << Variance << " Mean value = " << Mean << endl; + // Now we compute the autocorrelation function + vec autocorrelation = zeros<vec>(MonteCarloCycles); + for (int j = 0; j < MonteCarloCycles; j++){ + double sum = 0.0; + for (int k = 0; k < (MonteCarloCycles-j); k++){ + sum += (X(k)-Mean)*(X(k+j)-Mean); + } + autocorrelation(j) = sum/Variance/((double) MonteCarloCycles ); + ofile << setiosflags(ios::showpoint | ios::uppercase); + ofile << setw(15) << setprecision(8) << j; + ofile << setw(15) << setprecision(8) << autocorrelation(j) << endl; + } + // Now compute the exact covariance using the autocorrelation function + double Covariance = 0.0; + for (int j = 0; j < MonteCarloCycles; j++){ + Covariance += autocorrelation(j); + } + Covariance *= 2.0/((double) MonteCarloCycles); + // Compute now the total variance, including the covariance, and obtain the standard deviation + double TotalVariance = (Variance/((double) MonteCarloCycles ))+Covariance; + cout << "Covariance =" << Covariance << "Totalvariance= " << TotalVariance << "Sample Variance/n= " << (Variance/((double) MonteCarloCycles )) << endl; + cout << " STD from sample variance= " << sqrt(Variance/((double) MonteCarloCycles )) << " STD with covariance = " << sqrt(TotalVariance) << endl; + ofile.close(); // close output file + return 0; +} // end of main program +

    @@ -438,6 +498,8 @@ $$

  • 73
  • 74
  • 75
  • +
  • ...
  • +
  • 76
  • »
  • diff --git a/doc/pub/Statistics/html/._Statistics-bs066.html b/doc/pub/Statistics/html/._Statistics-bs066.html index b44d6f692..a835c3a76 100644 --- a/doc/pub/Statistics/html/._Statistics-bs066.html +++ b/doc/pub/Statistics/html/._Statistics-bs066.html @@ -6,6 +6,7 @@ Automatically generated HTML file from DocOnce source + Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis @@ -55,43 +56,40 @@ $(function () { @@ -296,80 +298,81 @@ MathJax.Hub.Config({ @@ -391,13 +394,24 @@ MathJax.Hub.Config({

    + +$$ +\sigma=\sqrt{\frac{1}{n}\left(\langle \mathbf{M}^2\rangle-\langle \mathbf{M}\rangle^2\right)} +$$ + + + + +$$ +\sigma=\sqrt{\frac{1+2\tau/\Delta t}{n}\left(\langle \mathbf{M}^2\rangle-\langle \mathbf{M}\rangle^2\right)} +$$ + + where \( \tau \) is the correlation time (the time between a sample and the next uncorrelated sample) and \( \Delta t \) is time between each sample @@ -426,6 +440,7 @@ MathJax.Hub.Config({
  • 73
  • 74
  • 75
  • +
  • 76
  • »
  • diff --git a/doc/pub/Statistics/html/._Statistics-bs067.html b/doc/pub/Statistics/html/._Statistics-bs067.html index e37f986e4..927d1570c 100644 --- a/doc/pub/Statistics/html/._Statistics-bs067.html +++ b/doc/pub/Statistics/html/._Statistics-bs067.html @@ -6,6 +6,7 @@ Automatically generated HTML file from DocOnce source + Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis @@ -55,43 +56,40 @@ $(function () { @@ -296,80 +298,81 @@ MathJax.Hub.Config({ @@ -391,10 +394,12 @@ MathJax.Hub.Config({

    @@ -423,6 +428,7 @@ MathJax.Hub.Config({
  • 73
  • 74
  • 75
  • +
  • 76
  • »
  • diff --git a/doc/pub/Statistics/html/._Statistics-bs068.html b/doc/pub/Statistics/html/._Statistics-bs068.html index 270e6bbb8..c72d4f1ba 100644 --- a/doc/pub/Statistics/html/._Statistics-bs068.html +++ b/doc/pub/Statistics/html/._Statistics-bs068.html @@ -6,6 +6,7 @@ Automatically generated HTML file from DocOnce source + Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis @@ -55,43 +56,40 @@ $(function () { @@ -296,80 +298,81 @@ MathJax.Hub.Config({ @@ -385,20 +388,16 @@ MathJax.Hub.Config({ -

    Implementation

    +

    What is blocking?

    @@ -426,6 +425,7 @@ MathJax.Hub.Config({
  • 73
  • 74
  • 75
  • +
  • 76
  • »
  • diff --git a/doc/pub/Statistics/html/._Statistics-bs069.html b/doc/pub/Statistics/html/._Statistics-bs069.html index 6f98bd6ee..c414c06b2 100644 --- a/doc/pub/Statistics/html/._Statistics-bs069.html +++ b/doc/pub/Statistics/html/._Statistics-bs069.html @@ -6,6 +6,7 @@ Automatically generated HTML file from DocOnce source + Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis @@ -55,43 +56,40 @@ $(function () { @@ -296,80 +298,81 @@ MathJax.Hub.Config({ @@ -385,43 +388,25 @@ MathJax.Hub.Config({ -

    Actual implementation with code, main function

    -When the file gets large, it can be useful to write your data in binary mode instead of ascii characters. -The following python file reads data from file with the output from every Monte Carlo cycle. -

    +

    Implementation

    +
    +
    +

    - -

    # Blocking
    -    @timeFunction
    -    def blocking(self, blockSizeMax = 500):
    -        blockSizeMin = 1
    +
      +
    • Do a Monte Carlo simulation, storing all samples to file
    • +
    • Do the statistical analysis on this file, independently of your Monte Carlo program
    • +
    • Read the file into an array
    • +
    • Loop over various block sizes
    • +
    • For each block size \( n_b \), loop over the array in steps of \( n_b \) taking the mean of elements \( i n_b,\ldots,(i+1) n_b \)
    • +
    • Take the mean and variance of the resulting array
    • +
    • Write the results for each block size to file for later + analysis
    • +
    +
    +
    - self.blockSizes = [] - self.meanVec = [] - self.varVec = [] - for i in range(blockSizeMin, blockSizeMax): - if(len(self.data) % i != 0): - pass#continue - blockSize = i - meanTempVec = [] - varTempVec = [] - startPoint = 0 - endPoint = blockSize - - while endPoint <= len(self.data): - meanTempVec.append(np.average(self.data[startPoint:endPoint])) - startPoint = endPoint - endPoint += blockSize - mean, var = np.average(meanTempVec), np.var(meanTempVec)/len(meanTempVec) - self.meanVec.append(mean) - self.varVec.append(var) - self.blockSizes.append(blockSize) - - self.blockingAvg = np.average(self.meanVec[-200:]) - self.blockingVar = (np.average(self.varVec[-200:])) - self.blockingStd = np.sqrt(self.blockingVar) -

    @@ -443,6 +428,7 @@ The 73

  • 74
  • 75
  • +
  • 76
  • »
  • diff --git a/doc/pub/Statistics/html/._Statistics-bs070.html b/doc/pub/Statistics/html/._Statistics-bs070.html index 071cd5a60..eb0b352eb 100644 --- a/doc/pub/Statistics/html/._Statistics-bs070.html +++ b/doc/pub/Statistics/html/._Statistics-bs070.html @@ -6,6 +6,7 @@ Automatically generated HTML file from DocOnce source + Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis @@ -55,43 +56,40 @@ $(function () { @@ -296,80 +298,81 @@ MathJax.Hub.Config({ @@ -385,23 +388,43 @@ MathJax.Hub.Config({ -

    The Bootstrap method

    - +

    Actual implementation with code, main function

    +When the file gets large, it can be useful to write your data in binary mode instead of ascii characters. +The following python file reads data from file with the output from every Monte Carlo cycle.

    -The Bootstrap resampling method is also very popular. It is very simple: -

      -
    1. Start with your sample of measurements and compute the sample variance and the mean values
    2. -
    3. Then start again but pick in a random way the numbers in the sample and recalculate the mean and the sample variance.
    4. -
    5. Repeat this \( K \) times.
    6. -
    + +
    # Blocking
    +    @timeFunction
    +    def blocking(self, blockSizeMax = 500):
    +        blockSizeMin = 1
     
    -It can be shown, see the article by Efron
    -that it produces the correct standard deviation.
    +        self.blockSizes = []
    +        self.meanVec = []
    +        self.varVec = []
     
    -

    -This method is very useful for small ensembles of data points. + for i in range(blockSizeMin, blockSizeMax): + if(len(self.data) % i != 0): + pass#continue + blockSize = i + meanTempVec = [] + varTempVec = [] + startPoint = 0 + endPoint = blockSize + while endPoint <= len(self.data): + meanTempVec.append(np.average(self.data[startPoint:endPoint])) + startPoint = endPoint + endPoint += blockSize + mean, var = np.average(meanTempVec), np.var(meanTempVec)/len(meanTempVec) + self.meanVec.append(mean) + self.varVec.append(var) + self.blockSizes.append(blockSize) + + self.blockingAvg = np.average(self.meanVec[-200:]) + self.blockingVar = (np.average(self.varVec[-200:])) + self.blockingStd = np.sqrt(self.blockingVar) +

    @@ -422,6 +445,7 @@ This method is very useful for small ensembles of data points.

  • 73
  • 74
  • 75
  • +
  • 76
  • »
  • diff --git a/doc/pub/Statistics/html/._Statistics-bs071.html b/doc/pub/Statistics/html/._Statistics-bs071.html index be4af3a8f..8f491205f 100644 --- a/doc/pub/Statistics/html/._Statistics-bs071.html +++ b/doc/pub/Statistics/html/._Statistics-bs071.html @@ -6,6 +6,7 @@ Automatically generated HTML file from DocOnce source + Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis @@ -55,43 +56,40 @@ $(function () { @@ -296,80 +298,81 @@ MathJax.Hub.Config({ @@ -383,15 +386,24 @@ MathJax.Hub.Config({

     

     

     

    - + -

    Bootstrapping

    -Given a set of \( N \) data, assume that we are interested in some -observable \( \theta \) which may be estimated from that set. This observable can also be for example the result of a fit based on all \( N \) raw data. -Let us call the value of the observable obtained from the original -data set \( \hat{\theta} \). One recreates from the sample repeatedly -other samples by choosing randomly \( N \) data out of the original set. -This costs essentially nothing, since we just recycle the original data set for the building of new sets. +

    The Bootstrap method

    + +

    +The Bootstrap resampling method is also very popular. It is very simple: + +

      +
    1. Start with your sample of measurements and compute the sample variance and the mean values
    2. +
    3. Then start again but pick in a random way the numbers in the sample and recalculate the mean and the sample variance.
    4. +
    5. Repeat this \( K \) times.
    6. +
    + +It can be shown, see the article by Efron +that it produces the correct standard deviation. + +

    +This method is very useful for small ensembles of data points.

    @@ -412,6 +424,7 @@ This costs essentially nothing, since we just recycle the original data set for

  • 73
  • 74
  • 75
  • +
  • 76
  • »
  • diff --git a/doc/pub/Statistics/html/._Statistics-bs072.html b/doc/pub/Statistics/html/._Statistics-bs072.html index a16b22560..1bf61fd73 100644 --- a/doc/pub/Statistics/html/._Statistics-bs072.html +++ b/doc/pub/Statistics/html/._Statistics-bs072.html @@ -6,6 +6,7 @@ Automatically generated HTML file from DocOnce source + Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis @@ -55,43 +56,40 @@ $(function () { @@ -296,80 +298,81 @@ MathJax.Hub.Config({ @@ -385,26 +388,13 @@ MathJax.Hub.Config({ -

    Bootstrapping, recipe

    -Let us assume we have done this \( K \) times and thus have \( K \) sets of \( N \) -data values each. -Of course some values will enter more than once in the new sets. For each of these sets one computes the observable \( \theta \) resulting in values \( \theta_k \) with \( k = 1,...,K \). Then one determines -$$ -\tilde{\theta} = \frac{1}{K} \sum_{k=1}^K \theta_k, -$$ - -and -$$ -sigma^2_{\tilde{\theta}} = \frac{1}{K} \sum_{k=1}^K \left(\theta_k-\tilde{\theta}\right)^2. -$$ - -

    -These are estimators for \( \angle\theta\rangle \) and its variance. They are not unbiased and therefore -\( \tilde{\theta}\neq\hat{\theta} \) for finite K. - -

    -The difference is called bias and gives an idea on how far away the result may be from -the true \( \angle\theta\rangle \). As final result for the observable one quotes \( \angle\theta\rangle = \tilde{\theta} \pm \sigma_{\tilde{\theta}} \) . +

    Bootstrapping

    +Given a set of \( N \) data, assume that we are interested in some +observable \( \theta \) which may be estimated from that set. This observable can also be for example the result of a fit based on all \( N \) raw data. +Let us call the value of the observable obtained from the original +data set \( \hat{\theta} \). One recreates from the sample repeatedly +other samples by choosing randomly \( N \) data out of the original set. +This costs essentially nothing, since we just recycle the original data set for the building of new sets.

    @@ -424,6 +414,7 @@ the true \( \angle\theta\rangle \). As final result for the observable one quote

  • 73
  • 74
  • 75
  • +
  • 76
  • »
  • diff --git a/doc/pub/Statistics/html/._Statistics-bs073.html b/doc/pub/Statistics/html/._Statistics-bs073.html index 116ea15e7..2b93160c1 100644 --- a/doc/pub/Statistics/html/._Statistics-bs073.html +++ b/doc/pub/Statistics/html/._Statistics-bs073.html @@ -6,6 +6,7 @@ Automatically generated HTML file from DocOnce source + Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis @@ -55,43 +56,40 @@ $(function () { @@ -296,80 +298,81 @@ MathJax.Hub.Config({ @@ -385,20 +388,27 @@ MathJax.Hub.Config({ -

    Bootstrapping, code

    -

    +

    Bootstrapping, recipe

    +Let us assume we have done this \( K \) times and thus have \( K \) sets of \( N \) +data values each. +Of course some values will enter more than once in the new sets. For each of these sets one computes the observable \( \theta \) resulting in values \( \theta_k \) with \( k = 1,...,K \). Then one determines +$$ +\tilde{\theta} = \frac{1}{K} \sum_{k=1}^K \theta_k, +$$ + +and +$$ +sigma^2_{\tilde{\theta}} = \frac{1}{K} \sum_{k=1}^K \left(\theta_k-\tilde{\theta}\right)^2. +$$ + +

    +These are estimators for \( \angle\theta\rangle \) and its variance. They are not unbiased and therefore +\( \tilde{\theta}\neq\hat{\theta} \) for finite K. + +

    +The difference is called bias and gives an idea on how far away the result may be from +the true \( \angle\theta\rangle \). As final result for the observable one quotes \( \angle\theta\rangle = \tilde{\theta} \pm \sigma_{\tilde{\theta}} \) . - -

    # Bootstrap
    -    @timeFunction
    -    def bootstrap(self, nBoots = 1000):
    -        bootVec = np.zeros(nBoots)
    -        for k in range(0,nBoots):
    -            bootVec[k] = np.average(np.random.choice(self.data, len(self.data)))
    -        self.bootAvg = np.average(bootVec)
    -        self.bootVar = np.var(bootVec)
    -        self.bootStd = np.std(bootVec)
    -

    @@ -416,6 +426,7 @@ MathJax.Hub.Config({

  • 73
  • 74
  • 75
  • +
  • 76
  • »
  • diff --git a/doc/pub/Statistics/html/._Statistics-bs074.html b/doc/pub/Statistics/html/._Statistics-bs074.html index 222252c62..711986fd0 100644 --- a/doc/pub/Statistics/html/._Statistics-bs074.html +++ b/doc/pub/Statistics/html/._Statistics-bs074.html @@ -6,6 +6,7 @@ Automatically generated HTML file from DocOnce source + Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis @@ -55,43 +56,40 @@ $(function () { @@ -296,80 +298,81 @@ MathJax.Hub.Config({ @@ -385,22 +388,21 @@ MathJax.Hub.Config({ -

    Jackknife, code

    +

    Bootstrapping, code

    -

    # Jackknife
    +
    # Bootstrap
         @timeFunction
    -    def jackknife(self):
    -        jackknVec = np.zeros(len(self.data))
    -        for k in range(0,len(self.data)):
    -            jackknVec[k] = np.average(np.delete(self.data, k))
    -        self.jackknAvg = self.avg - (len(self.data) - 1) * (np.average(jackknVec) - self.avg)
    -        self.jackknVar = float(len(self.data) - 1) * np.var(jackknVec)
    -        self.jackknStd = np.sqrt(self.jackknVar)
    +    def bootstrap(self, nBoots = 1000):
    +        bootVec = np.zeros(nBoots)
    +        for k in range(0,nBoots):
    +            bootVec[k] = np.average(np.random.choice(self.data, len(self.data)))
    +        self.bootAvg = np.average(bootVec)
    +        self.bootVar = np.var(bootVec)
    +        self.bootStd = np.std(bootVec)
     

    -

    diff --git a/doc/pub/Statistics/html/._Statistics-bs075.html b/doc/pub/Statistics/html/._Statistics-bs075.html index 0ef53d488..d8cf8f3c5 100644 --- a/doc/pub/Statistics/html/._Statistics-bs075.html +++ b/doc/pub/Statistics/html/._Statistics-bs075.html @@ -6,6 +6,7 @@ Automatically generated HTML file from DocOnce source + Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis @@ -55,9 +56,9 @@ $(function () { @@ -298,9 +298,9 @@ MathJax.Hub.Config({ @@ -389,21 +388,22 @@ MathJax.Hub.Config({ -

    Bootstrapping, code

    +

    Jackknife, code

    -

    # Bootstrap
    +
    # Jackknife
         @timeFunction
    -    def bootstrap(self, nBoots = 1000):
    -        bootVec = np.zeros(nBoots)
    -        for k in range(0,nBoots):
    -            bootVec[k] = np.average(np.random.choice(self.data, len(self.data)))
    -        self.bootAvg = np.average(bootVec)
    -        self.bootVar = np.var(bootVec)
    -        self.bootStd = np.std(bootVec)
    +    def jackknife(self):
    +        jackknVec = np.zeros(len(self.data))
    +        for k in range(0,len(self.data)):
    +            jackknVec[k] = np.average(np.delete(self.data, k))
    +        self.jackknAvg = self.avg - (len(self.data) - 1) * (np.average(jackknVec) - self.avg)
    +        self.jackknVar = float(len(self.data) - 1) * np.var(jackknVec)
    +        self.jackknStd = np.sqrt(self.jackknVar)
     

    +

      @@ -419,8 +419,6 @@ MathJax.Hub.Config({
    • 74
    • 75
    • 76
    • -
    • 77
    • -
    • »
    diff --git a/doc/pub/Statistics/html/._Statistics.do.txt-bs000.html b/doc/pub/Statistics/html/._Statistics.do.txt-bs000.html new file mode 100644 index 000000000..b8cde1a33 --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics.do.txt-bs000.html @@ -0,0 +1,459 @@ + + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +
    + +

     

     

     

    + + + + + + +
    +

    Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis

    + +

    + + +

    +Morten Hjorth-Jensen [1, 2] +
    + +

    + + +

    [1] Department of Physics, University of Oslo
    +
    [2] Department of Physics and Astronomy and National Superconducting Cyclotron Laboratory, Michigan State University
    +
    +

    +

    Sep 20, 2020

    +
    +

    + + +

    Read »

    + + +
    + +

    + +

    + + +
    + + + + + + + +
    + © 1999-2020, Morten Hjorth-Jensen. Released under CC Attribution-NonCommercial 4.0 license +
    + + + + + + diff --git a/doc/pub/Statistics/html/._Statistics.do.txt-bs001.html b/doc/pub/Statistics/html/._Statistics.do.txt-bs001.html new file mode 100644 index 000000000..f9a5f9376 --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics.do.txt-bs001.html @@ -0,0 +1,440 @@ + + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +
    + +

     

     

     

    + + + + +

    To do list

    + + + +

    + +

    + + +
    + + + + + + + +
    + +
    + + + + + + diff --git a/doc/pub/Statistics/html/._Statistics.do.txt-bs002.html b/doc/pub/Statistics/html/._Statistics.do.txt-bs002.html new file mode 100644 index 000000000..719e8a3b4 --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics.do.txt-bs002.html @@ -0,0 +1,456 @@ + + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +

     

     

     

    + + + + +

    Domains and probabilities

    +
    +
    +

    +Consider the following simple example, namely the tossing of two dice, resulting in the following possible values +$$ +\begin{equation*} +\{2,3,4,5,6,7,8,9,10,11,12\}. +\end{equation*} +$$ + +These values are called the domain. +To this domain we have the corresponding probabilities +$$ +\begin{equation*} +\{1/36,2/36/,3/36,4/36,5/36,6/36,5/36,4/36,3/36,2/36,1/36\}. +\end{equation*} +$$ +

    +
    + + +

    +

    + +

    + + +
    + + + + + + + +
    + +
    + + + + + + diff --git a/doc/pub/Statistics/html/._Statistics.do.txt-bs003.html b/doc/pub/Statistics/html/._Statistics.do.txt-bs003.html new file mode 100644 index 000000000..3f68ad04a --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics.do.txt-bs003.html @@ -0,0 +1,466 @@ + + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +

     

     

     

    + + + + +

    Tossing the dice

    +
    +
    +

    +The numbers in the domain are the outcomes of the physical process of tossing say two dice. +We cannot tell beforehand whether the outcome is 3 or 5 or any other number in this domain. +This defines the randomness of the outcome, or unexpectedness or any other synonimous word which +encompasses the uncertitude of the final outcome. + +

    +The only thing we can tell beforehand +is that say the outcome 2 has a certain probability. +If our favorite hobby is to spend an hour every evening throwing dice and +registering the sequence of outcomes, we will note that the numbers in the above domain +$$ +\begin{equation*} +\{2,3,4,5,6,7,8,9,10,11,12\}, +\end{equation*} +$$ + +appear in a random order. After 11 throws the results may look like + +$$ +\begin{equation*} +\{10,8,6,3,6,9,11,8,12,4,5\}. +\end{equation*} +$$ +

    +
    + + +

    +

    + +

    + + +
    + + + + + + + +
    + +
    + + + + + + diff --git a/doc/pub/Statistics/html/._Statistics.do.txt-bs004.html b/doc/pub/Statistics/html/._Statistics.do.txt-bs004.html new file mode 100644 index 000000000..f0c92d8e5 --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics.do.txt-bs004.html @@ -0,0 +1,447 @@ + + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +

     

     

     

    + + + + +

    Stochastic variables

    +
    +
    +

    + +

    +Random variables are characterized by a domain which contains all possible values that the random value may take. This domain has a corresponding probability distribution function(PDF). +

    +
    + + +

    +

    + +

    + + +
    + + + + + + + +
    + +
    + + + + + + diff --git a/doc/pub/Statistics/html/._Statistics.do.txt-bs005.html b/doc/pub/Statistics/html/._Statistics.do.txt-bs005.html new file mode 100644 index 000000000..a27ee1e29 --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics.do.txt-bs005.html @@ -0,0 +1,461 @@ + + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +

     

     

     

    + + + + +

    Stochastic variables and the main concepts, the discrete case

    +
    +
    +

    +There are two main concepts associated with a stochastic variable. The +domain is the set \( \mathbb D = \{x\} \) of all accessible values +the variable can assume, so that \( X \in \mathbb D \). An example of a +discrete domain is the set of six different numbers that we may get by +throwing of a dice, \( x\in\{1,\,2,\,3,\,4,\,5,\,6\} \). + +

    +The probability distribution function (PDF) is a function +\( p(x) \) on the domain which, in the discrete case, gives us the +probability or relative frequency with which these values of \( X \) +occur +$$ +\begin{equation*} +p(x) = \mathrm{Prob}(X=x). +\end{equation*} +$$ +

    +
    + + +

    +

    + +

    + + +
    + + + + + + + +
    + +
    + + + + + + diff --git a/doc/pub/Statistics/html/._Statistics.do.txt-bs006.html b/doc/pub/Statistics/html/._Statistics.do.txt-bs006.html new file mode 100644 index 000000000..a9010c766 --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics.do.txt-bs006.html @@ -0,0 +1,463 @@ + + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +

     

     

     

    + + + + +

    Stochastic variables and the main concepts, the continuous case

    +
    +
    +

    +In the continuous case, the PDF does not directly depict the +actual probability. Instead we define the probability for the +stochastic variable to assume any value on an infinitesimal interval +around \( x \) to be \( p(x)dx \). The continuous function \( p(x) \) then gives us +the density of the probability rather than the probability +itself. The probability for a stochastic variable to assume any value +on a non-infinitesimal interval \( [a,\,b] \) is then just the integral + +$$ +\begin{equation*} +\mathrm{Prob}(a\leq X\leq b) = \int_a^b p(x)dx. +\end{equation*} +$$ + +Qualitatively speaking, a stochastic variable represents the values of +numbers chosen as if by chance from some specified PDF so that the +selection of a large set of these numbers reproduces this PDF. +

    +
    + + +

    +

    + +

    + + +
    + + + + + + + +
    + +
    + + + + + + diff --git a/doc/pub/Statistics/html/._Statistics.do.txt-bs007.html b/doc/pub/Statistics/html/._Statistics.do.txt-bs007.html new file mode 100644 index 000000000..ff9604747 --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics.do.txt-bs007.html @@ -0,0 +1,464 @@ + + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +

     

     

     

    + + + + +

    The cumulative probability

    +
    +
    +

    +Of interest to us is the cumulative probability +distribution function (CDF), \( P(x) \), which is just the probability +for a stochastic variable \( X \) to assume any value less than \( x \) +$$ +\begin{equation*} +P(x)=\mathrm{Prob(}X\leq x\mathrm{)} = +\int_{-\infty}^x p(x^{\prime})dx^{\prime}. +\end{equation*} +$$ + +The relation between a CDF and its corresponding PDF is then + +$$ +\begin{equation*} +p(x) = \frac{d}{dx}P(x). +\end{equation*} +$$ +

    +
    + + +

    +

    + +

    + + +
    + + + + + + + +
    + +
    + + + + + + diff --git a/doc/pub/Statistics/html/._Statistics.do.txt-bs008.html b/doc/pub/Statistics/html/._Statistics.do.txt-bs008.html new file mode 100644 index 000000000..28c3464a4 --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics.do.txt-bs008.html @@ -0,0 +1,470 @@ + + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +

     

     

     

    + + + + +

    Properties of PDFs

    +
    +
    +

    + +

    +There are two properties that all PDFs must satisfy. The first one is +positivity (assuming that the PDF is normalized) + +$$ +\begin{equation*} +0 \leq p(x) \leq 1. +\end{equation*} +$$ + +Naturally, it would be nonsensical for any of the values of the domain +to occur with a probability greater than \( 1 \) or less than \( 0 \). Also, +the PDF must be normalized. That is, all the probabilities must add up +to unity. The probability of "anything" to happen is always unity. For +both discrete and continuous PDFs, this condition is +$$ +\begin{align*} +\sum_{x_i\in\mathbb D} p(x_i) & = 1,\\ +\int_{x\in\mathbb D} p(x)\,dx & = 1. +\end{align*} +$$ +

    +
    + + +

    +

    + +

    + + +
    + + + + + + + +
    + +
    + + + + + + diff --git a/doc/pub/Statistics/html/._Statistics.do.txt-bs009.html b/doc/pub/Statistics/html/._Statistics.do.txt-bs009.html new file mode 100644 index 000000000..37cd4ba89 --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics.do.txt-bs009.html @@ -0,0 +1,466 @@ + + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +

     

     

     

    + + + + +

    Important distributions, the uniform distribution

    +
    +
    +

    +The first one +is the most basic PDF; namely the uniform distribution +$$ +\begin{equation} +p(x) = \frac{1}{b-a}\theta(x-a)\theta(b-x). +\tag{1} +\end{equation} +$$ + +For \( a=0 \) and \( b=1 \) we have +$$ +\begin{array}{ll} +p(x)dx = dx & \in [0,1]. +\end{array} +$$ + +The latter distribution is used to generate random numbers. For other PDFs, one needs normally a mapping from this distribution to say for example the exponential distribution. +

    +
    + + +

    +

    + +

    + + +
    + + + + + + + +
    + +
    + + + + + + diff --git a/doc/pub/Statistics/html/._Statistics.do.txt-bs010.html b/doc/pub/Statistics/html/._Statistics.do.txt-bs010.html new file mode 100644 index 000000000..b197a9a4a --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics.do.txt-bs010.html @@ -0,0 +1,510 @@ + + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +

     

     

     

    + + + + +

    Gaussian distribution

    +
    +
    +

    +The second one is the Gaussian Distribution +$$ +\begin{equation*} +p(x) = \frac{1}{\sigma\sqrt{2\pi}} \exp{(-\frac{(x-\mu)^2}{2\sigma^2})}, +\end{equation*} +$$ + +with mean value \( \mu \) and standard deviation \( \sigma \). If \( \mu=0 \) and \( \sigma=1 \), it is normally called the standard normal distribution +$$ +\begin{equation*} +p(x) = \frac{1}{\sqrt{2\pi}} \exp{(-\frac{x^2}{2})}, +\end{equation*} +$$ + +

    +The following simple Python code plots the above distribution for different values of \( \mu \) and \( \sigma \). +

    + + +

    +

    +

    +
    + + +

    +

    + +

    + + +
    + + + + + + + +
    + +
    + + + + + + diff --git a/doc/pub/Statistics/html/._Statistics.do.txt-bs011.html b/doc/pub/Statistics/html/._Statistics.do.txt-bs011.html new file mode 100644 index 000000000..c4c75fae1 --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics.do.txt-bs011.html @@ -0,0 +1,456 @@ + + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +

     

     

     

    + + + + +

    Exponential distribution

    +
    +
    +

    +Another important distribution in science is the exponential distribution +$$ +\begin{equation*} +p(x) = \alpha\exp{-(\alpha x)}. +\end{equation*} +$$ +

    +
    + + +

    +

    + +

    + + +
    + + + + + + + +
    + +
    + + + + + + diff --git a/doc/pub/Statistics/html/._Statistics.do.txt-bs012.html b/doc/pub/Statistics/html/._Statistics.do.txt-bs012.html new file mode 100644 index 000000000..be60ec6c0 --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics.do.txt-bs012.html @@ -0,0 +1,471 @@ + + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +

     

     

     

    + + + + +

    Expectation values

    +
    +
    +

    +Let \( h(x) \) be an arbitrary continuous function on the domain of the stochastic +variable \( X \) whose PDF is \( p(x) \). We define the expectation value +of \( h \) with respect to \( p \) as follows + +$$ +\begin{equation} +\langle h \rangle_X \equiv \int\! h(x)p(x)\,dx +\tag{2} +\end{equation} +$$ + +Whenever the PDF is known implicitly, like in this case, we will drop +the index \( X \) for clarity. +A particularly useful class of special expectation values are the +moments. The \( n \)-th moment of the PDF \( p \) is defined as +follows +$$ +\begin{equation*} +\langle x^n \rangle \equiv \int\! x^n p(x)\,dx +\end{equation*} +$$ +

    +
    + + +

    +

    + +

    + + +
    + + + + + + + +
    + +
    + + + + + + diff --git a/doc/pub/Statistics/html/._Statistics.do.txt-bs013.html b/doc/pub/Statistics/html/._Statistics.do.txt-bs013.html new file mode 100644 index 000000000..3f6e599d3 --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics.do.txt-bs013.html @@ -0,0 +1,469 @@ + + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +

     

     

     

    + + + + +

    Stochastic variables and the main concepts, mean values

    +
    +
    +

    +The zero-th moment \( \langle 1\rangle \) is just the normalization condition of +\( p \). The first moment, \( \langle x\rangle \), is called the mean of \( p \) +and often denoted by the letter \( \mu \) +$$ +\begin{equation*} +\langle x\rangle = \mu \equiv \int x p(x)dx, +\end{equation*} +$$ + +for a continuous distribution and +$$ +\begin{equation*} +\langle x\rangle = \mu \equiv \sum_{i=1}^N x_i p(x_i), +\end{equation*} +$$ + +for a discrete distribution. +Qualitatively it represents the centroid or the average value of the +PDF and is therefore simply called the expectation value of \( p(x) \). +

    +
    + + +

    +

    + +

    + + +
    + + + + + + + +
    + +
    + + + + + + diff --git a/doc/pub/Statistics/html/._Statistics.do.txt-bs014.html b/doc/pub/Statistics/html/._Statistics.do.txt-bs014.html new file mode 100644 index 000000000..0ff9a0489 --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics.do.txt-bs014.html @@ -0,0 +1,477 @@ + + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +

     

     

     

    + + + + +

    Stochastic variables and the main concepts, central moments, the variance

    +
    +
    +

    + +

    +A special version of the moments is the set of central moments, the n-th central moment defined as +$$ +\begin{equation*} +\langle (x-\langle x\rangle )^n\rangle \equiv \int\! (x-\langle x\rangle)^n p(x)\,dx +\end{equation*} +$$ + +The zero-th and first central moments are both trivial, equal \( 1 \) and +\( 0 \), respectively. But the second central moment, known as the +variance of \( p \), is of particular interest. For the stochastic +variable \( X \), the variance is denoted as \( \sigma^2_X \) or \( \mathrm{Var}(X) \) +$$ +\begin{align*} +\sigma^2_X &=\mathrm{Var}(X) = \langle (x-\langle x\rangle)^2\rangle = +\int (x-\langle x\rangle)^2 p(x)dx\\ +& = \int\left(x^2 - 2 x \langle x\rangle^{2} +\langle x\rangle^2\right)p(x)dx\\ +& = \langle x^2\rangle - 2 \langle x\rangle\langle x\rangle + \langle x\rangle^2\\ +& = \langle x^2 \rangle - \langle x\rangle^2 +\end{align*} +$$ + +The square root of the variance, \( \sigma =\sqrt{\langle (x-\langle x\rangle)^2\rangle} \) is called the +standard deviation of \( p \). It is the RMS (root-mean-square) +value of the deviation of the PDF from its mean value, interpreted +qualitatively as the "spread" of \( p \) around its mean. +

    +
    + + +

    +

    + +

    + + +
    + + + + + + + +
    + +
    + + + + + + diff --git a/doc/pub/Statistics/html/._Statistics.do.txt-bs015.html b/doc/pub/Statistics/html/._Statistics.do.txt-bs015.html new file mode 100644 index 000000000..f51ec44e7 --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics.do.txt-bs015.html @@ -0,0 +1,477 @@ + + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +

     

     

     

    + + + + +

    Probability Distribution Functions

    +
    +
    +

    + +

    +The following table collects properties of probability distribution functions. +In our notation we reserve the label \( p(x) \) for the probability of a certain event, +while \( P(x) \) is the cumulative probability. + +

    + +

    +
    + + + + + + + + + + + + + +
    Discrete PDF Continuous PDF
    Domain \( \left\{x_1, x_2, x_3, \dots, x_N\right\} \) \( [a,b] \)
    Probability \( p(x_i) \) \( p(x)dx \)
    Cumulative \( P_i=\sum_{l=1}^ip(x_l) \) \( P(x)=\int_a^xp(t)dt \)
    Positivity \( 0 \le p(x_i) \le 1 \) \( p(x) \ge 0 \)
    Positivity \( 0 \le P_i \le 1 \) \( 0 \le P(x) \le 1 \)
    Monotonic \( P_i \ge P_j \) if \( x_i \ge x_j \) \( P(x_i) \ge P(x_j) \) if \( x_i \ge x_j \)
    Normalization \( P_N=1 \) \( P(b)=1 \)
    +
    +
    +

    +

    +
    + + +

    +

    + +

    + + +
    + + + + + + + +
    + +
    + + + + + + diff --git a/doc/pub/Statistics/html/._Statistics.do.txt-bs016.html b/doc/pub/Statistics/html/._Statistics.do.txt-bs016.html new file mode 100644 index 000000000..af278832b --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics.do.txt-bs016.html @@ -0,0 +1,468 @@ + + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +

     

     

     

    + + + + +

    Probability Distribution Functions

    +
    +
    +

    +With a PDF we can compute expectation values of selected quantities such as + +$$ +\begin{equation*} + \langle x^k\rangle=\sum_{i=1}^{N}x_i^kp(x_i), +\end{equation*} +$$ + +if we have a discrete PDF or + +$$ +\begin{equation*} + \langle x^k\rangle=\int_a^b x^kp(x)dx, +\end{equation*} +$$ + +in the case of a continuous PDF. We have already defined the mean value \( \mu \) +and the variance \( \sigma^2 \). +

    +
    + + +

    +

    + +

    + + +
    + + + + + + + +
    + +
    + + + + + + diff --git a/doc/pub/Statistics/html/._Statistics.do.txt-bs017.html b/doc/pub/Statistics/html/._Statistics.do.txt-bs017.html new file mode 100644 index 000000000..9068b29dc --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics.do.txt-bs017.html @@ -0,0 +1,484 @@ + + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +

     

     

     

    + + + + +

    The three famous Probability Distribution Functions

    +
    +
    +

    + +

    +There are at least three PDFs which one may encounter. These are the + +

    +Uniform distribution +$$ +\begin{equation*} +p(x)=\frac{1}{b-a}\Theta(x-a)\Theta(b-x), +\end{equation*} +$$ + +yielding probabilities different from zero in the interval \( [a,b] \). + +

    +The exponential distribution +$$ +\begin{equation*} +p(x)=\alpha \exp{(-\alpha x)}, +\end{equation*} +$$ + +yielding probabilities different from zero in the interval \( [0,\infty) \) and with mean value +$$ +\begin{equation*} +\mu = \int_0^{\infty}xp(x)dx=\int_0^{\infty}x\alpha \exp{(-\alpha x)}dx=\frac{1}{\alpha}, +\end{equation*} +$$ +

    +
    + +with variance +$$ +\begin{equation*} +\sigma^2=\int_0^{\infty}x^2p(x)dx-\mu^2 = \frac{1}{\alpha^2}. +\end{equation*} +$$ + +

    +

    + +

    + + +
    + + + + + + + +
    + +
    + + + + + + diff --git a/doc/pub/Statistics/html/._Statistics.do.txt-bs018.html b/doc/pub/Statistics/html/._Statistics.do.txt-bs018.html new file mode 100644 index 000000000..30d11b152 --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics.do.txt-bs018.html @@ -0,0 +1,473 @@ + + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +

     

     

     

    + + + + +

    Probability Distribution Functions, the normal distribution

    +
    +
    +

    +Finally, we have the so-called univariate normal distribution, or just the normal distribution +$$ +\begin{equation*} +p(x)=\frac{1}{b\sqrt{2\pi}}\exp{\left(-\frac{(x-a)^2}{2b^2}\right)} +\end{equation*} +$$ + +with probabilities different from zero in the interval \( (-\infty,\infty) \). +The integral \( \int_{-\infty}^{\infty}\exp{\left(-(x^2\right)}dx \) appears in many calculations, its value +is \( \sqrt{\pi} \), a result we will need when we compute the mean value and the variance. +The mean value is +$$ +\begin{equation*} + \mu = \int_0^{\infty}xp(x)dx=\frac{1}{b\sqrt{2\pi}}\int_{-\infty}^{\infty}x \exp{\left(-\frac{(x-a)^2}{2b^2}\right)}dx, +\end{equation*} +$$ + +which becomes with a suitable change of variables +$$ +\begin{equation*} + \mu =\frac{1}{b\sqrt{2\pi}}\int_{-\infty}^{\infty}b\sqrt{2}(a+b\sqrt{2}y)\exp{-y^2}dy=a. +\end{equation*} +$$ +

    +
    + + +

    +

    + +

    + + +
    + + + + + + + +
    + +
    + + + + + + diff --git a/doc/pub/Statistics/html/._Statistics.do.txt-bs019.html b/doc/pub/Statistics/html/._Statistics.do.txt-bs019.html new file mode 100644 index 000000000..668d5b370 --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics.do.txt-bs019.html @@ -0,0 +1,476 @@ + + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +

     

     

     

    + + + + +

    Probability Distribution Functions, the normal distribution

    +
    +
    +

    +Similarly, the variance becomes +$$ +\begin{equation*} + \sigma^2 = \frac{1}{b\sqrt{2\pi}}\int_{-\infty}^{\infty}(x-\mu)^2 \exp{\left(-\frac{(x-a)^2}{2b^2}\right)}dx, +\end{equation*} +$$ + +and inserting the mean value and performing a variable change we obtain + +$$ +\begin{equation*} + \sigma^2 = \frac{1}{b\sqrt{2\pi}}\int_{-\infty}^{\infty}b\sqrt{2}(b\sqrt{2}y)^2\exp{\left(-y^2\right)}dy= +\frac{2b^2}{\sqrt{\pi}}\int_{-\infty}^{\infty}y^2\exp{\left(-y^2\right)}dy, +\end{equation*} +$$ + +and performing a final integration by parts we obtain the well-known result \( \sigma^2=b^2 \). +It is useful to introduce the standard normal distribution as well, defined by \( \mu=a=0 \), viz. a distribution +centered around zero and with a variance \( \sigma^2=1 \), leading to + +$$ +\begin{equation} + p(x)=\frac{1}{\sqrt{2\pi}}\exp{\left(-\frac{x^2}{2}\right)}. +\tag{3} +\end{equation} +$$ +

    +
    + + +

    +

    + +

    + + +
    + + + + + + + +
    + +
    + + + + + + diff --git a/doc/pub/Statistics/html/._Statistics.do.txt-bs020.html b/doc/pub/Statistics/html/._Statistics.do.txt-bs020.html new file mode 100644 index 000000000..1ad2d0761 --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics.do.txt-bs020.html @@ -0,0 +1,463 @@ + + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +

     

     

     

    + + + + +

    Probability Distribution Functions, the cumulative distribution

    +
    +
    +

    + +

    +The exponential and uniform distributions have simple cumulative functions, +whereas the normal distribution does not, being proportional to the so-called +error function \( erf(x) \), given by + +$$ +\begin{equation*} +P(x) = \frac{1}{\sqrt{2\pi}}\int_{-\infty}^x\exp{\left(-\frac{t^2}{2}\right)}dt, +\end{equation*} +$$ + +which is difficult to evaluate in a quick way. +

    +
    + + +

    +

    + +

    + + +
    + + + + + + + +
    + +
    + + + + + + diff --git a/doc/pub/Statistics/html/._Statistics.do.txt-bs021.html b/doc/pub/Statistics/html/._Statistics.do.txt-bs021.html new file mode 100644 index 000000000..d00f2e76c --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics.do.txt-bs021.html @@ -0,0 +1,470 @@ + + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +

     

     

     

    + + + + +

    Probability Distribution Functions, other important distribution

    +
    +
    +

    + +

    +Some other PDFs which one encounters often in the natural sciences are the binomial distribution +$$ +\begin{equation*} + p(x) = \left(\begin{array}{c} n \\ x\end{array}\right)y^x(1-y)^{n-x} \hspace{0.5cm}x=0,1,\dots,n, +\end{equation*} +$$ + +where \( y \) is the probability for a specific event, such as the tossing of a coin or moving left or right +in case of a random walker. Note that \( x \) is a discrete stochastic variable. + +

    +The sequence of binomial trials is characterized by the following definitions + +

      +
    • Every experiment is thought to consist of \( N \) independent trials.
    • +
    • In every independent trial one registers if a specific situation happens or not, such as the jump to the left or right of a random walker.
    • +
    • The probability for every outcome in a single trial has the same value, for example the outcome of tossing (either heads or tails) a coin is always \( 1/2 \).
    • +
    +
    +
    + + +

    +

    + +

    + + +
    + + + + + + + +
    + +
    + + + + + + diff --git a/doc/pub/Statistics/html/._Statistics.do.txt-bs022.html b/doc/pub/Statistics/html/._Statistics.do.txt-bs022.html new file mode 100644 index 000000000..23922dd6c --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics.do.txt-bs022.html @@ -0,0 +1,493 @@ + + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +

     

     

     

    + + + + +

    Probability Distribution Functions, the binomial distribution

    +
    +
    +

    + +

    +In order to compute the mean and variance we need to recall Newton's binomial +formula +$$ +\begin{equation*} + (a+b)^m=\sum_{n=0}^m \left(\begin{array}{c} m \\ n\end{array}\right)a^nb^{m-n}, +\end{equation*} +$$ + +which can be used to show that + +$$ +\begin{equation*} +\sum_{x=0}^n\left(\begin{array}{c} n \\ x\end{array}\right)y^x(1-y)^{n-x} = (y+1-y)^n = 1, +\end{equation*} +$$ + +the PDF is normalized to one. +The mean value is +$$ +\begin{equation*} +\mu = \sum_{x=0}^n x\left(\begin{array}{c} n \\ x\end{array}\right)y^x(1-y)^{n-x} = +\sum_{x=0}^n x\frac{n!}{x!(n-x)!}y^x(1-y)^{n-x}, +\end{equation*} +$$ + +resulting in +$$ +\begin{equation*} +\mu = +\sum_{x=0}^n x\frac{(n-1)!}{(x-1)!(n-1-(x-1))!}y^{x-1}(1-y)^{n-1-(x-1)}, +\end{equation*} +$$ + +which we rewrite as + +$$ +\begin{equation*} +\mu=ny\sum_{\nu=0}^n\left(\begin{array}{c} n-1 \\ \nu\end{array}\right)y^{\nu}(1-y)^{n-1-\nu} =ny(y+1-y)^{n-1}=ny. +\end{equation*} +$$ +

    +
    + +The variance is slightly trickier to get. It reads \( \sigma^2=ny(1-y) \). + +

    +

    + +

    + + +
    + + + + + + + +
    + +
    + + + + + + diff --git a/doc/pub/Statistics/html/._Statistics.do.txt-bs023.html b/doc/pub/Statistics/html/._Statistics.do.txt-bs023.html new file mode 100644 index 000000000..227d0f892 --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics.do.txt-bs023.html @@ -0,0 +1,470 @@ + + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +

     

     

     

    + + + + +

    Probability Distribution Functions, Poisson's distribution

    +
    +
    +

    + +

    +Another important distribution with discrete stochastic variables \( x \) is +the Poisson model, which resembles the exponential distribution and reads +$$ +\begin{equation*} + p(x) = \frac{\lambda^x}{x!} e^{-\lambda} \hspace{0.5cm}x=0,1,\dots,;\lambda > 0. +\end{equation*} +$$ + +In this case both the mean value and the variance are easier to calculate, + +$$ +\begin{equation*} +\mu = \sum_{x=0}^{\infty} x \frac{\lambda^x}{x!} e^{-\lambda} = \lambda e^{-\lambda}\sum_{x=1}^{\infty} +\frac{\lambda^{x-1}}{(x-1)!}=\lambda, +\end{equation*} +$$ + +and the variance is \( \sigma^2=\lambda \). +

    +
    + + +

    +

    + +

    + + +
    + + + + + + + +
    + +
    + + + + + + diff --git a/doc/pub/Statistics/html/._Statistics.do.txt-bs024.html b/doc/pub/Statistics/html/._Statistics.do.txt-bs024.html new file mode 100644 index 000000000..943f87af2 --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics.do.txt-bs024.html @@ -0,0 +1,461 @@ + + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +

     

     

     

    + + + + +

    Probability Distribution Functions, Poisson's distribution

    +
    +
    +

    +An example of applications of the Poisson distribution could be the counting +of the number of \( \alpha \)-particles emitted from a radioactive source in a given time interval. +In the limit of \( n\rightarrow \infty \) and for small probabilities \( y \), the binomial distribution +approaches the Poisson distribution. Setting \( \lambda = ny \), with \( y \) the probability for an event in +the binomial distribution we can show that + +$$ +\begin{equation*} +\lim_{n\rightarrow \infty}\left(\begin{array}{c} n \\ x\end{array}\right)y^x(1-y)^{n-x} e^{-\lambda}=\sum_{x=1}^{\infty}\frac{\lambda^x}{x!} e^{-\lambda}. +\end{equation*} +$$ +

    +
    + + +

    +

    + +

    + + +
    + + + + + + + +
    + +
    + + + + + + diff --git a/doc/pub/Statistics/html/._Statistics.do.txt-bs025.html b/doc/pub/Statistics/html/._Statistics.do.txt-bs025.html new file mode 100644 index 000000000..20c4a05b3 --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics.do.txt-bs025.html @@ -0,0 +1,474 @@ + + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +

     

     

     

    + + + + +

    Meet the covariance!

    +
    +
    +

    +An important quantity in a statistical analysis is the so-called covariance. + +

    +Consider the set \( \{X_i\} \) of \( n \) +stochastic variables (not necessarily uncorrelated) with the +multivariate PDF \( P(x_1,\dots,x_n) \). The covariance of two +of the stochastic variables, \( X_i \) and \( X_j \), is defined as follows + +$$ +\begin{align} +\mathrm{Cov}(X_i,\,X_j) & = \langle (x_i-\langle x_i\rangle)(x_j-\langle x_j\rangle)\rangle +\tag{4}\\ +&=\int\cdots\int (x_i-\langle x_i\rangle)(x_j-\langle x_j\rangle)P(x_1,\dots,x_n)\,dx_1\dots dx_n, +\tag{5} +\end{align} +$$ + +with +$$ +\begin{equation*} +\langle x_i\rangle = +\int\cdots\int x_i P(x_1,\dots,x_n)\,dx_1\dots dx_n. +\end{equation*} +$$ +

    +
    + + +

    +

    + +

    + + +
    + + + + + + + +
    + +
    + + + + + + diff --git a/doc/pub/Statistics/html/._Statistics.do.txt-bs026.html b/doc/pub/Statistics/html/._Statistics.do.txt-bs026.html new file mode 100644 index 000000000..4a7c16ac0 --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics.do.txt-bs026.html @@ -0,0 +1,459 @@ + + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +

     

     

     

    + + + + +

    Meet the covariance in matrix disguise

    +
    +
    +

    +If we consider the above covariance as a matrix +$$ +C_{ij} =\mathrm{Cov}(X_i,\,X_j), +$$ + +then the diagonal elements are just the familiar +variances, \( C_{ii} = \mathrm{Cov}(X_i,\,X_i) = \mathrm{Var}(X_i) \). It turns out that +all the off-diagonal elements are zero if the stochastic variables are +uncorrelated. +

    +
    + + +

    +

    + +

    + + +
    + + + + + + + +
    + +
    + + + + + + diff --git a/doc/pub/Statistics/html/._Statistics.do.txt-bs027.html b/doc/pub/Statistics/html/._Statistics.do.txt-bs027.html new file mode 100644 index 000000000..a6aa0d49f --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics.do.txt-bs027.html @@ -0,0 +1,471 @@ + + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +

     

     

     

    + + + + +

    Covariance

    +

    + + +

    # Importing various packages
    +from math import exp, sqrt
    +from random import random, seed
    +import numpy as np
    +import matplotlib.pyplot as plt
    +
    +def covariance(x, y, n):
    +    sum = 0.0
    +    mean_x = np.mean(x)
    +    mean_y = np.mean(y)
    +    for i in range(0, n):
    +        sum += (x[(i)]-mean_x)*(y[i]-mean_y)
    +    return  sum/n
    +
    +n = 10
    +
    +x=np.random.normal(size=n)
    +y = 4+3*x+np.random.normal(size=n)
    +covxy = covariance(x,y,n)
    +print(covxy)
    +z = np.vstack((x, y))
    +c = np.cov(z.T)
    +
    +print(c)
    +
    +

    +

    + +

    + + +
    + + + + + + + +
    + +
    + + + + + + diff --git a/doc/pub/Statistics/html/._Statistics.do.txt-bs028.html b/doc/pub/Statistics/html/._Statistics.do.txt-bs028.html new file mode 100644 index 000000000..bf3b367d1 --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics.do.txt-bs028.html @@ -0,0 +1,474 @@ + + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +

     

     

     

    + + + + +

    Meet the covariance, uncorrelated events

    +
    +
    +

    + +

    +Consider the stochastic variables \( X_i \) and \( X_j \), (\( i\neq j \)). We have +$$ +\begin{align*} +Cov(X_i,\,X_j) &= \langle (x_i-\langle x_i\rangle)(x_j-\langle x_j\rangle)\rangle\\ +&=\langle x_i x_j - x_i\langle x_j\rangle - \langle x_i\rangle x_j + \langle x_i\rangle\langle x_j\rangle\rangle\\ +&=\langle x_i x_j\rangle - \langle x_i\langle x_j\rangle\rangle - \langle \langle x_i\rangle x_j \rangle + +\langle \langle x_i\rangle\langle x_j\rangle\rangle \\ +&=\langle x_i x_j\rangle - \langle x_i\rangle\langle x_j\rangle - \langle x_i\rangle\langle x_j\rangle + +\langle x_i\rangle\langle x_j\rangle \\ +&=\langle x_i x_j\rangle - \langle x_i\rangle\langle x_j\rangle +\end{align*} +$$ + +If \( X_i \) and \( X_j \) are independent (assuming \( i \neq j \)), we have that +$$ +\langle x_i x_j\rangle = \langle x_i\rangle\langle x_j\rangle, +$$ + +leading to +$$ +Cov(X_i, X_j) = 0 \hspace{0.1cm} (i\neq j). +$$ +

    +
    + + +

    +

    + +

    + + +
    + + + + + + + +
    + +
    + + + + + + diff --git a/doc/pub/Statistics/html/._Statistics.do.txt-bs029.html b/doc/pub/Statistics/html/._Statistics.do.txt-bs029.html new file mode 100644 index 000000000..ba252212b --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics.do.txt-bs029.html @@ -0,0 +1,466 @@ + + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +

     

     

     

    + + + + +

    Numerical experiments and the covariance

    +
    +
    +

    + +

    +Now that we have constructed an idealized mathematical framework, let +us try to apply it to empirical observations. Examples of relevant +physical phenomena may be spontaneous decays of nuclei, or a purely +mathematical set of numbers produced by some deterministic +mechanism. It is the latter we will deal with, using so-called pseudo-random +number generators. In general our observations will contain only a limited set of +observables. We remind the reader that +a stochastic process is a process that produces sequentially a +chain of values +$$ +\begin{equation*} +\{x_1, x_2,\dots\,x_k,\dots\}. +\end{equation*} +$$ +

    +
    + + +

    +

    + +

    + + +
    + + + + + + + +
    + +
    + + + + + + diff --git a/doc/pub/Statistics/html/._Statistics.do.txt-bs030.html b/doc/pub/Statistics/html/._Statistics.do.txt-bs030.html new file mode 100644 index 000000000..0e5275d29 --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics.do.txt-bs030.html @@ -0,0 +1,462 @@ + + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +

     

     

     

    + + + + +

    Numerical experiments and the covariance

    +
    +
    +

    +We will call these +values our measurements and the entire set as our measured +sample. The action of measuring all the elements of a sample +we will call a stochastic experiment (since, operationally, +they are often associated with results of empirical observation of +some physical or mathematical phenomena; precisely an experiment). We +assume that these values are distributed according to some +PDF \( p_X^{\phantom X}(x) \), where \( X \) is just the formal symbol for the +stochastic variable whose PDF is \( p_X^{\phantom X}(x) \). Instead of +trying to determine the full distribution \( p \) we are often only +interested in finding the few lowest moments, like the mean +\( \mu_X^{\phantom X} \) and the variance \( \sigma_X^{\phantom X} \). +

    +
    + + +

    +

    + +

    + + +
    + + + + + + + +
    + +
    + + + + + + diff --git a/doc/pub/Statistics/html/._Statistics.do.txt-bs031.html b/doc/pub/Statistics/html/._Statistics.do.txt-bs031.html new file mode 100644 index 000000000..15fbe4d90 --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics.do.txt-bs031.html @@ -0,0 +1,466 @@ + + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +

     

     

     

    + + + + +

    Numerical experiments and the covariance, actual situations

    +
    +
    +

    +In practical situations however, a sample is always of finite size. Let that +size be \( n \). The expectation value of a sample \( \alpha \), the sample mean, is then defined as follows +$$ +\begin{equation*} +\langle x_{\alpha} \rangle \equiv \frac{1}{n}\sum_{k=1}^n x_{\alpha,k}. +\end{equation*} +$$ + +The sample variance is: +$$ +\begin{equation*} +\mathrm{Var}(x) \equiv \frac{1}{n}\sum_{k=1}^n (x_{\alpha,k} - \langle x_{\alpha} \rangle)^2, +\end{equation*} +$$ + +with its square root being the standard deviation of the sample. +

    +
    + + +

    +

    + +

    + + +
    + + + + + + + +
    + +
    + + + + + + diff --git a/doc/pub/Statistics/html/._Statistics.do.txt-bs032.html b/doc/pub/Statistics/html/._Statistics.do.txt-bs032.html new file mode 100644 index 000000000..6458219d7 --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics.do.txt-bs032.html @@ -0,0 +1,475 @@ + + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +

     

     

     

    + + + + +

    Numerical experiments and the covariance, our observables

    +
    +
    +

    +You can think of the above observables as a set of quantities which define +a given experiment. This experiment is then repeated several times, say \( m \) times. +The total average is then +$$ +\begin{equation} +\langle X_m \rangle= \frac{1}{m}\sum_{\alpha=1}^mx_{\alpha}=\frac{1}{mn}\sum_{\alpha, k} x_{\alpha,k}, +\tag{6} +\end{equation} +$$ + +where the last sums end at \( m \) and \( n \). +The total variance is +$$ +\begin{equation*} +\sigma^2_m= \frac{1}{mn^2}\sum_{\alpha=1}^m(\langle x_{\alpha} \rangle-\langle X_m \rangle)^2, +\end{equation*} +$$ + +which we rewrite as +$$ +\begin{equation} +\sigma^2_m=\frac{1}{m}\sum_{\alpha=1}^m\sum_{kl=1}^n (x_{\alpha,k}-\langle X_m \rangle)(x_{\alpha,l}-\langle X_m \rangle). +\tag{7} +\end{equation} +$$ +

    +
    + + +

    +

    + +

    + + +
    + + + + + + + +
    + +
    + + + + + + diff --git a/doc/pub/Statistics/html/._Statistics.do.txt-bs033.html b/doc/pub/Statistics/html/._Statistics.do.txt-bs033.html new file mode 100644 index 000000000..415d13433 --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics.do.txt-bs033.html @@ -0,0 +1,466 @@ + + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +

     

     

     

    + + + + +

    Numerical experiments and the covariance, the sample variance

    +
    +
    +

    + +

    +We define also the sample variance \( \sigma^2 \) of all \( mn \) individual experiments as +$$ +\begin{equation} +\sigma^2=\frac{1}{mn}\sum_{\alpha=1}^m\sum_{k=1}^n (x_{\alpha,k}-\langle X_m \rangle)^2. +\tag{8} +\end{equation} +$$ + +

    +These quantities, being known experimental values or the results from our calculations, +may differ, in some cases +significantly, from the similarly named +exact values for the mean value \( \mu_X \), the variance \( \mathrm{Var}(X) \) +and the covariance \( \mathrm{Cov}(X,Y) \). +

    +
    + + +

    +

    + +

    + + +
    + + + + + + + +
    + +
    + + + + + + diff --git a/doc/pub/Statistics/html/._Statistics.do.txt-bs034.html b/doc/pub/Statistics/html/._Statistics.do.txt-bs034.html new file mode 100644 index 000000000..7b0430c01 --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics.do.txt-bs034.html @@ -0,0 +1,470 @@ + + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +

     

     

     

    + + + + +

    Numerical experiments and the covariance, central limit theorem

    +
    +
    +

    + +

    +The central limit theorem states that the PDF \( \tilde{p}(z) \) of +the average of \( m \) random values corresponding to a PDF \( p(x) \) +is a normal distribution whose mean is the +mean value of the PDF \( p(x) \) and whose variance is the variance +of the PDF \( p(x) \) divided by \( m \), the number of values used to compute \( z \). + +

    +The central limit theorem leads then to the well-known expression for the +standard deviation, given by +$$ +\begin{equation*} + \sigma_m= +\frac{\sigma}{\sqrt{m}}. +\end{equation*} +$$ + +

    +In many cases the above estimate for the standard deviation, in particular if correlations are strong, may be too simplistic. We need therefore a more precise defintion of the error and the variance in our results. +

    +
    + + +

    +

    + +

    + + +
    + + + + + + + +
    + +
    + + + + + + diff --git a/doc/pub/Statistics/html/._Statistics.do.txt-bs035.html b/doc/pub/Statistics/html/._Statistics.do.txt-bs035.html new file mode 100644 index 000000000..7dcbd5e35 --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics.do.txt-bs035.html @@ -0,0 +1,475 @@ + + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +

     

     

     

    + + + + +

    Definition of Correlation Functions and Standard Deviation

    +
    +
    +

    +Our estimate of the true average \( \mu_{X} \) is the sample mean \( \langle X_m \rangle \) + +$$ +\begin{equation*} +\mu_{X}^{\phantom X} \approx X_m=\frac{1}{mn}\sum_{\alpha=1}^m\sum_{k=1}^n x_{\alpha,k}. +\end{equation*} +$$ + +

    +We can then use Eq. (7) +$$ +\begin{equation*} +\sigma^2_m=\frac{1}{mn^2}\sum_{\alpha=1}^m\sum_{kl=1}^n (x_{\alpha,k}-\langle X_m \rangle)(x_{\alpha,l}-\langle X_m \rangle), +\end{equation*} +$$ + +and rewrite it as +$$ +\begin{equation*} +\sigma^2_m=\frac{\sigma^2}{n}+\frac{2}{mn^2}\sum_{\alpha=1}^m\sum_{k < l}^n (x_{\alpha,k}-\langle X_m \rangle)(x_{\alpha,l}-\langle X_m \rangle), +\end{equation*} +$$ + +where the first term is the sample variance of all \( mn \) experiments divided by \( n \) +and the last term is nothing but the covariance which arises when \( k\ne l \). +

    +
    + + +

    +

    + +

    + + +
    + + + + + + + +
    + +
    + + + + + + diff --git a/doc/pub/Statistics/html/._Statistics.do.txt-bs036.html b/doc/pub/Statistics/html/._Statistics.do.txt-bs036.html new file mode 100644 index 000000000..6deca0bf6 --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics.do.txt-bs036.html @@ -0,0 +1,464 @@ + + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +

     

     

     

    + + + + +

    Definition of Correlation Functions and Standard Deviation

    +
    +
    +

    +Our estimate of the true average \( \mu_{X} \) is the sample mean \( \langle X_m \rangle \) + +

    +If the +observables are uncorrelated, then the covariance is zero and we obtain a total variance +which agrees with the central limit theorem. Correlations may often be present in our data set, resulting in a non-zero covariance. The first term is normally called the uncorrelated +contribution. +Computationally the uncorrelated first term is much easier to treat +efficiently than the second. +We just accumulate separately the values \( x^2 \) and \( x \) for every +measurement \( x \) we receive. The correlation term, though, has to be +calculated at the end of the experiment since we need all the +measurements to calculate the cross terms. Therefore, all measurements +have to be stored throughout the experiment. +

    +
    + + +

    +

    + +

    + + +
    + + + + + + + +
    + +
    + + + + + + diff --git a/doc/pub/Statistics/html/._Statistics.do.txt-bs037.html b/doc/pub/Statistics/html/._Statistics.do.txt-bs037.html new file mode 100644 index 000000000..70202f676 --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics.do.txt-bs037.html @@ -0,0 +1,470 @@ + + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +

     

     

     

    + + + + +

    Definition of Correlation Functions and Standard Deviation

    +
    +
    +

    + +

    +Let us analyze the problem by splitting up the correlation term into +partial sums of the form + +$$ +\begin{equation*} +f_d = \frac{1}{nm}\sum_{\alpha=1}^m\sum_{k=1}^{n-d}(x_{\alpha,k}-\langle X_m \rangle)(x_{\alpha,k+d}-\langle X_m \rangle), +\end{equation*} +$$ + +The correlation term of the total variance can now be rewritten in terms of +\( f_d \) + +$$ +\begin{equation*} +\frac{2}{mn^2}\sum_{\alpha=1}^m\sum_{k < l}^n (x_{\alpha,k}-\langle X_m \rangle)(x_{\alpha,l}-\langle X_m \rangle)= +\frac{2}{n}\sum_{d=1}^{n-1} f_d +\end{equation*} +$$ +

    +
    + + +

    +

    + +

    + + +
    + + + + + + + +
    + +
    + + + + + + diff --git a/doc/pub/Statistics/html/._Statistics.do.txt-bs038.html b/doc/pub/Statistics/html/._Statistics.do.txt-bs038.html new file mode 100644 index 000000000..09e6410da --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics.do.txt-bs038.html @@ -0,0 +1,464 @@ + + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +

     

     

     

    + + + + +

    Definition of Correlation Functions and Standard Deviation

    +
    +
    +

    +The value of \( f_d \) reflects the correlation between measurements +separated by the distance \( d \) in the samples. Notice that for +\( d=0 \), \( f \) is just the sample variance, \( \sigma^2 \). If we divide \( f_d \) +by \( \sigma^2 \), we arrive at the so called autocorrelation function + +$$ +\begin{equation} +\kappa_d = \frac{f_d}{\sigma^2} +\tag{9} +\end{equation} +$$ + +which gives us a useful measure of the correlation pair correlation +starting always at \( 1 \) for \( d=0 \). +

    +
    + + +

    +

    + +

    + + +
    + + + + + + + +
    + +
    + + + + + + diff --git a/doc/pub/Statistics/html/._Statistics.do.txt-bs039.html b/doc/pub/Statistics/html/._Statistics.do.txt-bs039.html new file mode 100644 index 000000000..9ce4ea2f1 --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics.do.txt-bs039.html @@ -0,0 +1,479 @@ + + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +

     

     

     

    + + + + +

    Definition of Correlation Functions and Standard Deviation, sample variance

    +
    +
    +

    + +

    +The sample variance of the \( mn \) experiments can now be +written in terms of the autocorrelation function + +$$ +\begin{equation} +\sigma_m^2=\frac{\sigma^2}{n}+\frac{2}{n}\cdot\sigma^2\sum_{d=1}^{n-1} +\frac{f_d}{\sigma^2}=\left(1+2\sum_{d=1}^{n-1}\kappa_d\right)\frac{1}{n}\sigma^2=\frac{\tau}{n}\cdot\sigma^2 +\tag{10} +\end{equation} +$$ + +and we see that \( \sigma_m \) can be expressed in terms of the +uncorrelated sample variance times a correction factor \( \tau \) which +accounts for the correlation between measurements. We call this +correction factor the autocorrelation time + +$$ +\begin{equation} +\tau = 1+2\sum_{d=1}^{n-1}\kappa_d +\tag{11} +\end{equation} +$$ + + + +For a correlation free experiment, \( \tau \) +equals 1. +

    +
    + + +

    +

    + +

    + + +
    + + + + + + + +
    + +
    + + + + + + diff --git a/doc/pub/Statistics/html/._Statistics.do.txt-bs040.html b/doc/pub/Statistics/html/._Statistics.do.txt-bs040.html new file mode 100644 index 000000000..1b3df2c96 --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics.do.txt-bs040.html @@ -0,0 +1,468 @@ + + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +

     

     

     

    + + + + +

    Definition of Correlation Functions and Standard Deviation

    +
    +
    +

    +From the point of view of +Eq. (10) we can interpret a sequential +correlation as an effective reduction of the number of measurements by +a factor \( \tau \). The effective number of measurements becomes +$$ +\begin{equation*} +n_\mathrm{eff} = \frac{n}{\tau} +\end{equation*} +$$ + +To neglect the autocorrelation time \( \tau \) will always cause our +simple uncorrelated estimate of \( \sigma_m^2\approx \sigma^2/n \) to +be less than the true sample error. The estimate of the error will be +too "good". On the other hand, the calculation of the full +autocorrelation time poses an efficiency problem if the set of +measurements is very large. The solution to this problem is given by +more practically oriented methods like the blocking technique. + +

    +
    + + +

    +

    + +

    + + +
    + + + + + + + +
    + +
    + + + + + + diff --git a/doc/pub/Statistics/html/._Statistics.do.txt-bs041.html b/doc/pub/Statistics/html/._Statistics.do.txt-bs041.html new file mode 100644 index 000000000..ad27911b5 --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics.do.txt-bs041.html @@ -0,0 +1,484 @@ + + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +

     

     

     

    + + + + +

    Code to compute the Covariance matrix and the Covariance

    +

    + + +

    # Importing various packages
    +from math import exp, sqrt
    +from random import random, seed
    +import numpy as np
    +import matplotlib.pyplot as plt
    +
    +# Sample covariance, note the factor 1/(n-1)
    +def covariance(x, y, n):
    +    sum = 0.0
    +    mean_x = np.mean(x)
    +    mean_y = np.mean(y)
    +    for i in range(0, n):
    +        sum += (x[(i)]-mean_x)*(y[i]-mean_y)
    +    return  sum/(n-1.)
    +
    +n = 100
    +x = np.random.normal(size=n)
    +print(np.mean(x))
    +y = 4+3*x+np.random.normal(size=n)
    +print(np.mean(y))
    +z = x**3+np.random.normal(size=n)
    +print(np.mean(z))
    +covxx = covariance(x,x,n)
    +covyy = covariance(y,y,n)
    +covzz = covariance(z,z,n)
    +covxy = covariance(x,y,n)
    +covxz = covariance(x,z,n)
    +covyz = covariance(y,z,n)
    +print(covxx,covyy, covzz)
    +print(covxy,covxz, covyz)
    +w = np.vstack((x, y, z))
    +#print(w)
    +c = np.cov(w)
    +print(c)
    +#eigen = np.zeros(n)
    +Eigvals, Eigvecs = np.linalg.eig(c)
    +print(Eigvals)
    +
    +

    +

    + +

    + + +
    + + + + + + + +
    + +
    + + + + + + diff --git a/doc/pub/Statistics/html/._Statistics.do.txt-bs042.html b/doc/pub/Statistics/html/._Statistics.do.txt-bs042.html new file mode 100644 index 000000000..f5084cc1d --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics.do.txt-bs042.html @@ -0,0 +1,462 @@ + + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +

     

     

     

    + + + + +

    Random Numbers

    +
    +
    +

    + +

    +Uniform deviates are just random numbers that lie within a specified range +(typically 0 to 1), with any one number in the range just as likely as any other. They +are, in other words, what you probably think random numbers are. However, +we want to distinguish uniform deviates from other sorts of random numbers, for +example numbers drawn from a normal (Gaussian) distribution of specified mean +and standard deviation. These other sorts of deviates are almost always generated by +performing appropriate operations on one or more uniform deviates, as we will see +in subsequent sections. So, a reliable source of random uniform deviates, the subject +of this section, is an essential building block for any sort of stochastic modeling +or Monte Carlo computer work. +

    +
    + + +

    +

    + +

    + + +
    + + + + + + + +
    + +
    + + + + + + diff --git a/doc/pub/Statistics/html/._Statistics.do.txt-bs043.html b/doc/pub/Statistics/html/._Statistics.do.txt-bs043.html new file mode 100644 index 000000000..824a26213 --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics.do.txt-bs043.html @@ -0,0 +1,465 @@ + + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +

     

     

     

    + + + + +

    Random Numbers, better name: pseudo random numbers

    +
    +
    +

    + +

    +A disclaimer is however appropriate. It should be fairly obvious that +something as deterministic as a computer cannot generate purely random numbers. + +

    +Numbers generated by any of the standard algorithms are in reality pseudo random +numbers, hopefully abiding to the following criteria: + +

      +
    • they produce a uniform distribution in the interval [0,1].
    • +
    • correlations between random numbers are negligible
    • +
    • the period before the same sequence of random numbers is repeated is as large as possible and finally
    • +
    • the algorithm should be fast.
    • +
    +
    +
    + + +

    +

    + +

    + + +
    + + + + + + + +
    + +
    + + + + + + diff --git a/doc/pub/Statistics/html/._Statistics.do.txt-bs044.html b/doc/pub/Statistics/html/._Statistics.do.txt-bs044.html new file mode 100644 index 000000000..0e6f21fbf --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics.do.txt-bs044.html @@ -0,0 +1,474 @@ + + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +

     

     

     

    + + + + +

    Random number generator RNG

    +
    +
    +

    + The most common random number generators are based on so-called +Linear congruential relations of the type + +$$ +\begin{equation*} + N_i=(aN_{i-1}+c) \mathrm{MOD} (M), +\end{equation*} +$$ + +which yield a number in the interval [0,1] through + +$$ +\begin{equation*} + x_i=N_i/M +\end{equation*} +$$ + +

    +The number +\( M \) is called the period and it should be as large as possible + and +\( N_0 \) is the starting value, or seed. The function \( \mathrm{MOD} \) means the remainder, +that is if we were to evaluate \( (13)\mathrm{MOD}(9) \), the outcome is the remainder +of the division \( 13/9 \), namely \( 4 \). +

    +
    + + +

    +

    + +

    + + +
    + + + + + + + +
    + +
    + + + + + + diff --git a/doc/pub/Statistics/html/._Statistics.do.txt-bs045.html b/doc/pub/Statistics/html/._Statistics.do.txt-bs045.html new file mode 100644 index 000000000..5d5ac9608 --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics.do.txt-bs045.html @@ -0,0 +1,479 @@ + + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +

     

     

     

    + + + + +

    Random number generator RNG and periodic outputs

    +
    +
    +

    + +

    +The problem with such generators is that their outputs are periodic; +they +will start to repeat themselves with a period that is at most \( M \). If however +the parameters \( a \) and \( c \) are badly chosen, the period may be even shorter. + +

    +Consider the following example + +$$ +\begin{equation*} + N_i=(6N_{i-1}+7) \mathrm{MOD} (5), +\end{equation*} +$$ + +with a seed \( N_0=2 \). This generator produces the sequence +\( 4,1,3,0,2,4,1,3,0,2,...\dots \), i.e., a sequence with period \( 5 \). +However, increasing \( M \) may not guarantee a larger period as the following +example shows + +$$ +\begin{equation*} + N_i=(27N_{i-1}+11) \mathrm{MOD} (54), +\end{equation*} +$$ + +which still, with \( N_0=2 \), results in \( 11,38,11,38,11,38,\dots \), a period of +just \( 2 \). +

    +
    + + +

    +

    + +

    + + +
    + + + + + + + +
    + +
    + + + + + + diff --git a/doc/pub/Statistics/html/._Statistics.do.txt-bs046.html b/doc/pub/Statistics/html/._Statistics.do.txt-bs046.html new file mode 100644 index 000000000..b43dcdf3f --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics.do.txt-bs046.html @@ -0,0 +1,463 @@ + + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +

     

     

     

    + + + + +

    Random number generator RNG and its period

    +
    +
    +

    +Typical periods for the random generators provided in the program library +are of the order of \( \sim 10^9 \) or larger. Other random number generators which have +become increasingly popular are so-called shift-register generators. +In these generators each successive number depends on many preceding +values (rather than the last values as in the linear congruential +generator). +For example, you could make a shift register generator whose $l$th +number is the sum of the $l-i$th and $l-j$th values with modulo \( M \), +$$ +\begin{equation*} + N_l=(aN_{l-i}+cN_{l-j})\mathrm{MOD}(M). +\end{equation*} +$$ +

    +
    + + +

    +

    + +

    + + +
    + + + + + + + +
    + +
    + + + + + + diff --git a/doc/pub/Statistics/html/._Statistics.do.txt-bs047.html b/doc/pub/Statistics/html/._Statistics.do.txt-bs047.html new file mode 100644 index 000000000..07d423a62 --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics.do.txt-bs047.html @@ -0,0 +1,473 @@ + + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +

     

     

     

    + + + + +

    Random number generator RNG, other examples

    +
    +
    +

    +Such a generator again produces a sequence of pseudorandom numbers +but this time with a period much larger than \( M \). +It is also possible to construct more elaborate algorithms by including +more than two past terms in the sum of each iteration. +One example is the generator of Marsaglia and Zaman +which consists of two congruential relations + +$$ +\begin{equation} + N_l=(N_{l-3}-N_{l-1})\mathrm{MOD}(2^{31}-69), +\tag{12} +\end{equation} +$$ + +followed by +$$ +\begin{equation} + N_l=(69069N_{l-1}+1013904243)\mathrm{MOD}(2^{32}), +\tag{13} +\end{equation} +$$ + +which according to the authors has a period larger than \( 2^{94} \). +

    +
    + + +

    +

    + +

    + + +
    + + + + + + + +
    + +
    + + + + + + diff --git a/doc/pub/Statistics/html/._Statistics.do.txt-bs048.html b/doc/pub/Statistics/html/._Statistics.do.txt-bs048.html new file mode 100644 index 000000000..0132b83a4 --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics.do.txt-bs048.html @@ -0,0 +1,470 @@ + + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +

     

     

     

    + + + + +

    Random number generator RNG, other examples

    +
    +
    +

    +Instead of using modular addition, we could use the bitwise +exclusive-OR (\( \oplus \)) operation so that + +$$ +\begin{equation*} + N_l=(N_{l-i})\oplus (N_{l-j}) +\end{equation*} +$$ + +where the bitwise action of \( \oplus \) means that if \( N_{l-i}=N_{l-j} \) the result is +\( 0 \) whereas if \( N_{l-i}\ne N_{l-j} \) the result is +\( 1 \). As an example, consider the case where \( N_{l-i}=6 \) and \( N_{l-j}=11 \). The first +one has a bit representation (using 4 bits only) which reads \( 0110 \) whereas the +second number is \( 1011 \). Employing the \( \oplus \) operator yields +\( 1101 \), or \( 2^3+2^2+2^0=13 \). + +

    +In Fortran90, the bitwise \( \oplus \) operation is coded through the intrinsic +function \( \mathrm{IEOR}(m,n) \) where \( m \) and \( n \) are the input numbers, while in \( C \) +it is given by \( m\wedge n \). +

    +
    + + +

    +

    + +

    + + +
    + + + + + + + +
    + +
    + + + + + + diff --git a/doc/pub/Statistics/html/._Statistics.do.txt-bs049.html b/doc/pub/Statistics/html/._Statistics.do.txt-bs049.html new file mode 100644 index 000000000..8ed9d7495 --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics.do.txt-bs049.html @@ -0,0 +1,486 @@ + + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +

     

     

     

    + + + + +

    Random number generator RNG, RAN0

    +
    +
    +

    + +

    +We show here how the linear congruential algorithm can be implemented, namely +$$ +\begin{equation*} + N_i=(aN_{i-1}) \mathrm{MOD} (M). +\end{equation*} +$$ + +However, since \( a \) and \( N_{i-1} \) are integers and their multiplication +could become greater than the standard 32 bit integer, there is a trick via +Schrage's algorithm which approximates the multiplication +of large integers through the factorization +$$ +\begin{equation*} + M=aq+r, +\end{equation*} +$$ + +where we have defined + +$$ +\begin{equation*} + q=[M/a], +\end{equation*} +$$ + +and +$$ +\begin{equation*} + r = M\hspace{0.1cm}\mathrm{MOD} \hspace{0.1cm}a. +\end{equation*} +$$ + +where the brackets denote integer division. In the code below the numbers +\( q \) and \( r \) are chosen so that \( r < q \). +

    +
    + + +

    +

    + +

    + + +
    + + + + + + + +
    + +
    + + + + + + diff --git a/doc/pub/Statistics/html/._Statistics.do.txt-bs050.html b/doc/pub/Statistics/html/._Statistics.do.txt-bs050.html new file mode 100644 index 000000000..66733c640 --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics.do.txt-bs050.html @@ -0,0 +1,463 @@ + + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +

     

     

     

    + + + + +

    Random number generator RNG, RAN0

    +
    +
    +

    + +

    +To see how this works we note first that +$$ +\begin{equation} +(aN_{i-1}) \mathrm{MOD} (M)= (aN_{i-1}-[N_{i-1}/q]M)\mathrm{MOD} (M), +\tag{14} +\end{equation} +$$ + +since we can add or subtract any integer multiple of \( M \) from \( aN_{i-1} \). +The last term \( [N_{i-1}/q]M\mathrm{MOD}(M) \) is zero since the integer division +\( [N_{i-1}/q] \) just yields a constant which is multiplied with \( M \). +

    +
    + + +

    +

    + +

    + + +
    + + + + + + + +
    + +
    + + + + + + diff --git a/doc/pub/Statistics/html/._Statistics.do.txt-bs051.html b/doc/pub/Statistics/html/._Statistics.do.txt-bs051.html new file mode 100644 index 000000000..899eb130a --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics.do.txt-bs051.html @@ -0,0 +1,476 @@ + + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +

     

     

     

    + + + + +

    Random number generator RNG, RAN0

    +
    +
    +

    +We can now rewrite Eq. (14) as + +$$ +\begin{equation} +(aN_{i-1}) \mathrm{MOD} (M)= (aN_{i-1}-[N_{i-1}/q](aq+r))\mathrm{MOD} (M), +\tag{15} +\end{equation} +$$ + +which results +in + +$$ +\begin{equation} +(aN_{i-1}) \mathrm{MOD} (M)= \left(a(N_{i-1}-[N_{i-1}/q]q)-[N_{i-1}/q]r)\right)\mathrm{MOD} (M), +\tag{16} +\end{equation} +$$ + +yielding +$$ +\begin{equation} +(aN_{i-1}) \mathrm{MOD} (M)= \left(a(N_{i-1}\mathrm{MOD} (q)) -[N_{i-1}/q]r)\right)\mathrm{MOD} (M). +\tag{17} +\end{equation} +$$ +

    +
    + + +

    +

    + +

    + + +
    + + + + + + + +
    + +
    + + + + + + diff --git a/doc/pub/Statistics/html/._Statistics.do.txt-bs052.html b/doc/pub/Statistics/html/._Statistics.do.txt-bs052.html new file mode 100644 index 000000000..e8abc5e67 --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics.do.txt-bs052.html @@ -0,0 +1,462 @@ + + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +

     

     

     

    + + + + +

    Random number generator RNG, RAN0

    +
    +
    +

    +The term \( [N_{i-1}/q]r \) is always smaller or equal \( N_{i-1}(r/q) \) and with \( r < q \) we obtain always a +number smaller than \( N_{i-1} \), which is smaller than \( M \). +And since the number \( N_{i-1}\mathrm{MOD} (q) \) is between zero and \( q-1 \) then +\( a(N_{i-1}\mathrm{MOD} (q)) < aq \). Combined with our definition of \( q=[M/a] \) ensures that +this term is also smaller than \( M \) meaning that both terms fit into a +32-bit signed integer. None of these two terms can be negative, but their difference could. +The algorithm below adds \( M \) if their difference is negative. +Note that the program uses the bitwise \( \oplus \) operator to generate +the starting point for each generation of a random number. The period +of \( ran0 \) is \( \sim 2.1\times 10^{9} \). A special feature of this +algorithm is that is should never be called with the initial seed +set to \( 0 \). +

    +
    + + +

    +

    + +

    + + +
    + + + + + + + +
    + +
    + + + + + + diff --git a/doc/pub/Statistics/html/._Statistics.do.txt-bs053.html b/doc/pub/Statistics/html/._Statistics.do.txt-bs053.html new file mode 100644 index 000000000..27f011b77 --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics.do.txt-bs053.html @@ -0,0 +1,482 @@ + + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +

     

     

     

    + + + + +

    Random number generator RNG, RAN0 code

    +
    +
    +

    + +

    + + +

        /*
    +     ** The function
    +     **           ran0()
    +     ** is an "Minimal" random number generator of Park and Miller
    +     ** Set or reset the input value
    +     ** idum to any integer value (except the unlikely value MASK)
    +     ** to initialize the sequence; idum must not be altered between
    +     ** calls for sucessive deviates in a sequence.
    +     ** The function returns a uniform deviate between 0.0 and 1.0.
    +     */
    +double ran0(long &idum)
    +{
    +   const int a = 16807, m = 2147483647, q = 127773;
    +   const int r = 2836, MASK = 123459876;
    +   const double am = 1./m;
    +   long     k;
    +   double   ans;
    +   idum ^= MASK;
    +   k = (*idum)/q;
    +   idum = a*(idum - k*q) - r*k;
    +   // add m if negative difference
    +   if(idum < 0) idum += m;
    +   ans=am*(idum);
    +   idum ^= MASK;
    +   return ans;
    +} // End: function ran0() 
    +
    +

    +

    +
    + + +

    +

    + +

    + + +
    + + + + + + + +
    + +
    + + + + + + diff --git a/doc/pub/Statistics/html/._Statistics.do.txt-bs054.html b/doc/pub/Statistics/html/._Statistics.do.txt-bs054.html new file mode 100644 index 000000000..14cfff1be --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics.do.txt-bs054.html @@ -0,0 +1,467 @@ + + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +

     

     

     

    + + + + +

    Properties of Selected Random Number Generators

    +
    +
    +

    + +

    +As mentioned previously, the underlying PDF for the generation of +random numbers is the uniform distribution, meaning that the +probability for finding a number \( x \) in the interval [0,1] is \( p(x)=1 \). + +

    +A random number generator should produce numbers which are uniformly distributed +in this interval. The table shows the distribution of \( N=10000 \) random +numbers generated by the functions in the program library. +We note in this table that the number of points in the various +intervals \( 0.0-0.1 \), \( 0.1-0.2 \) etc are fairly close to \( 1000 \), with some minor +deviations. + +

    +Two additional measures are the standard deviation \( \sigma \) and the mean +\( \mu=\langle x\rangle \). +

    +
    + + +

    +

    + +

    + + +
    + + + + + + + +
    + +
    + + + + + + diff --git a/doc/pub/Statistics/html/._Statistics.do.txt-bs055.html b/doc/pub/Statistics/html/._Statistics.do.txt-bs055.html new file mode 100644 index 000000000..b03b7daa1 --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics.do.txt-bs055.html @@ -0,0 +1,465 @@ + + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +

     

     

     

    + + + + +

    Properties of Selected Random Number Generators

    +
    +
    +

    +For the uniform distribution, the mean value \( \mu \) is then + +$$ +\begin{equation*} + \mu=\langle x\rangle=\frac{1}{2} +\end{equation*} +$$ + +while the standard deviation is + +$$ +\begin{equation*} + \sigma=\sqrt{\langle x^2\rangle-\mu^2}=\frac{1}{\sqrt{12}}=0.2886. +\end{equation*} +$$ +

    +
    + + +

    +

    + +

    + + +
    + + + + + + + +
    + +
    + + + + + + diff --git a/doc/pub/Statistics/html/._Statistics.do.txt-bs056.html b/doc/pub/Statistics/html/._Statistics.do.txt-bs056.html new file mode 100644 index 000000000..a0f3a0722 --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics.do.txt-bs056.html @@ -0,0 +1,479 @@ + + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +

     

     

     

    + + + + +

    Properties of Selected Random Number Generators

    +
    +
    +

    +The various random number generators produce results which agree rather well with +these limiting values. + +

    + +

    +
    + + + + + + + + + + + + + + + + + + +
    \( x \)-bin ran0 ran1 ran2 ran3
    0.0-0.1 1013 991 938 1047
    0.1-0.2 1002 1009 1040 1030
    0.2-0.3 989 999 1030 993
    0.3-0.4 939 960 1023 937
    0.4-0.5 1038 1001 1002 992
    0.5-0.6 1037 1047 1009 1009
    0.6-0.7 1005 989 1003 989
    0.7-0.8 986 962 985 954
    0.8-0.9 1000 1027 1009 1023
    0.9-1.0 991 1015 961 1026
    \( \mu \) 0.4997 0.5018 0.4992 0.4990
    \( \sigma \) 0.2882 0.2892 0.2861 0.2915
    +
    +
    +

    +

    +
    + + +

    +

    + +

    + + +
    + + + + + + + +
    + +
    + + + + + + diff --git a/doc/pub/Statistics/html/._Statistics.do.txt-bs057.html b/doc/pub/Statistics/html/._Statistics.do.txt-bs057.html new file mode 100644 index 000000000..0d70f9a89 --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics.do.txt-bs057.html @@ -0,0 +1,480 @@ + + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +

     

     

     

    + + + + +

    Simple demonstration of RNGs using python

    +
    +
    +

    +The following simple Python code plots the distribution of the produced random numbers using the linear congruential RNG employed by Python. The trend displayed in the previous table is seen rather clearly. +

    + + +

    +

    +

    +
    + + +

    +

    + +

    + + +
    + + + + + + + +
    + +
    + + + + + + diff --git a/doc/pub/Statistics/html/._Statistics.do.txt-bs058.html b/doc/pub/Statistics/html/._Statistics.do.txt-bs058.html new file mode 100644 index 000000000..001e1c29b --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics.do.txt-bs058.html @@ -0,0 +1,477 @@ + + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +

     

     

     

    + + + + +

    Properties of Selected Random Number Generators

    +
    +
    +

    +Since our random numbers, which are typically generated via a linear congruential algorithm, +are never fully independent, we can then define +an important test which measures the degree of correlation, namely the so-called +auto-correlation function defined previously, see again Eq. (9). +We rewrite it here as +$$ +\begin{equation*} + C_k=\frac{f_d} + {\sigma^2}, +\end{equation*} +$$ + +with \( C_0=1 \). Recall that +\( \sigma^2=\langle x_i^2\rangle-\langle x_i\rangle^2 \) and that +$$ +\begin{equation*} +f_d = \frac{1}{nm}\sum_{\alpha=1}^m\sum_{k=1}^{n-d}(x_{\alpha,k}-\langle X_m \rangle)(x_{\alpha,k+d}-\langle X_m \rangle), +\end{equation*} +$$ + +

    +The non-vanishing of \( C_k \) for \( k\ne 0 \) means that the random +numbers are not independent. The independence of the random numbers is crucial +in the evaluation of other expectation values. If they are not independent, our +assumption for approximating \( \sigma_N \) is no longer valid. + +

    +

    +
    + + +

    +

    + +

    + + +
    + + + + + + + +
    + +
    + + + + + + diff --git a/doc/pub/Statistics/html/._Statistics.do.txt-bs059.html b/doc/pub/Statistics/html/._Statistics.do.txt-bs059.html new file mode 100644 index 000000000..d22bacd1b --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics.do.txt-bs059.html @@ -0,0 +1,481 @@ + + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +

     

     

     

    + + + + +

    Autocorrelation function

    +This program computes the autocorrelation function as discussed in the equation on the previous slide for random numbers generated with the normal distribution \( N(0,1) \). +

    + + +

    # Importing various packages
    +from math import exp, sqrt
    +from random import random, seed
    +import numpy as np
    +import matplotlib.pyplot as plt
    +
    +def autocovariance(x, n, k, mean_x):
    +    sum = 0.0
    +    for i in range(0, n-k):
    +        sum += (x[(i+k)]-mean_x)*(x[i]-mean_x)
    +    return  sum/n
    +
    +n = 1000
    +x=np.random.normal(size=n)
    +autocor = np.zeros(n)
    +figaxis = np.zeros(n)
    +mean_x=np.mean(x)
    +var_x = np.var(x)
    +print(mean_x, var_x)
    +for i in range (0, n):
    +    figaxis[i] = i
    +    autocor[i]=(autocovariance(x, n, i, mean_x))/var_x    
    +
    +plt.plot(figaxis, autocor, "r-")
    +plt.axis([0,n,-0.1, 1.0])
    +plt.xlabel(r'$i$')
    +plt.ylabel(r'$\gamma_i$')
    +plt.title(r'Autocorrelation function')
    +plt.show()
    +
    +

    +As can be seen from the plot, the first point gives back the variance and a value of one. +For the remaining values we notice that there are still non-zero values for the auto-correlation function. + +

    +

    + +

    + + +
    + + + + + + + +
    + +
    + + + + + + diff --git a/doc/pub/Statistics/html/._Statistics.do.txt-bs060.html b/doc/pub/Statistics/html/._Statistics.do.txt-bs060.html new file mode 100644 index 000000000..e5aa51926 --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics.do.txt-bs060.html @@ -0,0 +1,522 @@ + + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +

     

     

     

    + + + + +

    Correlation function and which random number generators should I use

    +
    +
    +

    +The program here computes the correlation function for one of the standard functions included with the c++ compiler. +

    + + +

    //  This function computes the autocorrelation function for 
    +//  the standard c++ random number generator
    +
    +#include <fstream>
    +#include <iomanip>
    +#include <iostream>
    +#include <cmath>
    +using namespace std;
    +// output file as global variable
    +ofstream ofile;  
    +
    +//     Main function begins here     
    +int main(int argc, char* argv[])
    +{
    +     int n;
    +     char *outfilename;
    +
    +     cin >> n;
    +     double MCint = 0.;      double MCintsqr2=0.;
    +     double invers_period = 1./RAND_MAX; // initialise the random number generator
    +     srand(time(NULL));  // This produces the so-called seed in MC jargon
    +     // Compute the variance and the mean value of the uniform distribution
    +     // Compute also the specific values x for each cycle in order to be able to
    +     // the covariance and the correlation function  
    +     // Read in output file, abort if there are too few command-line arguments
    +     if( argc <= 2 ){
    +       cout << "Bad Usage: " << argv[0] << 
    +	 " read also output file and number of cycles on same line" << endl;
    +       exit(1);
    +     }
    +     else{
    +       outfilename=argv[1];
    +     }
    +     ofile.open(outfilename); 
    +     // Get  the number of Monte-Carlo samples
    +     n = atoi(argv[2]);
    +     double *X;  
    +     X = new double[n];
    +     for (int i = 0;  i < n; i++){
    +           double x = double(rand())*invers_period; 
    +           X[i] = x;
    +           MCint += x;
    +           MCintsqr2 += x*x;
    +     }
    +     double Mean = MCint/((double) n );
    +     MCintsqr2 = MCintsqr2/((double) n );
    +     double STDev = sqrt(MCintsqr2-Mean*Mean);
    +     double Variance = MCintsqr2-Mean*Mean;
    +//   Write mean value and standard deviation 
    +     cout << " Standard deviation= " << STDev << " Integral = " << Mean << endl;
    +
    +     // Now we compute the autocorrelation function
    +     double *autocor;  autocor = new double[n];
    +     for (int j = 0; j < n; j++){
    +       double sum = 0.0;
    +       for (int k = 0; k < (n-j); k++){
    +	 sum  += (X[k]-Mean)*(X[k+j]-Mean); 
    +       }
    +       autocor[j] = sum/Variance/((double) n );
    +       ofile << setiosflags(ios::showpoint | ios::uppercase);
    +       ofile << setw(15) << setprecision(8) << j;
    +       ofile << setw(15) << setprecision(8) << autocor[j] << endl;
    +     }
    +     ofile.close();  // close output file
    +     return 0;
    +}  // end of main program 
    +
    +

    +

    +
    + + +

    +

    + +

    + + +
    + + + + + + + +
    + +
    + + + + + + diff --git a/doc/pub/Statistics/html/._Statistics.do.txt-bs061.html b/doc/pub/Statistics/html/._Statistics.do.txt-bs061.html new file mode 100644 index 000000000..6e658d2d1 --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics.do.txt-bs061.html @@ -0,0 +1,455 @@ + + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +

     

     

     

    + + + + +

    Which RNG should I use?

    +
    +
    +

    + +

      +
    • C++ has a class called random. The random class contains a large selection of RNGs and is highly recommended. Some of these RNGs have very large periods making it thereby very safe to use these RNGs in case one is performing large calculations. In particular, the Mersenne twister random number engine has a period of \( 2^{19937} \).
    • +
    • Add RNGs in Python
    • +
    +
    +
    + + +

    +

    + +

    + + +
    + + + + + + + +
    + +
    + + + + + + diff --git a/doc/pub/Statistics/html/._Statistics.do.txt-bs062.html b/doc/pub/Statistics/html/._Statistics.do.txt-bs062.html new file mode 100644 index 000000000..081c078f4 --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics.do.txt-bs062.html @@ -0,0 +1,469 @@ + + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +

     

     

     

    + + + + +

    How to use the Mersenne generator

    +
    +
    +

    +The following part of a c++ code (from project 4) sets up the uniform distribution for \( x\in [0,1] \). +

    + + +

    /*
    +
    +//  You need this 
    +#include <random>
    +
    +// Initialize the seed and call the Mersienne algo
    +std::random_device rd;
    +std::mt19937_64 gen(rd());
    +// Set up the uniform distribution for x \in [[0, 1]
    +std::uniform_real_distribution<double> RandomNumberGenerator(0.0,1.0);
    +
    +// Now use the RNG
    +int ix = (int) (RandomNumberGenerator(gen)*NSpins);
    +
    +

    +

    +
    + + +

    +

    + +

    + + +
    + + + + + + + +
    + +
    + + + + + + diff --git a/doc/pub/Statistics/html/._Statistics.do.txt-bs063.html b/doc/pub/Statistics/html/._Statistics.do.txt-bs063.html new file mode 100644 index 000000000..a2c75d542 --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics.do.txt-bs063.html @@ -0,0 +1,460 @@ + + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +

     

     

     

    + + + + +

    Why blocking?

    +
    +
    +

    + +

      +
    • Monte Carlo simulations can be treated as computer experiments
    • +
    • The results can be analysed with the same statistical tools as we would use analysing experimental data.
    • +
    • As in all experiments, we are looking for expectation values and an estimate of how accurate they are, i.e., possible sources for errors.
    • +
    + +A very good article which explains blocking is H. Flyvbjerg and H. G. Petersen, Error estimates on averages of correlated data, Journal of Chemical Physics 91, 461-466 (1989). + +

    +

    +
    + + +

    +

    + +

    + + +
    + + + + + + + +
    + +
    + + + + + + diff --git a/doc/pub/Statistics/html/._Statistics.do.txt-bs064.html b/doc/pub/Statistics/html/._Statistics.do.txt-bs064.html new file mode 100644 index 000000000..8acd0206d --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics.do.txt-bs064.html @@ -0,0 +1,462 @@ + + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +

     

     

     

    + + + + +

    Why blocking?

    +
    +
    +

    + +

      +
    • As in other experiments, Monte Carlo experiments have two classes of errors:
    • + +
        +
      • Statistical errors
      • +
      • Systematical errors
      • +
      + +
    • Statistical errors can be estimated using standard tools from statistics
    • +
    • Systematical errors are method specific and must be treated differently from case to case. (In VMC a common source is the step length or time step in importance sampling)
    • +
    +
    +
    + + +

    +

    + +

    + + +
    + + + + + + + +
    + +
    + + + + + + diff --git a/doc/pub/Statistics/html/._Statistics.do.txt-bs065.html b/doc/pub/Statistics/html/._Statistics.do.txt-bs065.html new file mode 100644 index 000000000..023d19b7f --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics.do.txt-bs065.html @@ -0,0 +1,527 @@ + + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +

     

     

     

    + + + + +

    Code to demonstrate the calculation of the autocorrelation function

    +The following code computes the autocorrelation function, the covariance and the standard deviation +for standard RNG. +The following file gives the code. +

    + + +

    //  This function computes the autocorrelation function for 
    +//  the Mersenne random number generator with a uniform distribution
    +#include <iostream>
    +#include <fstream>
    +#include <iomanip>
    +#include <cstdlib>
    +#include <random>
    +#include <armadillo>
    +#include <string>
    +#include <cmath>
    +using namespace  std;
    +using namespace arma;
    +// output file
    +ofstream ofile;
    +
    +//     Main function begins here     
    +int main(int argc, char* argv[])
    +{
    +  int MonteCarloCycles;
    +  string filename;
    +  if (argc > 1) {
    +    filename=argv[1];
    +    MonteCarloCycles = atoi(argv[2]);
    +    string fileout = filename;
    +    string argument = to_string(MonteCarloCycles);
    +    fileout.append(argument);
    +    ofile.open(fileout);
    +  }
    +
    +  // Compute the variance and the mean value of the uniform distribution
    +  // Compute also the specific values x for each cycle in order to be able to
    +  // compute the covariance and the correlation function  
    +
    +  vec X  = zeros<vec>(MonteCarloCycles);
    +  double MCint = 0.;      double MCintsqr2=0.;
    +  std::random_device rd;
    +  std::mt19937_64 gen(rd());
    +  // Set up the uniform distribution for x \in [[0, 1]
    +  std::uniform_real_distribution<double> RandomNumberGenerator(0.0,1.0);
    +  for (int i = 0;  i < MonteCarloCycles; i++){
    +    double x =   RandomNumberGenerator(gen); 
    +    X(i) = x;
    +    MCint += x;
    +    MCintsqr2 += x*x;
    +  }
    +  double Mean = MCint/((double) MonteCarloCycles );
    +  MCintsqr2 = MCintsqr2/((double) MonteCarloCycles );
    +  double STDev = sqrt(MCintsqr2-Mean*Mean);
    +  double Variance = MCintsqr2-Mean*Mean;
    +  //   Write mean value and variance
    +  cout << " Sample variance= " << Variance  << " Mean value = " << Mean << endl;
    +  // Now we compute the autocorrelation function
    +  vec autocorrelation = zeros<vec>(MonteCarloCycles);
    +  for (int j = 0; j < MonteCarloCycles; j++){
    +    double sum = 0.0;
    +    for (int k = 0; k < (MonteCarloCycles-j); k++){
    +      sum  += (X(k)-Mean)*(X(k+j)-Mean); 
    +    }
    +    autocorrelation(j) = sum/Variance/((double) MonteCarloCycles );
    +    ofile << setiosflags(ios::showpoint | ios::uppercase);
    +    ofile << setw(15) << setprecision(8) << j;
    +    ofile << setw(15) << setprecision(8) << autocorrelation(j) << endl;
    +  }
    +  // Now compute the exact covariance using the autocorrelation function
    +  double Covariance = 0.0;
    +  for (int j = 0; j < MonteCarloCycles; j++){
    +    Covariance  += autocorrelation(j);
    +  }
    +  Covariance *=  2.0/((double) MonteCarloCycles);
    +  // Compute now the total variance, including the covariance, and obtain the standard deviation
    +  double TotalVariance = (Variance/((double) MonteCarloCycles ))+Covariance;
    +  cout << "Covariance =" << Covariance << "Totalvariance= " << TotalVariance << "Sample Variance/n= " << (Variance/((double) MonteCarloCycles )) << endl;
    +  cout << " STD from sample variance= " << sqrt(Variance/((double) MonteCarloCycles )) << " STD with covariance = " << sqrt(TotalVariance) << endl;
    +
    +  ofile.close();  // close output file
    +  return 0;
    +}  // end of main program 
    +
    +

    +

    + +

    + + +
    + + + + + + + +
    + +
    + + + + + + diff --git a/doc/pub/Statistics/html/._Statistics.do.txt-bs066.html b/doc/pub/Statistics/html/._Statistics.do.txt-bs066.html new file mode 100644 index 000000000..d4b3b1a0e --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics.do.txt-bs066.html @@ -0,0 +1,468 @@ + + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +

     

     

     

    + + + + +

    What is blocking?

    +
    +
    +

    + +

      +
    • Say that we have a set of samples from a Monte Carlo experiment
    • +
    • Assuming (wrongly) that our samples are uncorrelated our best estimate of the standard deviation of the mean \( \langle \mathbf{M}\rangle \) is given by
    • +
    + +$$ +\sigma=\sqrt{\frac{1}{n}\left(\langle \mathbf{M}^2\rangle-\langle \mathbf{M}\rangle^2\right)} +$$ + + +
      +
    • If the samples are correlated we can rewrite our results to show that
    • +
    + +$$ +\sigma=\sqrt{\frac{1+2\tau/\Delta t}{n}\left(\langle \mathbf{M}^2\rangle-\langle \mathbf{M}\rangle^2\right)} +$$ + + where \( \tau \) is the correlation time (the time between a sample and the next uncorrelated sample) and \( \Delta t \) is time between each sample +
    +
    + + +

    +

    + +

    + + +
    + + + + + + + +
    + +
    + + + + + + diff --git a/doc/pub/Statistics/html/._Statistics.do.txt-bs067.html b/doc/pub/Statistics/html/._Statistics.do.txt-bs067.html new file mode 100644 index 000000000..3d0f6e9b3 --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics.do.txt-bs067.html @@ -0,0 +1,456 @@ + + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +

     

     

     

    + + + + +

    What is blocking?

    +
    +
    +

    + +

      +
    • If \( \Delta t\gg\tau \) our first estimate of \( \sigma \) still holds
    • +
    • Much more common that \( \Delta t < \tau \)
    • +
    • In the method of data blocking we divide the sequence of samples into blocks
    • +
    • We then take the mean \( \langle \mathbf{M}_i\rangle \) of block \( i=1\ldots n_{blocks} \) to calculate the total mean and variance
    • +
    • The size of each block must be so large that sample \( j \) of block \( i \) is not correlated with sample \( j \) of block \( i+1 \)
    • +
    • The correlation time \( \tau \) would be a good choice
    • +
    +
    +
    + + +

    +

    + +

    + + +
    + + + + + + + +
    + +
    + + + + + + diff --git a/doc/pub/Statistics/html/._Statistics.do.txt-bs068.html b/doc/pub/Statistics/html/._Statistics.do.txt-bs068.html new file mode 100644 index 000000000..2792b3b96 --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics.do.txt-bs068.html @@ -0,0 +1,453 @@ + + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +

     

     

     

    + + + + +

    What is blocking?

    +
    +
    +

    + +

      +
    • Problem: We don't know \( \tau \) or it is too expensive to compute
    • +
    • Solution: Make a plot of std. dev. as a function of blocksize
    • +
    • The estimate of std. dev. of correlated data is too low \( \to \) the error will increase with increasing block size until the blocks are uncorrelated, where we reach a plateau
    • +
    • When the std. dev. stops increasing the blocks are uncorrelated
    • +
    +
    +
    + + +

    +

    + +

    + + +
    + + + + + + + +
    + +
    + + + + + + diff --git a/doc/pub/Statistics/html/._Statistics.do.txt-bs069.html b/doc/pub/Statistics/html/._Statistics.do.txt-bs069.html new file mode 100644 index 000000000..f8319083d --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics.do.txt-bs069.html @@ -0,0 +1,456 @@ + + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +

     

     

     

    + + + + +

    Implementation

    +
    +
    +

    + +

      +
    • Do a Monte Carlo simulation, storing all samples to file
    • +
    • Do the statistical analysis on this file, independently of your Monte Carlo program
    • +
    • Read the file into an array
    • +
    • Loop over various block sizes
    • +
    • For each block size \( n_b \), loop over the array in steps of \( n_b \) taking the mean of elements \( i n_b,\ldots,(i+1) n_b \)
    • +
    • Take the mean and variance of the resulting array
    • +
    • Write the results for each block size to file for later + analysis
    • +
    +
    +
    + + +

    +

    + +

    + + +
    + + + + + + + +
    + +
    + + + + + + diff --git a/doc/pub/Statistics/html/._Statistics.do.txt-bs070.html b/doc/pub/Statistics/html/._Statistics.do.txt-bs070.html new file mode 100644 index 000000000..d914e1b7e --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics.do.txt-bs070.html @@ -0,0 +1,473 @@ + + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +

     

     

     

    + + + + +

    Actual implementation with code, main function

    +When the file gets large, it can be useful to write your data in binary mode instead of ascii characters. +The following python file reads data from file with the output from every Monte Carlo cycle. +

    + + +

    # Blocking
    +    @timeFunction
    +    def blocking(self, blockSizeMax = 500):
    +        blockSizeMin = 1
    +
    +        self.blockSizes = []
    +        self.meanVec = []
    +        self.varVec = []
    +
    +        for i in range(blockSizeMin, blockSizeMax):
    +            if(len(self.data) % i != 0):
    +                pass#continue
    +            blockSize = i
    +            meanTempVec = []
    +            varTempVec = []
    +            startPoint = 0
    +            endPoint = blockSize
    +
    +            while endPoint <= len(self.data):
    +                meanTempVec.append(np.average(self.data[startPoint:endPoint]))
    +                startPoint = endPoint
    +                endPoint += blockSize
    +            mean, var = np.average(meanTempVec), np.var(meanTempVec)/len(meanTempVec)
    +            self.meanVec.append(mean)
    +            self.varVec.append(var)
    +            self.blockSizes.append(blockSize)
    +
    +        self.blockingAvg = np.average(self.meanVec[-200:])
    +        self.blockingVar = (np.average(self.varVec[-200:]))
    +        self.blockingStd = np.sqrt(self.blockingVar)
    +
    +

    +

    + +

    + + +
    + + + + + + + +
    + +
    + + + + + + diff --git a/doc/pub/Statistics/html/._Statistics.do.txt-bs071.html b/doc/pub/Statistics/html/._Statistics.do.txt-bs071.html new file mode 100644 index 000000000..516a96cf8 --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics.do.txt-bs071.html @@ -0,0 +1,452 @@ + + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +

     

     

     

    + + + + +

    The Bootstrap method

    + +

    +The Bootstrap resampling method is also very popular. It is very simple: + +

      +
    1. Start with your sample of measurements and compute the sample variance and the mean values
    2. +
    3. Then start again but pick in a random way the numbers in the sample and recalculate the mean and the sample variance.
    4. +
    5. Repeat this \( K \) times.
    6. +
    + +It can be shown, see the article by Efron +that it produces the correct standard deviation. + +

    +This method is very useful for small ensembles of data points. + +

    +

    + +

    + + +
    + + + + + + + +
    + +
    + + + + + + diff --git a/doc/pub/Statistics/html/._Statistics.do.txt-bs072.html b/doc/pub/Statistics/html/._Statistics.do.txt-bs072.html new file mode 100644 index 000000000..f980431b5 --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics.do.txt-bs072.html @@ -0,0 +1,442 @@ + + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +

     

     

     

    + + + + +

    Bootstrapping

    +Given a set of \( N \) data, assume that we are interested in some +observable \( \theta \) which may be estimated from that set. This observable can also be for example the result of a fit based on all \( N \) raw data. +Let us call the value of the observable obtained from the original +data set \( \hat{\theta} \). One recreates from the sample repeatedly +other samples by choosing randomly \( N \) data out of the original set. +This costs essentially nothing, since we just recycle the original data set for the building of new sets. + +

    +

    + +

    + + +
    + + + + + + + +
    + +
    + + + + + + diff --git a/doc/pub/Statistics/html/._Statistics.do.txt-bs073.html b/doc/pub/Statistics/html/._Statistics.do.txt-bs073.html new file mode 100644 index 000000000..b9535c5e6 --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics.do.txt-bs073.html @@ -0,0 +1,454 @@ + + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +

     

     

     

    + + + + +

    Bootstrapping, recipe

    +Let us assume we have done this \( K \) times and thus have \( K \) sets of \( N \) +data values each. +Of course some values will enter more than once in the new sets. For each of these sets one computes the observable \( \theta \) resulting in values \( \theta_k \) with \( k = 1,...,K \). Then one determines +$$ +\tilde{\theta} = \frac{1}{K} \sum_{k=1}^K \theta_k, +$$ + +and +$$ +sigma^2_{\tilde{\theta}} = \frac{1}{K} \sum_{k=1}^K \left(\theta_k-\tilde{\theta}\right)^2. +$$ + +

    +These are estimators for \( \angle\theta\rangle \) and its variance. They are not unbiased and therefore +\( \tilde{\theta}\neq\hat{\theta} \) for finite K. + +

    +The difference is called bias and gives an idea on how far away the result may be from +the true \( \angle\theta\rangle \). As final result for the observable one quotes \( \angle\theta\rangle = \tilde{\theta} \pm \sigma_{\tilde{\theta}} \) . + +

    +

    + +

    + + +
    + + + + + + + +
    + +
    + + + + + + diff --git a/doc/pub/Statistics/html/._Statistics.do.txt-bs074.html b/doc/pub/Statistics/html/._Statistics.do.txt-bs074.html new file mode 100644 index 000000000..195fb4a78 --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics.do.txt-bs074.html @@ -0,0 +1,446 @@ + + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +

     

     

     

    + + + + +

    Bootstrapping, code

    +

    + + +

    # Bootstrap
    +    @timeFunction
    +    def bootstrap(self, nBoots = 1000):
    +        bootVec = np.zeros(nBoots)
    +        for k in range(0,nBoots):
    +            bootVec[k] = np.average(np.random.choice(self.data, len(self.data)))
    +        self.bootAvg = np.average(bootVec)
    +        self.bootVar = np.var(bootVec)
    +        self.bootStd = np.std(bootVec)
    +
    +

    +

    + +

    + + +
    + + + + + + + +
    + +
    + + + + + + diff --git a/doc/pub/Statistics/html/._Statistics.do.txt-bs075.html b/doc/pub/Statistics/html/._Statistics.do.txt-bs075.html new file mode 100644 index 000000000..c7ca893d8 --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics.do.txt-bs075.html @@ -0,0 +1,445 @@ + + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +

     

     

     

    + + + + +

    Jackknife, code

    +

    + + +

    # Jackknife
    +    @timeFunction
    +    def jackknife(self):
    +        jackknVec = np.zeros(len(self.data))
    +        for k in range(0,len(self.data)):
    +            jackknVec[k] = np.average(np.delete(self.data, k))
    +        self.jackknAvg = self.avg - (len(self.data) - 1) * (np.average(jackknVec) - self.avg)
    +        self.jackknVar = float(len(self.data) - 1) * np.var(jackknVec)
    +        self.jackknStd = np.sqrt(self.jackknVar)
    +
    +

    + +

    + +

    + + +
    + + + + + + + +
    + +
    + + + + + + diff --git a/doc/pub/Statistics/html/Statistics-bs.html b/doc/pub/Statistics/html/Statistics-bs.html index 0383be408..ff6dac9b0 100644 --- a/doc/pub/Statistics/html/Statistics-bs.html +++ b/doc/pub/Statistics/html/Statistics-bs.html @@ -6,6 +6,7 @@ Automatically generated HTML file from DocOnce source + Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis @@ -55,43 +56,40 @@ $(function () { @@ -296,80 +298,81 @@ MathJax.Hub.Config({ @@ -404,7 +407,7 @@ MathJax.Hub.Config({
    [2] Department of Physics and Astronomy and National Superconducting Cyclotron Laboratory, Michigan State University

    -

    Aug 27, 2018

    +

    Sep 20, 2020


    @@ -428,7 +431,7 @@ MathJax.Hub.Config({

  • 9
  • 10
  • ...
  • -
  • 75
  • +
  • 76
  • »
  • @@ -446,7 +449,7 @@ MathJax.Hub.Config({
    - © 1999-2018, Morten Hjorth-Jensen. Released under CC Attribution-NonCommercial 4.0 license + © 1999-2020, Morten Hjorth-Jensen. Released under CC Attribution-NonCommercial 4.0 license
    diff --git a/doc/pub/Statistics/html/Statistics-reveal.html b/doc/pub/Statistics/html/Statistics-reveal.html index b28db8abf..6b9ebfaee 100644 --- a/doc/pub/Statistics/html/Statistics-reveal.html +++ b/doc/pub/Statistics/html/Statistics-reveal.html @@ -1,8 +1,8 @@ -\ + Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis @@ -163,18 +163,29 @@ MathJax.Hub.Config({
    [2] Department of Physics and Astronomy and National Superconducting Cyclotron Laboratory, Michigan State University

     
    -

    Aug 27, 2018

    +

    Sep 20, 2020


    - © 1999-2018, Morten Hjorth-Jensen. Released under CC Attribution-NonCommercial 4.0 license + © 1999-2020, Morten Hjorth-Jensen. Released under CC Attribution-NonCommercial 4.0 license
    -

    Domains and probabilities

    +

    To do list

    + + +
    + + +
    +

    Domains and probabilities

    @@ -201,7 +212,7 @@ $$

    -

    Tossing the dice

    +

    Tossing the dice

    @@ -237,7 +248,7 @@ $$

    -

    Stochastic variables

    +

    Stochastic variables

    @@ -247,7 +258,7 @@ $$

    -

    Stochastic variables and the main concepts, the discrete case

    +

    Stochastic variables and the main concepts, the discrete case

    @@ -274,7 +285,7 @@ $$

    -

    Stochastic variables and the main concepts, the continuous case

    +

    Stochastic variables and the main concepts, the continuous case

    @@ -302,7 +313,7 @@ selection of a large set of these numbers reproduces this PDF.

    -

    The cumulative probability

    +

    The cumulative probability

    @@ -332,7 +343,7 @@ $$

    -

    Properties of PDFs

    +

    Properties of PDFs

    @@ -365,7 +376,7 @@ $$

    -

    Important distributions, the uniform distribution

    +

    Important distributions, the uniform distribution

    @@ -395,7 +406,7 @@ The latter distribution is used to generate random numbers. For other PDFs, one

    -

    Gaussian distribution

    +

    Gaussian distribution

    @@ -468,7 +479,7 @@ plt.show()

    -

    Exponential distribution

    +

    Exponential distribution

    @@ -485,7 +496,7 @@ $$

    -

    Expectation values

    +

    Expectation values

    @@ -519,7 +530,7 @@ $$

    -

    Stochastic variables and the main concepts, mean values

    +

    Stochastic variables and the main concepts, mean values

    @@ -551,7 +562,7 @@ PDF and is therefore simply called the expectation value of \( p(x) \).

    -

    Stochastic variables and the main concepts, central moments, the variance

    +

    Stochastic variables and the main concepts, central moments, the variance

    @@ -589,7 +600,7 @@ qualitatively as the "spread" of \( p \) around its mean.

    -

    Probability Distribution Functions

    +

    Probability Distribution Functions

    @@ -618,7 +629,7 @@ while \( P(x) \) is the cumulative probability.

    -

    Probability Distribution Functions

    +

    Probability Distribution Functions

    @@ -649,7 +660,7 @@ and the variance \( \sigma^2 \).

    -

    The three famous Probability Distribution Functions

    +

    The three famous Probability Distribution Functions

    @@ -700,7 +711,7 @@ $$

    -

    Probability Distribution Functions, the normal distribution

    +

    Probability Distribution Functions, the normal distribution

    @@ -738,7 +749,7 @@ $$

    -

    Probability Distribution Functions, the normal distribution

    +

    Probability Distribution Functions, the normal distribution

    @@ -779,7 +790,7 @@ $$

    -

    Probability Distribution Functions, the cumulative distribution

    +

    Probability Distribution Functions, the cumulative distribution

    @@ -801,7 +812,7 @@ which is difficult to evaluate in a quick way.

    -

    Probability Distribution Functions, other important distribution

    +

    Probability Distribution Functions, other important distribution

    @@ -833,7 +844,7 @@ The sequence of binomial trials is characterized by the following definitions

    -

    Probability Distribution Functions, the binomial distribution

    +

    Probability Distribution Functions, the binomial distribution

    @@ -894,7 +905,7 @@ The variance is slightly trickier to get. It reads \( \sigma^2=ny(1-y) \).

    -

    Probability Distribution Functions, Poisson's distribution

    +

    Probability Distribution Functions, Poisson's distribution

    @@ -925,7 +936,7 @@ and the variance is \( \sigma^2=\lambda \).

    -

    Probability Distribution Functions, Poisson's distribution

    +

    Probability Distribution Functions, Poisson's distribution

    @@ -947,7 +958,7 @@ $$

    -

    Meet the covariance!

    +

    Meet the covariance!

    @@ -984,7 +995,7 @@ $$

    -

    Meet the covariance in matrix disguise

    +

    Meet the covariance in matrix disguise

    @@ -1004,7 +1015,7 @@ uncorrelated.

    -

    Covariance

    +

    Covariance

    @@ -1027,17 +1038,17 @@ n = 10 x=np.random.normal(size=n) y = 4+3*x+np.random.normal(size=n) covxy = covariance(x,y,n) -print(covxy) +print(covxy) z = np.vstack((x, y)) c = np.cov(z.T) -print(c) +print(c)

    -

    Meet the covariance, uncorrelated events

    +

    Meet the covariance, uncorrelated events

    @@ -1074,7 +1085,7 @@ $$

    -

    Numerical experiments and the covariance

    +

    Numerical experiments and the covariance

    @@ -1099,7 +1110,7 @@ $$

    -

    Numerical experiments and the covariance

    +

    Numerical experiments and the covariance

    @@ -1120,7 +1131,7 @@ interested in finding the few lowest moments, like the mean

    -

    Numerical experiments and the covariance, actual situations

    +

    Numerical experiments and the covariance, actual situations

    @@ -1149,7 +1160,7 @@ with its square root being the standard deviation of the sample.

    -

    Numerical experiments and the covariance, our observables

    +

    Numerical experiments and the covariance, our observables

    @@ -1189,7 +1200,7 @@ $$

    -

    Numerical experiments and the covariance, the sample variance

    +

    Numerical experiments and the covariance, the sample variance

    @@ -1214,7 +1225,7 @@ and the covariance \( \mathrm{Cov}(X,Y) \).

    -

    Numerical experiments and the covariance, central limit theorem

    +

    Numerical experiments and the covariance, central limit theorem

    @@ -1243,7 +1254,7 @@ In many cases the above estimate for the standard deviation, in particular if co

    -

    Definition of Correlation Functions and Standard Deviation

    +

    Definition of Correlation Functions and Standard Deviation

    @@ -1283,7 +1294,7 @@ and the last term is nothing but the covariance which arises when \( k\ne l \).

    -

    Definition of Correlation Functions and Standard Deviation

    +

    Definition of Correlation Functions and Standard Deviation

    @@ -1306,7 +1317,7 @@ have to be stored throughout the experiment.

    -

    Definition of Correlation Functions and Standard Deviation

    +

    Definition of Correlation Functions and Standard Deviation

    @@ -1337,7 +1348,7 @@ $$

    -

    Definition of Correlation Functions and Standard Deviation

    +

    Definition of Correlation Functions and Standard Deviation

    @@ -1362,7 +1373,7 @@ starting always at \( 1 \) for \( d=0 \).

    -

    Definition of Correlation Functions and Standard Deviation, sample variance

    +

    Definition of Correlation Functions and Standard Deviation, sample variance

    @@ -1402,7 +1413,7 @@ equals 1.

    -

    Definition of Correlation Functions and Standard Deviation

    +

    Definition of Correlation Functions and Standard Deviation

    @@ -1431,7 +1442,7 @@ more practically oriented methods like the blocking technique.

    -

    Code to compute the Covariance matrix and the Covariance

    +

    Code to compute the Covariance matrix and the Covariance

    @@ -1452,32 +1463,32 @@ more practically oriented methods like the blocking technique. n = 100 x = np.random.normal(size=n) -print(np.mean(x)) +print(np.mean(x)) y = 4+3*x+np.random.normal(size=n) -print(np.mean(y)) +print(np.mean(y)) z = x**3+np.random.normal(size=n) -print(np.mean(z)) +print(np.mean(z)) covxx = covariance(x,x,n) covyy = covariance(y,y,n) covzz = covariance(z,z,n) covxy = covariance(x,y,n) covxz = covariance(x,z,n) covyz = covariance(y,z,n) -print(covxx,covyy, covzz) -print(covxy,covxz, covyz) +print(covxx,covyy, covzz) +print(covxy,covxz, covyz) w = np.vstack((x, y, z)) #print(w) c = np.cov(w) -print(c) +print(c) #eigen = np.zeros(n) Eigvals, Eigvecs = np.linalg.eig(c) -print(Eigvals) +print(Eigvals)

    -

    Random Numbers

    +

    Random Numbers

    @@ -1496,7 +1507,7 @@ or Monte Carlo computer work.

    -

    Random Numbers, better name: pseudo random numbers

    +

    Random Numbers, better name: pseudo random numbers

    @@ -1522,7 +1533,7 @@ numbers, hopefully abiding to the following criteria:

    -

    Random number generator RNG

    +

    Random number generator RNG

    @@ -1559,7 +1570,7 @@ of the division \( 13/9 \), namely \( 4 \).

    -

    Random number generator RNG and periodic outputs

    +

    Random number generator RNG and periodic outputs

    @@ -1599,7 +1610,7 @@ just \( 2 \).

    -

    Random number generator RNG and its period

    +

    Random number generator RNG and its period

    @@ -1623,7 +1634,7 @@ $$

    -

    Random number generator RNG, other examples

    +

    Random number generator RNG, other examples

    @@ -1659,7 +1670,7 @@ which according to the authors has a period larger than \( 2^{94} \).

    -

    Random number generator RNG, other examples

    +

    Random number generator RNG, other examples

    @@ -1690,7 +1701,7 @@ it is given by \( m\wedge n \).

    -

    Random number generator RNG, RAN0

    +

    Random number generator RNG, RAN0

    @@ -1741,7 +1752,7 @@ where the brackets denote integer division. In the code below the numbers

    -

    Random number generator RNG, RAN0

    +

    Random number generator RNG, RAN0

    @@ -1763,7 +1774,7 @@ The last term \( [N_{i-1}/q]M\mathrm{MOD}(M) \) is zero since the integer divisi

    -

    Random number generator RNG, RAN0

    +

    Random number generator RNG, RAN0

    @@ -1804,7 +1815,7 @@ $$

    -

    Random number generator RNG, RAN0

    +

    Random number generator RNG, RAN0

    @@ -1825,7 +1836,7 @@ set to \( 0 \).

    -

    Random number generator RNG, RAN0 code

    +

    Random number generator RNG, RAN0 code

    @@ -1864,7 +1875,7 @@ set to \( 0 \).

    -

    Properties of Selected Random Number Generators

    +

    Properties of Selected Random Number Generators

    @@ -1888,7 +1899,7 @@ Two additional measures are the standard deviation \( \sigma \) and the mean

    -

    Properties of Selected Random Number Generators

    +

    Properties of Selected Random Number Generators

    @@ -1916,7 +1927,7 @@ $$

    -

    Properties of Selected Random Number Generators

    +

    Properties of Selected Random Number Generators

    @@ -1949,7 +1960,7 @@ these limiting values.

    -

    Simple demonstration of RNGs using python

    +

    Simple demonstration of RNGs using python

    @@ -1988,7 +1999,7 @@ plt.show()

    -

    Properties of Selected Random Number Generators

    +

    Properties of Selected Random Number Generators

    @@ -2028,7 +2039,7 @@ assumption for approximating \( \sigma_N \) is no longer valid.

    -

    Autocorrelation function

    +

    Autocorrelation function

    This program computes the autocorrelation function as discussed in the equation on the previous slide for random numbers generated with the normal distribution \( N(0,1) \).

    @@ -2051,7 +2062,7 @@ autocor = np.zeros(n) figaxis = np.zeros(n) mean_x=np.mean(x) var_x = np.var(x) -print(mean_x, var_x) +print(mean_x, var_x) for i in range (0, n): figaxis[i] = i autocor[i]=(autocovariance(x, n, i, mean_x))/var_x @@ -2070,7 +2081,7 @@ For the remaining values we notice that there are still non-zero values for the

    -

    Correlation function and which random number generators should I use

    +

    Correlation function and which random number generators should I use

    @@ -2151,7 +2162,7 @@ ofstream ofile;

    -

    Which RNG should I use?

    +

    Which RNG should I use?

      @@ -2163,7 +2174,7 @@ ofstream ofile;
      -

      How to use the Mersenne generator

      +

      How to use the Mersenne generator

      @@ -2191,7 +2202,7 @@ The following part of a c++ code (from project 4) sets up the uniform distributi

      -

      Why blocking?

      +

      Why blocking?

      Statistical analysis.
        @@ -2212,7 +2223,7 @@ A very good article which explains blocking is H. Flyvbjerg and H. G. Petersen,
        -

        Why blocking?

        +

        Why blocking?

        Statistical analysis.
          @@ -2234,7 +2245,7 @@ A very good article which explains blocking is H. Flyvbjerg and H. G. Petersen,
          -

          Code to demonstrate the calculation of the autocorrelation function

          +

          Code to demonstrate the calculation of the autocorrelation function

          The following code computes the autocorrelation function, the covariance and the standard deviation for standard RNG. The following file gives the code. @@ -2323,7 +2334,7 @@ ofstream ofile;
          -

          What is blocking?

          +

          What is blocking?

          Blocking.
            @@ -2355,7 +2366,7 @@ $$
            -

            What is blocking?

            +

            What is blocking?

            Blocking.
              @@ -2377,7 +2388,7 @@ $$
              -

              What is blocking?

              +

              What is blocking?

              Blocking.
                @@ -2395,7 +2406,7 @@ $$
                -

                Implementation

                +

                Implementation

                  @@ -2420,7 +2431,7 @@ $$
                  -

                  Actual implementation with code, main function

                  +

                  Actual implementation with code, main function

                  When the file gets large, it can be useful to write your data in binary mode instead of ascii characters. The following python file reads data from file with the output from every Monte Carlo cycle.

                  @@ -2461,7 +2472,7 @@ The The Bootstrap method +

                  The Bootstrap method

                  The Bootstrap resampling method is also very popular. It is very simple: @@ -2482,7 +2493,7 @@ This method is very useful for small ensembles of data points.

                  -

                  Bootstrapping

                  +

                  Bootstrapping

                  Given a set of \( N \) data, assume that we are interested in some observable \( \theta \) which may be estimated from that set. This observable can also be for example the result of a fit based on all \( N \) raw data. Let us call the value of the observable obtained from the original @@ -2493,7 +2504,7 @@ This costs essentially nothing, since we just recycle the original data set for
                  -

                  Bootstrapping, recipe

                  +

                  Bootstrapping, recipe

                  Let us assume we have done this \( K \) times and thus have \( K \) sets of \( N \) data values each. Of course some values will enter more than once in the new sets. For each of these sets one computes the observable \( \theta \) resulting in values \( \theta_k \) with \( k = 1,...,K \). Then one determines @@ -2521,7 +2532,7 @@ the true \( \angle\theta\rangle \). As final result for the observable one quote
                  -

                  Bootstrapping, code

                  +

                  Bootstrapping, code

                  @@ -2539,7 +2550,7 @@ the true \( \angle\theta\rangle \). As final result for the observable one quote

                  -

                  Jackknife, code

                  +

                  Jackknife, code

                  diff --git a/doc/pub/Statistics/html/Statistics-solarized.html b/doc/pub/Statistics/html/Statistics-solarized.html index e53be939f..d6af08719 100644 --- a/doc/pub/Statistics/html/Statistics-solarized.html +++ b/doc/pub/Statistics/html/Statistics-solarized.html @@ -6,6 +6,7 @@ Automatically generated HTML file from DocOnce source + Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis @@ -75,43 +76,40 @@ $(function () { @@ -320,12 +322,22 @@ MathJax.Hub.Config({

                  [2] Department of Physics and Astronomy and National Superconducting Cyclotron Laboratory, Michigan State University

                  -

                  Aug 27, 2018

                  +

                  Sep 20, 2020












                  -

                  Domains and probabilities

                  +

                  To do list

                  + +
                    +
                  • add math about MVN and define MLE and other quantities
                  • +
                  • rewrite about covariance matrix
                  • +
                  • add KL theorem
                  • +
                  + +









                  + +

                  Domains and probabilities

                  @@ -349,7 +361,7 @@ $$











                  -

                  Tossing the dice

                  +

                  Tossing the dice

                  @@ -382,7 +394,7 @@ $$











                  -

                  Stochastic variables

                  +

                  Stochastic variables

                  @@ -395,7 +407,7 @@ $$











                  -

                  Stochastic variables and the main concepts, the discrete case

                  +

                  Stochastic variables and the main concepts, the discrete case

                  @@ -421,7 +433,7 @@ $$











                  -

                  Stochastic variables and the main concepts, the continuous case

                  +

                  Stochastic variables and the main concepts, the continuous case

                  @@ -448,7 +460,7 @@ selection of a large set of these numbers reproduces this PDF.











                  -

                  The cumulative probability

                  +

                  The cumulative probability

                  @@ -475,7 +487,7 @@ $$











                  -

                  Properties of PDFs

                  +

                  Properties of PDFs

                  @@ -507,7 +519,7 @@ $$











                  -

                  Important distributions, the uniform distribution

                  +

                  Important distributions, the uniform distribution

                  @@ -534,7 +546,7 @@ The latter distribution is used to generate random numbers. For other PDFs, one











                  -

                  Gaussian distribution

                  +

                  Gaussian distribution

                  @@ -604,7 +616,7 @@ plt.show()











                  -

                  Exponential distribution

                  +

                  Exponential distribution

                  @@ -620,7 +632,7 @@ $$











                  -

                  Expectation values

                  +

                  Expectation values

                  @@ -651,7 +663,7 @@ $$











                  -

                  Stochastic variables and the main concepts, mean values

                  +

                  Stochastic variables and the main concepts, mean values

                  @@ -680,7 +692,7 @@ PDF and is therefore simply called the expectation value of \( p(x) \).











                  -

                  Stochastic variables and the main concepts, central moments, the variance

                  +

                  Stochastic variables and the main concepts, central moments, the variance

                  @@ -717,7 +729,7 @@ qualitatively as the "spread" of \( p \) around its mean.











                  -

                  Probability Distribution Functions

                  +

                  Probability Distribution Functions

                  @@ -749,7 +761,7 @@ while \( P(x) \) is the cumulative probability.











                  -

                  Probability Distribution Functions

                  +

                  Probability Distribution Functions

                  @@ -777,7 +789,7 @@ and the variance \( \sigma^2 \).











                  -

                  The three famous Probability Distribution Functions

                  +

                  The three famous Probability Distribution Functions

                  @@ -821,7 +833,7 @@ $$











                  -

                  Probability Distribution Functions, the normal distribution

                  +

                  Probability Distribution Functions, the normal distribution

                  @@ -854,7 +866,7 @@ $$











                  -

                  Probability Distribution Functions, the normal distribution

                  +

                  Probability Distribution Functions, the normal distribution

                  @@ -890,7 +902,7 @@ $$











                  -

                  Probability Distribution Functions, the cumulative distribution

                  +

                  Probability Distribution Functions, the cumulative distribution

                  @@ -913,7 +925,7 @@ which is difficult to evaluate in a quick way.











                  -

                  Probability Distribution Functions, other important distribution

                  +

                  Probability Distribution Functions, other important distribution

                  @@ -943,7 +955,7 @@ The sequence of binomial trials is characterized by the following definitions











                  -

                  Probability Distribution Functions, the binomial distribution

                  +

                  Probability Distribution Functions, the binomial distribution

                  @@ -996,7 +1008,7 @@ The variance is slightly trickier to get. It reads \( \sigma^2=ny(1-y) \).











                  -

                  Probability Distribution Functions, Poisson's distribution

                  +

                  Probability Distribution Functions, Poisson's distribution

                  @@ -1026,7 +1038,7 @@ and the variance is \( \sigma^2=\lambda \).











                  -

                  Probability Distribution Functions, Poisson's distribution

                  +

                  Probability Distribution Functions, Poisson's distribution

                  @@ -1047,7 +1059,7 @@ $$











                  -

                  Meet the covariance!

                  +

                  Meet the covariance!

                  @@ -1081,7 +1093,7 @@ $$











                  -

                  Meet the covariance in matrix disguise

                  +

                  Meet the covariance in matrix disguise

                  @@ -1100,7 +1112,7 @@ uncorrelated.











                  -

                  Covariance

                  +

                  Covariance

                  @@ -1123,16 +1135,16 @@ n = 10 x=np.random.normal(size=n) y = 4+3*x+np.random.normal(size=n) covxy = covariance(x,y,n) -print(covxy) +print(covxy) z = np.vstack((x, y)) c = np.cov(z.T) -print(c) +print(c)











                  -

                  Meet the covariance, uncorrelated events

                  +

                  Meet the covariance, uncorrelated events

                  @@ -1166,7 +1178,7 @@ $$











                  -

                  Numerical experiments and the covariance

                  +

                  Numerical experiments and the covariance

                  @@ -1192,7 +1204,7 @@ $$











                  -

                  Numerical experiments and the covariance

                  +

                  Numerical experiments and the covariance

                  @@ -1214,7 +1226,7 @@ interested in finding the few lowest moments, like the mean











                  -

                  Numerical experiments and the covariance, actual situations

                  +

                  Numerical experiments and the covariance, actual situations

                  @@ -1240,7 +1252,7 @@ with its square root being the standard deviation of the sample.











                  -

                  Numerical experiments and the covariance, our observables

                  +

                  Numerical experiments and the covariance, our observables

                  @@ -1275,7 +1287,7 @@ $$











                  -

                  Numerical experiments and the covariance, the sample variance

                  +

                  Numerical experiments and the covariance, the sample variance

                  @@ -1301,7 +1313,7 @@ and the covariance \( \mathrm{Cov}(X,Y) \).











                  -

                  Numerical experiments and the covariance, central limit theorem

                  +

                  Numerical experiments and the covariance, central limit theorem

                  @@ -1331,7 +1343,7 @@ In many cases the above estimate for the standard deviation, in particular if co











                  -

                  Definition of Correlation Functions and Standard Deviation

                  +

                  Definition of Correlation Functions and Standard Deviation

                  @@ -1366,7 +1378,7 @@ and the last term is nothing but the covariance which arises when \( k\ne l \).











                  -

                  Definition of Correlation Functions and Standard Deviation

                  +

                  Definition of Correlation Functions and Standard Deviation

                  @@ -1390,7 +1402,7 @@ have to be stored throughout the experiment.











                  -

                  Definition of Correlation Functions and Standard Deviation

                  +

                  Definition of Correlation Functions and Standard Deviation

                  @@ -1420,7 +1432,7 @@ $$











                  -

                  Definition of Correlation Functions and Standard Deviation

                  +

                  Definition of Correlation Functions and Standard Deviation

                  @@ -1444,7 +1456,7 @@ starting always at \( 1 \) for \( d=0 \).











                  -

                  Definition of Correlation Functions and Standard Deviation, sample variance

                  +

                  Definition of Correlation Functions and Standard Deviation, sample variance

                  @@ -1483,7 +1495,7 @@ equals 1.











                  -

                  Definition of Correlation Functions and Standard Deviation

                  +

                  Definition of Correlation Functions and Standard Deviation

                  @@ -1511,7 +1523,7 @@ more practically oriented methods like the blocking technique.

                  -

                  Code to compute the Covariance matrix and the Covariance

                  +

                  Code to compute the Covariance matrix and the Covariance

                  @@ -1532,31 +1544,31 @@ more practically oriented methods like the blocking technique. n = 100 x = np.random.normal(size=n) -print(np.mean(x)) +print(np.mean(x)) y = 4+3*x+np.random.normal(size=n) -print(np.mean(y)) +print(np.mean(y)) z = x**3+np.random.normal(size=n) -print(np.mean(z)) +print(np.mean(z)) covxx = covariance(x,x,n) covyy = covariance(y,y,n) covzz = covariance(z,z,n) covxy = covariance(x,y,n) covxz = covariance(x,z,n) covyz = covariance(y,z,n) -print(covxx,covyy, covzz) -print(covxy,covxz, covyz) +print(covxx,covyy, covzz) +print(covxy,covxz, covyz) w = np.vstack((x, y, z)) #print(w) c = np.cov(w) -print(c) +print(c) #eigen = np.zeros(n) Eigvals, Eigvecs = np.linalg.eig(c) -print(Eigvals) +print(Eigvals)











                  -

                  Random Numbers

                  +

                  Random Numbers

                  @@ -1578,7 +1590,7 @@ or Monte Carlo computer work.











                  -

                  Random Numbers, better name: pseudo random numbers

                  +

                  Random Numbers, better name: pseudo random numbers

                  @@ -1603,7 +1615,7 @@ numbers, hopefully abiding to the following criteria:











                  -

                  Random number generator RNG

                  +

                  Random number generator RNG

                  @@ -1637,7 +1649,7 @@ of the division \( 13/9 \), namely \( 4 \).











                  -

                  Random number generator RNG and periodic outputs

                  +

                  Random number generator RNG and periodic outputs

                  @@ -1676,7 +1688,7 @@ just \( 2 \).











                  -

                  Random number generator RNG and its period

                  +

                  Random number generator RNG and its period

                  @@ -1699,7 +1711,7 @@ $$











                  -

                  Random number generator RNG, other examples

                  +

                  Random number generator RNG, other examples

                  @@ -1732,7 +1744,7 @@ which according to the authors has a period larger than \( 2^{94} \).











                  -

                  Random number generator RNG, other examples

                  +

                  Random number generator RNG, other examples

                  @@ -1762,7 +1774,7 @@ it is given by \( m\wedge n \).











                  -

                  Random number generator RNG, RAN0

                  +

                  Random number generator RNG, RAN0

                  @@ -1808,7 +1820,7 @@ where the brackets denote integer division. In the code below the numbers











                  -

                  Random number generator RNG, RAN0

                  +

                  Random number generator RNG, RAN0

                  @@ -1831,7 +1843,7 @@ The last term \( [N_{i-1}/q]M\mathrm{MOD}(M) \) is zero since the integer divisi











                  -

                  Random number generator RNG, RAN0

                  +

                  Random number generator RNG, RAN0

                  @@ -1867,7 +1879,7 @@ $$











                  -

                  Random number generator RNG, RAN0

                  +

                  Random number generator RNG, RAN0

                  @@ -1889,7 +1901,7 @@ set to \( 0 \).











                  -

                  Random number generator RNG, RAN0 code

                  +

                  Random number generator RNG, RAN0 code

                  @@ -1931,7 +1943,7 @@ set to \( 0 \).











                  -

                  Properties of Selected Random Number Generators

                  +

                  Properties of Selected Random Number Generators

                  @@ -1958,7 +1970,7 @@ Two additional measures are the standard deviation \( \sigma \) and the mean











                  -

                  Properties of Selected Random Number Generators

                  +

                  Properties of Selected Random Number Generators

                  @@ -1983,7 +1995,7 @@ $$











                  -

                  Properties of Selected Random Number Generators

                  +

                  Properties of Selected Random Number Generators

                  @@ -2017,7 +2029,7 @@ these limiting values.











                  -

                  Simple demonstration of RNGs using python

                  +

                  Simple demonstration of RNGs using python

                  @@ -2057,7 +2069,7 @@ plt.show()











                  -

                  Properties of Selected Random Number Generators

                  +

                  Properties of Selected Random Number Generators

                  @@ -2094,7 +2106,7 @@ assumption for approximating \( \sigma_N \) is no longer valid.











                  -

                  Autocorrelation function

                  +

                  Autocorrelation function

                  This program computes the autocorrelation function as discussed in the equation on the previous slide for random numbers generated with the normal distribution \( N(0,1) \).

                  @@ -2117,7 +2129,7 @@ autocor = np.zeros(n) figaxis = np.zeros(n) mean_x=np.mean(x) var_x = np.var(x) -print(mean_x, var_x) +print(mean_x, var_x) for i in range (0, n): figaxis[i] = i autocor[i]=(autocovariance(x, n, i, mean_x))/var_x @@ -2136,7 +2148,7 @@ For the remaining values we notice that there are still non-zero values for the











                  -

                  Correlation function and which random number generators should I use

                  +

                  Correlation function and which random number generators should I use

                  @@ -2218,7 +2230,7 @@ ofstream ofile;











                  -

                  Which RNG should I use?

                  +

                  Which RNG should I use?

                  @@ -2233,7 +2245,7 @@ ofstream ofile;











                  -

                  How to use the Mersenne generator

                  +

                  How to use the Mersenne generator

                  @@ -2262,7 +2274,7 @@ The following part of a c++ code (from project 4) sets up the uniform distributi











                  -

                  Why blocking?

                  +

                  Why blocking?

                  Statistical analysis.

                  @@ -2282,7 +2294,7 @@ A very good article which explains blocking is H. Flyvbjerg and H. G. Petersen,











                  -

                  Why blocking?

                  +

                  Why blocking?

                  Statistical analysis.

                  @@ -2304,7 +2316,7 @@ A very good article which explains blocking is H. Flyvbjerg and H. G. Petersen,











                  -

                  Code to demonstrate the calculation of the autocorrelation function

                  +

                  Code to demonstrate the calculation of the autocorrelation function

                  The following code computes the autocorrelation function, the covariance and the standard deviation for standard RNG. The following file gives the code. @@ -2392,7 +2404,7 @@ ofstream ofile;











                  -

                  What is blocking?

                  +

                  What is blocking?

                  Blocking.

                  @@ -2422,7 +2434,7 @@ $$











                  -

                  What is blocking?

                  +

                  What is blocking?

                  Blocking.

                  @@ -2441,7 +2453,7 @@ $$











                  -

                  What is blocking?

                  +

                  What is blocking?

                  Blocking.

                  @@ -2458,7 +2470,7 @@ $$











                  -

                  Implementation

                  +

                  Implementation

                  @@ -2479,7 +2491,7 @@ $$











                  -

                  Actual implementation with code, main function

                  +

                  Actual implementation with code, main function

                  When the file gets large, it can be useful to write your data in binary mode instead of ascii characters. The following python file reads data from file with the output from every Monte Carlo cycle.

                  @@ -2519,7 +2531,7 @@ The The Bootstrap method +

                  The Bootstrap method

                  The Bootstrap resampling method is also very popular. It is very simple: @@ -2539,7 +2551,7 @@ This method is very useful for small ensembles of data points.

                  -

                  Bootstrapping

                  +

                  Bootstrapping

                  Given a set of \( N \) data, assume that we are interested in some observable \( \theta \) which may be estimated from that set. This observable can also be for example the result of a fit based on all \( N \) raw data. Let us call the value of the observable obtained from the original @@ -2550,7 +2562,7 @@ This costs essentially nothing, since we just recycle the original data set for

                  -

                  Bootstrapping, recipe

                  +

                  Bootstrapping, recipe

                  Let us assume we have done this \( K \) times and thus have \( K \) sets of \( N \) data values each. Of course some values will enter more than once in the new sets. For each of these sets one computes the observable \( \theta \) resulting in values \( \theta_k \) with \( k = 1,...,K \). Then one determines @@ -2574,7 +2586,7 @@ the true \( \angle\theta\rangle \). As final result for the observable one quote

                  -

                  Bootstrapping, code

                  +

                  Bootstrapping, code

                  @@ -2591,7 +2603,7 @@ the true \( \angle\theta\rangle \). As final result for the observable one quote

                  -

                  Jackknife, code

                  +

                  Jackknife, code

                  @@ -2611,7 +2623,7 @@ the true \( \angle\theta\rangle \). As final result for the observable one quote

                  - © 1999-2018, Morten Hjorth-Jensen. Released under CC Attribution-NonCommercial 4.0 license + © 1999-2020, Morten Hjorth-Jensen. Released under CC Attribution-NonCommercial 4.0 license
                  diff --git a/doc/pub/Statistics/html/Statistics.html b/doc/pub/Statistics/html/Statistics.html index fc5eaf8a3..30b253550 100644 --- a/doc/pub/Statistics/html/Statistics.html +++ b/doc/pub/Statistics/html/Statistics.html @@ -6,6 +6,7 @@ Automatically generated HTML file from DocOnce source + Data Analysis and Machine Learning: Elements of Probability Theory and Statistical Data Analysis @@ -80,43 +81,40 @@ $(function () { @@ -325,12 +327,22 @@ MathJax.Hub.Config({
                  [2] Department of Physics and Astronomy and National Superconducting Cyclotron Laboratory, Michigan State University

                  -

                  Aug 27, 2018

                  +

                  Sep 20, 2020












                  -

                  Domains and probabilities

                  +

                  To do list

                  + +
                    +
                  • add math about MVN and define MLE and other quantities
                  • +
                  • rewrite about covariance matrix
                  • +
                  • add KL theorem
                  • +
                  + +









                  + +

                  Domains and probabilities

                  @@ -354,7 +366,7 @@ $$











                  -

                  Tossing the dice

                  +

                  Tossing the dice

                  @@ -387,7 +399,7 @@ $$











                  -

                  Stochastic variables

                  +

                  Stochastic variables

                  @@ -400,7 +412,7 @@ $$











                  -

                  Stochastic variables and the main concepts, the discrete case

                  +

                  Stochastic variables and the main concepts, the discrete case

                  @@ -426,7 +438,7 @@ $$











                  -

                  Stochastic variables and the main concepts, the continuous case

                  +

                  Stochastic variables and the main concepts, the continuous case

                  @@ -453,7 +465,7 @@ selection of a large set of these numbers reproduces this PDF.











                  -

                  The cumulative probability

                  +

                  The cumulative probability

                  @@ -480,7 +492,7 @@ $$











                  -

                  Properties of PDFs

                  +

                  Properties of PDFs

                  @@ -512,7 +524,7 @@ $$











                  -

                  Important distributions, the uniform distribution

                  +

                  Important distributions, the uniform distribution

                  @@ -539,7 +551,7 @@ The latter distribution is used to generate random numbers. For other PDFs, one











                  -

                  Gaussian distribution

                  +

                  Gaussian distribution

                  @@ -609,7 +621,7 @@ plt.show()











                  -

                  Exponential distribution

                  +

                  Exponential distribution

                  @@ -625,7 +637,7 @@ $$











                  -

                  Expectation values

                  +

                  Expectation values

                  @@ -656,7 +668,7 @@ $$











                  -

                  Stochastic variables and the main concepts, mean values

                  +

                  Stochastic variables and the main concepts, mean values

                  @@ -685,7 +697,7 @@ PDF and is therefore simply called the expectation value of \( p(x) \).











                  -

                  Stochastic variables and the main concepts, central moments, the variance

                  +

                  Stochastic variables and the main concepts, central moments, the variance

                  @@ -722,7 +734,7 @@ qualitatively as the "spread" of \( p \) around its mean.











                  -

                  Probability Distribution Functions

                  +

                  Probability Distribution Functions

                  @@ -754,7 +766,7 @@ while \( P(x) \) is the cumulative probability.











                  -

                  Probability Distribution Functions

                  +

                  Probability Distribution Functions

                  @@ -782,7 +794,7 @@ and the variance \( \sigma^2 \).











                  -

                  The three famous Probability Distribution Functions

                  +

                  The three famous Probability Distribution Functions

                  @@ -826,7 +838,7 @@ $$











                  -

                  Probability Distribution Functions, the normal distribution

                  +

                  Probability Distribution Functions, the normal distribution

                  @@ -859,7 +871,7 @@ $$











                  -

                  Probability Distribution Functions, the normal distribution

                  +

                  Probability Distribution Functions, the normal distribution

                  @@ -895,7 +907,7 @@ $$











                  -

                  Probability Distribution Functions, the cumulative distribution

                  +

                  Probability Distribution Functions, the cumulative distribution

                  @@ -918,7 +930,7 @@ which is difficult to evaluate in a quick way.











                  -

                  Probability Distribution Functions, other important distribution

                  +

                  Probability Distribution Functions, other important distribution

                  @@ -948,7 +960,7 @@ The sequence of binomial trials is characterized by the following definitions











                  -

                  Probability Distribution Functions, the binomial distribution

                  +

                  Probability Distribution Functions, the binomial distribution

                  @@ -1001,7 +1013,7 @@ The variance is slightly trickier to get. It reads \( \sigma^2=ny(1-y) \).











                  -

                  Probability Distribution Functions, Poisson's distribution

                  +

                  Probability Distribution Functions, Poisson's distribution

                  @@ -1031,7 +1043,7 @@ and the variance is \( \sigma^2=\lambda \).











                  -

                  Probability Distribution Functions, Poisson's distribution

                  +

                  Probability Distribution Functions, Poisson's distribution

                  @@ -1052,7 +1064,7 @@ $$











                  -

                  Meet the covariance!

                  +

                  Meet the covariance!

                  @@ -1086,7 +1098,7 @@ $$











                  -

                  Meet the covariance in matrix disguise

                  +

                  Meet the covariance in matrix disguise

                  @@ -1105,7 +1117,7 @@ uncorrelated.











                  -

                  Covariance

                  +

                  Covariance

                  @@ -1128,16 +1140,16 @@ n = 10 x=np.random.normal(size=n) y = 4+3*x+np.random.normal(size=n) covxy = covariance(x,y,n) -print(covxy) +print(covxy) z = np.vstack((x, y)) c = np.cov(z.T) -print(c) +print(c)











                  -

                  Meet the covariance, uncorrelated events

                  +

                  Meet the covariance, uncorrelated events

                  @@ -1171,7 +1183,7 @@ $$











                  -

                  Numerical experiments and the covariance

                  +

                  Numerical experiments and the covariance

                  @@ -1197,7 +1209,7 @@ $$











                  -

                  Numerical experiments and the covariance

                  +

                  Numerical experiments and the covariance

                  @@ -1219,7 +1231,7 @@ interested in finding the few lowest moments, like the mean











                  -

                  Numerical experiments and the covariance, actual situations

                  +

                  Numerical experiments and the covariance, actual situations

                  @@ -1245,7 +1257,7 @@ with its square root being the standard deviation of the sample.











                  -

                  Numerical experiments and the covariance, our observables

                  +

                  Numerical experiments and the covariance, our observables

                  @@ -1280,7 +1292,7 @@ $$











                  -

                  Numerical experiments and the covariance, the sample variance

                  +

                  Numerical experiments and the covariance, the sample variance

                  @@ -1306,7 +1318,7 @@ and the covariance \( \mathrm{Cov}(X,Y) \).











                  -

                  Numerical experiments and the covariance, central limit theorem

                  +

                  Numerical experiments and the covariance, central limit theorem

                  @@ -1336,7 +1348,7 @@ In many cases the above estimate for the standard deviation, in particular if co











                  -

                  Definition of Correlation Functions and Standard Deviation

                  +

                  Definition of Correlation Functions and Standard Deviation

                  @@ -1371,7 +1383,7 @@ and the last term is nothing but the covariance which arises when \( k\ne l \).











                  -

                  Definition of Correlation Functions and Standard Deviation

                  +

                  Definition of Correlation Functions and Standard Deviation

                  @@ -1395,7 +1407,7 @@ have to be stored throughout the experiment.











                  -

                  Definition of Correlation Functions and Standard Deviation

                  +

                  Definition of Correlation Functions and Standard Deviation

                  @@ -1425,7 +1437,7 @@ $$











                  -

                  Definition of Correlation Functions and Standard Deviation

                  +

                  Definition of Correlation Functions and Standard Deviation

                  @@ -1449,7 +1461,7 @@ starting always at \( 1 \) for \( d=0 \).











                  -

                  Definition of Correlation Functions and Standard Deviation, sample variance

                  +

                  Definition of Correlation Functions and Standard Deviation, sample variance

                  @@ -1488,7 +1500,7 @@ equals 1.











                  -

                  Definition of Correlation Functions and Standard Deviation

                  +

                  Definition of Correlation Functions and Standard Deviation

                  @@ -1516,7 +1528,7 @@ more practically oriented methods like the blocking technique.

                  -

                  Code to compute the Covariance matrix and the Covariance

                  +

                  Code to compute the Covariance matrix and the Covariance

                  @@ -1537,31 +1549,31 @@ more practically oriented methods like the blocking technique. n = 100 x = np.random.normal(size=n) -print(np.mean(x)) +print(np.mean(x)) y = 4+3*x+np.random.normal(size=n) -print(np.mean(y)) +print(np.mean(y)) z = x**3+np.random.normal(size=n) -print(np.mean(z)) +print(np.mean(z)) covxx = covariance(x,x,n) covyy = covariance(y,y,n) covzz = covariance(z,z,n) covxy = covariance(x,y,n) covxz = covariance(x,z,n) covyz = covariance(y,z,n) -print(covxx,covyy, covzz) -print(covxy,covxz, covyz) +print(covxx,covyy, covzz) +print(covxy,covxz, covyz) w = np.vstack((x, y, z)) #print(w) c = np.cov(w) -print(c) +print(c) #eigen = np.zeros(n) Eigvals, Eigvecs = np.linalg.eig(c) -print(Eigvals) +print(Eigvals)











                  -

                  Random Numbers

                  +

                  Random Numbers

                  @@ -1583,7 +1595,7 @@ or Monte Carlo computer work.











                  -

                  Random Numbers, better name: pseudo random numbers

                  +

                  Random Numbers, better name: pseudo random numbers

                  @@ -1608,7 +1620,7 @@ numbers, hopefully abiding to the following criteria:











                  -

                  Random number generator RNG

                  +

                  Random number generator RNG

                  @@ -1642,7 +1654,7 @@ of the division \( 13/9 \), namely \( 4 \).











                  -

                  Random number generator RNG and periodic outputs

                  +

                  Random number generator RNG and periodic outputs

                  @@ -1681,7 +1693,7 @@ just \( 2 \).











                  -

                  Random number generator RNG and its period

                  +

                  Random number generator RNG and its period

                  @@ -1704,7 +1716,7 @@ $$











                  -

                  Random number generator RNG, other examples

                  +

                  Random number generator RNG, other examples

                  @@ -1737,7 +1749,7 @@ which according to the authors has a period larger than \( 2^{94} \).











                  -

                  Random number generator RNG, other examples

                  +

                  Random number generator RNG, other examples

                  @@ -1767,7 +1779,7 @@ it is given by \( m\wedge n \).











                  -

                  Random number generator RNG, RAN0

                  +

                  Random number generator RNG, RAN0

                  @@ -1813,7 +1825,7 @@ where the brackets denote integer division. In the code below the numbers











                  -

                  Random number generator RNG, RAN0

                  +

                  Random number generator RNG, RAN0

                  @@ -1836,7 +1848,7 @@ The last term \( [N_{i-1}/q]M\mathrm{MOD}(M) \) is zero since the integer divisi











                  -

                  Random number generator RNG, RAN0

                  +

                  Random number generator RNG, RAN0

                  @@ -1872,7 +1884,7 @@ $$











                  -

                  Random number generator RNG, RAN0

                  +

                  Random number generator RNG, RAN0

                  @@ -1894,7 +1906,7 @@ set to \( 0 \).











                  -

                  Random number generator RNG, RAN0 code

                  +

                  Random number generator RNG, RAN0 code

                  @@ -1936,7 +1948,7 @@ set to \( 0 \).











                  -

                  Properties of Selected Random Number Generators

                  +

                  Properties of Selected Random Number Generators

                  @@ -1963,7 +1975,7 @@ Two additional measures are the standard deviation \( \sigma \) and the mean











                  -

                  Properties of Selected Random Number Generators

                  +

                  Properties of Selected Random Number Generators

                  @@ -1988,7 +2000,7 @@ $$











                  -

                  Properties of Selected Random Number Generators

                  +

                  Properties of Selected Random Number Generators

                  @@ -2022,7 +2034,7 @@ these limiting values.











                  -

                  Simple demonstration of RNGs using python

                  +

                  Simple demonstration of RNGs using python

                  @@ -2062,7 +2074,7 @@ plt.show()











                  -

                  Properties of Selected Random Number Generators

                  +

                  Properties of Selected Random Number Generators

                  @@ -2099,7 +2111,7 @@ assumption for approximating \( \sigma_N \) is no longer valid.











                  -

                  Autocorrelation function

                  +

                  Autocorrelation function

                  This program computes the autocorrelation function as discussed in the equation on the previous slide for random numbers generated with the normal distribution \( N(0,1) \).

                  @@ -2122,7 +2134,7 @@ autocor = np.= np.zeros(n) mean_x=np.mean(x) var_x = np.var(x) -print(mean_x, var_x) +print(mean_x, var_x) for i in range (0, n): figaxis[i] = i autocor[i]=(autocovariance(x, n, i, mean_x))/var_x @@ -2141,7 +2153,7 @@ For the remaining values we notice that there are still non-zero values for the











                  -

                  Correlation function and which random number generators should I use

                  +

                  Correlation function and which random number generators should I use

                  @@ -2223,7 +2235,7 @@ ofstream ofile;











                  -

                  Which RNG should I use?

                  +

                  Which RNG should I use?

                  @@ -2238,7 +2250,7 @@ ofstream ofile;











                  -

                  How to use the Mersenne generator

                  +

                  How to use the Mersenne generator

                  @@ -2267,7 +2279,7 @@ The following part of a c++ code (from project 4) sets up the uniform distributi











                  -

                  Why blocking?

                  +

                  Why blocking?

                  Statistical analysis.

                  @@ -2287,7 +2299,7 @@ A very good article which explains blocking is H. Flyvbjerg and H. G. Petersen,











                  -

                  Why blocking?

                  +

                  Why blocking?

                  Statistical analysis.

                  @@ -2309,7 +2321,7 @@ A very good article which explains blocking is H. Flyvbjerg and H. G. Petersen,











                  -

                  Code to demonstrate the calculation of the autocorrelation function

                  +

                  Code to demonstrate the calculation of the autocorrelation function

                  The following code computes the autocorrelation function, the covariance and the standard deviation for standard RNG. The following file gives the code. @@ -2397,7 +2409,7 @@ ofstream ofile;











                  -

                  What is blocking?

                  +

                  What is blocking?

                  Blocking.

                  @@ -2427,7 +2439,7 @@ $$











                  -

                  What is blocking?

                  +

                  What is blocking?

                  Blocking.

                  @@ -2446,7 +2458,7 @@ $$











                  -

                  What is blocking?

                  +

                  What is blocking?

                  Blocking.

                  @@ -2463,7 +2475,7 @@ $$











                  -

                  Implementation

                  +

                  Implementation

                  @@ -2484,7 +2496,7 @@ $$











                  -

                  Actual implementation with code, main function

                  +

                  Actual implementation with code, main function

                  When the file gets large, it can be useful to write your data in binary mode instead of ascii characters. The following python file reads data from file with the output from every Monte Carlo cycle.

                  @@ -2524,7 +2536,7 @@ The The Bootstrap method +

                  The Bootstrap method

                  The Bootstrap resampling method is also very popular. It is very simple: @@ -2544,7 +2556,7 @@ This method is very useful for small ensembles of data points.

                  -

                  Bootstrapping

                  +

                  Bootstrapping

                  Given a set of \( N \) data, assume that we are interested in some observable \( \theta \) which may be estimated from that set. This observable can also be for example the result of a fit based on all \( N \) raw data. Let us call the value of the observable obtained from the original @@ -2555,7 +2567,7 @@ This costs essentially nothing, since we just recycle the original data set for

                  -

                  Bootstrapping, recipe

                  +

                  Bootstrapping, recipe

                  Let us assume we have done this \( K \) times and thus have \( K \) sets of \( N \) data values each. Of course some values will enter more than once in the new sets. For each of these sets one computes the observable \( \theta \) resulting in values \( \theta_k \) with \( k = 1,...,K \). Then one determines @@ -2579,7 +2591,7 @@ the true \( \angle\theta\rangle \). As final result for the observable one quote

                  -

                  Bootstrapping, code

                  +

                  Bootstrapping, code

                  @@ -2596,7 +2608,7 @@ the true \( \angle\theta\rangle \). As final result for the observable one quote

                  -

                  Jackknife, code

                  +

                  Jackknife, code

                  @@ -2616,7 +2628,7 @@ the true \( \angle\theta\rangle \). As final result for the observable one quote

                  - © 1999-2018, Morten Hjorth-Jensen. Released under CC Attribution-NonCommercial 4.0 license + © 1999-2020, Morten Hjorth-Jensen. Released under CC Attribution-NonCommercial 4.0 license
                  diff --git a/doc/pub/Statistics/html/reveal.js/.gitignore b/doc/pub/Statistics/html/reveal.js/.gitignore index e7b4f216a..a5df3133d 100644 --- a/doc/pub/Statistics/html/reveal.js/.gitignore +++ b/doc/pub/Statistics/html/reveal.js/.gitignore @@ -1,8 +1,3 @@ -.idea/ -*.iml -*.iws -*.eml -out/ .DS_Store .svn log/*.log @@ -10,4 +5,4 @@ tmp/** node_modules/ .sass-cache css/reveal.min.css -js/reveal.min.js \ No newline at end of file +js/reveal.min.js diff --git a/doc/pub/Statistics/html/reveal.js/.travis.yml b/doc/pub/Statistics/html/reveal.js/.travis.yml index ec3b27d5d..165d9ae9f 100644 --- a/doc/pub/Statistics/html/reveal.js/.travis.yml +++ b/doc/pub/Statistics/html/reveal.js/.travis.yml @@ -1,7 +1,5 @@ language: node_js node_js: - - 4 + - 0.10 before_script: - - npm install -g grunt-cli -after_script: - - grunt retire + - npm install -g grunt-cli \ No newline at end of file diff --git a/doc/pub/Statistics/html/reveal.js/LICENSE b/doc/pub/Statistics/html/reveal.js/LICENSE index c3e6e5fd6..09623076f 100644 --- a/doc/pub/Statistics/html/reveal.js/LICENSE +++ b/doc/pub/Statistics/html/reveal.js/LICENSE @@ -1,4 +1,4 @@ -Copyright (C) 2017 Hakim El Hattab, http://hakim.se, and reveal.js contributors +Copyright (C) 2015 Hakim El Hattab, http://hakim.se Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/doc/pub/Statistics/html/reveal.js/README.md b/doc/pub/Statistics/html/reveal.js/README.md index f2ab6ca88..573b19597 100644 --- a/doc/pub/Statistics/html/reveal.js/README.md +++ b/doc/pub/Statistics/html/reveal.js/README.md @@ -1,58 +1,12 @@ -# reveal.js [![Build Status](https://travis-ci.org/hakimel/reveal.js.svg?branch=master)](https://travis-ci.org/hakimel/reveal.js) Slides +# reveal.js [![Build Status](https://travis-ci.org/hakimel/reveal.js.svg?branch=master)](https://travis-ci.org/hakimel/reveal.js) -A framework for easily creating beautiful presentations using HTML. [Check out the live demo](http://revealjs.com/). +A framework for easily creating beautiful presentations using HTML. [Check out the live demo](http://lab.hakim.se/reveal-js/). -reveal.js comes with a broad range of features including [nested slides](https://github.com/hakimel/reveal.js#markup), [Markdown contents](https://github.com/hakimel/reveal.js#markdown), [PDF export](https://github.com/hakimel/reveal.js#pdf-export), [speaker notes](https://github.com/hakimel/reveal.js#speaker-notes) and a [JavaScript API](https://github.com/hakimel/reveal.js#api). There's also a fully featured visual editor and platform for sharing reveal.js presentations at [slides.com](https://slides.com?ref=github). +reveal.js comes with a broad range of features including [nested slides](https://github.com/hakimel/reveal.js#markup), [Markdown contents](https://github.com/hakimel/reveal.js#markdown), [PDF export](https://github.com/hakimel/reveal.js#pdf-export), [speaker notes](https://github.com/hakimel/reveal.js#speaker-notes) and a [JavaScript API](https://github.com/hakimel/reveal.js#api). It's best viewed in a modern browser but [fallbacks](https://github.com/hakimel/reveal.js/wiki/Browser-Support) are available to make sure your presentation can still be viewed elsewhere. -## Table of contents -- [Online Editor](#online-editor) -- [Instructions](#instructions) - - [Markup](#markup) - - [Markdown](#markdown) - - [Element Attributes](#element-attributes) - - [Slide Attributes](#slide-attributes) -- [Configuration](#configuration) -- [Presentation Size](#presentation-size) -- [Dependencies](#dependencies) -- [Ready Event](#ready-event) -- [Auto-sliding](#auto-sliding) -- [Keyboard Bindings](#keyboard-bindings) -- [Touch Navigation](#touch-navigation) -- [Lazy Loading](#lazy-loading) -- [API](#api) - - [Slide Changed Event](#slide-changed-event) - - [Presentation State](#presentation-state) - - [Slide States](#slide-states) - - [Slide Backgrounds](#slide-backgrounds) - - [Parallax Background](#parallax-background) - - [Slide Transitions](#slide-transitions) - - [Internal links](#internal-links) - - [Fragments](#fragments) - - [Fragment events](#fragment-events) - - [Code syntax highlighting](#code-syntax-highlighting) - - [Slide number](#slide-number) - - [Overview mode](#overview-mode) - - [Fullscreen mode](#fullscreen-mode) - - [Embedded media](#embedded-media) - - [Stretching elements](#stretching-elements) - - [postMessage API](#postmessage-api) -- [PDF Export](#pdf-export) -- [Theming](#theming) -- [Speaker Notes](#speaker-notes) - - [Share and Print Speaker Notes](#share-and-print-speaker-notes) - - [Server Side Speaker Notes](#server-side-speaker-notes) -- [Multiplexing](#multiplexing) - - [Master presentation](#master-presentation) - - [Client presentation](#client-presentation) - - [Socket.io server](#socketio-server) -- [MathJax](#mathjax) -- [Installation](#installation) - - [Basic setup](#basic-setup) - - [Full setup](#full-setup) - - [Folder Structure](#folder-structure) -- [License](#license) -#### More reading +#### More reading: +- [Installation](#installation): Step-by-step instructions for getting reveal.js running on your computer. - [Changelog](https://github.com/hakimel/reveal.js/releases): Up-to-date version history. - [Examples](https://github.com/hakimel/reveal.js/wiki/Example-Presentations): Presentations created with reveal.js, add your own! - [Browser Support](https://github.com/hakimel/reveal.js/wiki/Browser-Support): Explanation of browser support and fallbacks. @@ -60,36 +14,14 @@ reveal.js comes with a broad range of features including [nested slides](https:/ ## Online Editor -Presentations are written using HTML or Markdown but there's also an online editor for those of you who prefer a graphical interface. Give it a try at [https://slides.com](https://slides.com?ref=github). +Presentations are written using HTML or Markdown but there's also an online editor for those of you who prefer a graphical interface. Give it a try at [http://slides.com](http://slides.com). ## Instructions ### Markup -Here's a barebones example of a fully working reveal.js presentation: -```html - - - - - - -
                  -
                  -
                  Slide 1
                  -
                  Slide 2
                  -
                  -
                  - - - - -``` - -The presentation markup hierarchy needs to be `.reveal > .slides > section` where the `section` represents one slide and can be repeated indefinitely. If you place multiple `section` elements inside of another `section` they will be shown as vertical slides. The first of the vertical slides is the "root" of the others (at the top), and will be included in the horizontal sequence. For example: +Markup hierarchy needs to be ``
                  `` where the ``
                  `` represents one slide and can be repeated indefinitely. If you place multiple ``
                  ``'s inside of another ``
                  `` they will be shown as vertical slides. The first of the vertical slides is the "root" of the others (at the top), and it will be included in the horizontal sequence. For example: ```html
                  @@ -105,36 +37,32 @@ The presentation markup hierarchy needs to be `.reveal > .slides > section` wher ### Markdown -It's possible to write your slides using Markdown. To enable Markdown, add the `data-markdown` attribute to your `
                  ` elements and wrap the contents in a ` +
                  ``` #### External Markdown -You can write your content as a separate file and have reveal.js load it at runtime. Note the separator arguments which determine how slides are delimited in the external file: the `data-separator` attribute defines a regular expression for horizontal slides (defaults to `^\r?\n---\r?\n$`, a newline-bounded horizontal rule) and `data-separator-vertical` defines vertical slides (disabled by default). The `data-separator-notes` attribute is a regular expression for specifying the beginning of the current slide's speaker notes (defaults to `note:`). The `data-charset` attribute is optional and specifies which charset to use when loading the external file. +You can write your content as a separate file and have reveal.js load it at runtime. Note the separator arguments which determine how slides are delimited in the external file. The ```data-charset``` attribute is optional and specifies which charset to use when loading the external file. -When used locally, this feature requires that reveal.js [runs from a local web server](#full-setup). The following example customises all available options: +When used locally, this feature requires that reveal.js [runs from a local web server](#full-setup). ```html -
                  -
                  ``` @@ -164,19 +92,6 @@ Special syntax (in html comment) is available for adding attributes to the slide
                  ``` -#### Configuring *marked* - -We use [marked](https://github.com/chjj/marked) to parse Markdown. To customise marked's rendering, you can pass in options when [configuring Reveal](#configuration): - -```javascript -Reveal.initialize({ - // Options which are passed into marked - // See https://github.com/chjj/marked#options-1 - markdown: { - smartypants: true - } -}); -``` ### Configuration @@ -185,26 +100,12 @@ At the end of your page you need to initialize reveal by running the following c ```javascript Reveal.initialize({ - // Display presentation control arrows + // Display controls in the bottom right corner controls: true, - // Help the user learn the controls by providing hints, for example by - // bouncing the down arrow when they first encounter a vertical slide - controlsTutorial: true, - - // Determines where controls appear, "edges" or "bottom-right" - controlsLayout: 'bottom-right', - - // Visibility rule for backwards navigation arrows; "faded", "hidden" - // or "visible" - controlsBackArrows: 'faded', - // Display a presentation progress bar progress: true, - // Set default timing of 2 minutes per slide - defaultTiming: 120, - // Display the page number of the current slide slideNumber: false, @@ -229,9 +130,6 @@ Reveal.initialize({ // Change the presentation direction to be RTL rtl: false, - // Randomizes the order of slides each time the presentation loads - shuffle: false, - // Turns fragments on and off globally fragments: true, @@ -243,15 +141,6 @@ Reveal.initialize({ // key is pressed help: true, - // Flags if speaker notes should be visible to all viewers - showNotes: false, - - // Global override for autoplaying embedded media (video/audio/iframe) - // - null: Media will only autoplay if data-autoplay is present - // - true: All media will autoplay, regardless of individual setting - // - false: No media will autoplay, regardless of individual setting - autoPlayMedia: null, - // Number of milliseconds between automatically proceeding to the // next slide, disabled when set to 0, this value can be overwritten // by using a data-autoslide attribute on your slides @@ -260,9 +149,6 @@ Reveal.initialize({ // Stop auto-sliding after user input autoSlideStoppable: true, - // Use this method for navigation when auto-sliding - autoSlideMethod: Reveal.navigateNext, - // Enable slide navigation via mouse wheel mouseWheel: false, @@ -270,18 +156,16 @@ Reveal.initialize({ hideAddressBar: true, // Opens links in an iframe preview overlay - // Add `data-preview-link` and `data-preview-link="false"` to customise each link - // individually previewLinks: false, // Transition style - transition: 'slide', // none/fade/slide/convex/concave/zoom + transition: 'default', // none/fade/slide/convex/concave/zoom // Transition speed transitionSpeed: 'default', // default/fast/slow // Transition style for full page slide backgrounds - backgroundTransition: 'fade', // none/fade/slide/convex/concave/zoom + backgroundTransition: 'default', // none/fade/slide/convex/concave/zoom // Number of slides away from the current that are visible viewDistance: 3, @@ -292,14 +176,10 @@ Reveal.initialize({ // Parallax background size parallaxBackgroundSize: '', // CSS syntax, e.g. "2100px 900px" - // Number of pixels to move the parallax background per slide - // - Calculated automatically unless specified - // - Set to 0 to disable movement along an axis - parallaxBackgroundHorizontal: null, - parallaxBackgroundVertical: null, - - // The display mode that will be used to show slides - display: 'block' + // Amount to move parallax background (horizontal and vertical) on slide change + // Number, e.g. 100 + parallaxBackgroundHorizontal: '', + parallaxBackgroundVertical: '' }); ``` @@ -316,6 +196,56 @@ Reveal.configure({ autoSlide: 5000 }); ``` +### Dependencies + +Reveal.js doesn't _rely_ on any third party scripts to work but a few optional libraries are included by default. These libraries are loaded as dependencies in the order they appear, for example: + +```javascript +Reveal.initialize({ + dependencies: [ + // Cross-browser shim that fully implements classList - https://github.com/eligrey/classList.js/ + { src: 'lib/js/classList.js', condition: function() { return !document.body.classList; } }, + + // Interpret Markdown in
                  elements + { src: 'plugin/markdown/marked.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } }, + { src: 'plugin/markdown/markdown.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } }, + + // Syntax highlight for elements + { src: 'plugin/highlight/highlight.js', async: true, callback: function() { hljs.initHighlightingOnLoad(); } }, + + // Zoom in and out with Alt+click + { src: 'plugin/zoom-js/zoom.js', async: true }, + + // Speaker notes + { src: 'plugin/notes/notes.js', async: true }, + + // Remote control your reveal.js presentation using a touch device + { src: 'plugin/remotes/remotes.js', async: true }, + + // MathJax + { src: 'plugin/math/math.js', async: true } + ] +}); +``` + +You can add your own extensions using the same syntax. The following properties are available for each dependency object: +- **src**: Path to the script to load +- **async**: [optional] Flags if the script should load after reveal.js has started, defaults to false +- **callback**: [optional] Function to execute when the script has loaded +- **condition**: [optional] Function which must return true for the script to be loaded + + +### Ready Event + +A 'ready' event is fired when reveal.js has loaded all non-async dependencies and is ready to start navigating. To check if reveal.js is already 'ready' you can call `Reveal.isReady()`. + +```javascript +Reveal.addEventListener( 'ready', function( event ) { + // event.currentSlide, event.indexh, event.indexv +} ); +``` + + ### Presentation Size All presentations have a normal size, that is the resolution at which they are authored. The framework will automatically scale presentations uniformly based on this size to ensure that everything fits on any given display or viewport. @@ -343,69 +273,6 @@ Reveal.initialize({ }); ``` -If you wish to disable this behavior and do your own scaling (e.g. using media queries), try these settings: - -```javascript -Reveal.initialize({ - - ... - - width: "100%", - height: "100%", - margin: 0, - minScale: 1, - maxScale: 1 -}); -``` - -### Dependencies - -Reveal.js doesn't _rely_ on any third party scripts to work but a few optional libraries are included by default. These libraries are loaded as dependencies in the order they appear, for example: - -```javascript -Reveal.initialize({ - dependencies: [ - // Cross-browser shim that fully implements classList - https://github.com/eligrey/classList.js/ - { src: 'lib/js/classList.js', condition: function() { return !document.body.classList; } }, - - // Interpret Markdown in
                  elements - { src: 'plugin/markdown/marked.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } }, - { src: 'plugin/markdown/markdown.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } }, - - // Syntax highlight for elements - { src: 'plugin/highlight/highlight.js', async: true, callback: function() { hljs.initHighlightingOnLoad(); } }, - - // Zoom in and out with Alt+click - { src: 'plugin/zoom-js/zoom.js', async: true }, - - // Speaker notes - { src: 'plugin/notes/notes.js', async: true }, - - // MathJax - { src: 'plugin/math/math.js', async: true } - ] -}); -``` - -You can add your own extensions using the same syntax. The following properties are available for each dependency object: -- **src**: Path to the script to load -- **async**: [optional] Flags if the script should load after reveal.js has started, defaults to false -- **callback**: [optional] Function to execute when the script has loaded -- **condition**: [optional] Function which must return true for the script to be loaded - -To load these dependencies, reveal.js requires [head.js](http://headjs.com/) *(a script loading library)* to be loaded before reveal.js. - -### Ready Event - -A 'ready' event is fired when reveal.js has loaded all non-async dependencies and is ready to start navigating. To check if reveal.js is already 'ready' you can call `Reveal.isReady()`. - -```javascript -Reveal.addEventListener( 'ready', function( event ) { - // event.currentSlide, event.indexh, event.indexv -} ); -``` - -Note that we also add a `.ready` class to the `.reveal` element so that you can hook into this with CSS. ### Auto-sliding @@ -429,8 +296,6 @@ You can also override the slide duration for individual slides and fragments by
                  ``` -To override the method used for navigation when auto-sliding, you can specify the ```autoSlideMethod``` setting. To only navigate along the top layer and ignore vertical slides, set this to ```Reveal.navigateRight```. - Whenever the auto-slide mode is resumed or paused the ```autoslideresumed``` and ```autoslidepaused``` events are fired. @@ -448,13 +313,6 @@ Reveal.configure({ }); ``` -### Touch Navigation - -You can swipe to navigate through a presentation on any touch-enabled device. Horizontal swipes change between horizontal slides, vertical swipes change between vertical slides. If you wish to disable this you can set the `touch` config option to false when initializing reveal.js. - -If there's some part of your content that needs to remain accessible to touch events you'll need to highlight this by adding a `data-prevent-swipe` attribute to the element. One common example where this is useful is elements that need to be scrolled. - - ### Lazy Loading When working on presentation with a lot of media or iframe content it's important to load lazily. Lazy loading means that reveal.js will only load content for the few slides nearest to the current slide. The number of slides that are preloaded is determined by the `viewDistance` configuration option. @@ -489,18 +347,11 @@ Reveal.next(); Reveal.prevFragment(); Reveal.nextFragment(); -// Randomize the order of slides -Reveal.shuffle(); - // Toggle presentation states, optionally pass true/false to force on/off Reveal.toggleOverview(); Reveal.togglePause(); Reveal.toggleAutoSlide(); -// Shows a help overlay with keyboard shortcuts, optionally pass true/false -// to force on/off -Reveal.toggleHelp(); - // Change a config value at runtime Reveal.configure({ controls: true }); @@ -514,14 +365,9 @@ Reveal.getScale(); Reveal.getPreviousSlide(); Reveal.getCurrentSlide(); -Reveal.getIndices(); // { h: 0, v: 0 } } -Reveal.getPastSlideCount(); -Reveal.getProgress(); // (0 == first slide, 1 == last slide) -Reveal.getSlides(); // Array of all slides -Reveal.getTotalSlides(); // total number of slides - -// Returns the speaker notes for the current slide -Reveal.getSlideNotes(); +Reveal.getIndices(); // { h: 0, v: 0 } } +Reveal.getProgress(); // 0-1 +Reveal.getTotalSlides(); // State checks Reveal.isFirstSlide(); @@ -574,59 +420,26 @@ Reveal.addEventListener( 'somestate', function() { ### Slide Backgrounds -Slides are contained within a limited portion of the screen by default to allow them to fit any display and scale uniformly. You can apply full page backgrounds outside of the slide area by adding a ```data-background``` attribute to your ```
                  ``` elements. Four different types of backgrounds are supported: color, image, video and iframe. +Slides are contained within a limited portion of the screen by default to allow them to fit any display and scale uniformly. You can apply full page backgrounds outside of the slide area by adding a ```data-background``` attribute to your ```
                  ``` elements. Four different types of backgrounds are supported: color, image, video and iframe. Below are a few examples. -#### Color Backgrounds -All CSS color formats are supported, like rgba() or hsl(). ```html -
                  -

                  Color

                  +
                  +

                  All CSS color formats are supported, like rgba() or hsl().

                  +
                  +
                  +

                  This slide will have a full-size background image.

                  +
                  +
                  +

                  This background image will be sized to 100px and repeated.

                  +
                  +
                  +

                  Video. Multiple sources can be defined using a comma separated list. Video will loop when the data-background-video-loop attribute is provided.

                  +
                  +
                  +

                  Embeds a web page as a background. Note that the page won't be interactive.

                  ``` -#### Image Backgrounds -By default, background images are resized to cover the full page. Available options: - -| Attribute | Default | Description | -| :--------------------------- | :--------- | :---------- | -| data-background-image | | URL of the image to show. GIFs restart when the slide opens. | -| data-background-size | cover | See [background-size](https://developer.mozilla.org/docs/Web/CSS/background-size) on MDN. | -| data-background-position | center | See [background-position](https://developer.mozilla.org/docs/Web/CSS/background-position) on MDN. | -| data-background-repeat | no-repeat | See [background-repeat](https://developer.mozilla.org/docs/Web/CSS/background-repeat) on MDN. | -```html -
                  -

                  Image

                  -
                  -
                  -

                  This background image will be sized to 100px and repeated

                  -
                  -``` - -#### Video Backgrounds -Automatically plays a full size video behind the slide. - -| Attribute | Default | Description | -| :--------------------------- | :------ | :---------- | -| data-background-video | | A single video source, or a comma separated list of video sources. | -| data-background-video-loop | false | Flags if the video should play repeatedly. | -| data-background-video-muted | false | Flags if the audio should be muted. | -| data-background-size | cover | Use `cover` for full screen and some cropping or `contain` for letterboxing. | - -```html -
                  -

                  Video

                  -
                  -``` - -#### Iframe Backgrounds -Embeds a web page as a slide background that covers 100% of the reveal.js width and height. The iframe is in the background layer, behind your slides, and as such it's not possible to interact with it by default. To make your background interactive, you can add the `data-background-interactive` attribute. -```html -
                  -

                  Iframe

                  -
                  -``` - -#### Background Transitions Backgrounds transition using a fade animation by default. This can be changed to a linear sliding transition by passing ```backgroundTransition: 'slide'``` to the ```Reveal.initialize()``` call. Alternatively you can set ```data-background-transition``` on any section with a background to override that specific transition. @@ -643,16 +456,16 @@ Reveal.initialize({ // Parallax background size parallaxBackgroundSize: '', // CSS syntax, e.g. "2100px 900px" - currently only pixels are supported (don't use % or auto) - // Number of pixels to move the parallax background per slide - // - Calculated automatically unless specified - // - Set to 0 to disable movement along an axis + // Amount of pixels to move the parallax background per slide step, + // a value of 0 disables movement along the given axis + // These are optional, if they aren't specified they'll be calculated automatically parallaxBackgroundHorizontal: 200, parallaxBackgroundVertical: 50 }); ``` -Make sure that the background size is much bigger than screen size to allow for some scrolling. [View example](http://revealjs.com/?parallaxBackgroundImage=https%3A%2F%2Fs3.amazonaws.com%2Fhakim-static%2Freveal-js%2Freveal-parallax-1.jpg¶llaxBackgroundSize=2100px%20900px). +Make sure that the background size is much bigger than screen size to allow for some scrolling. [View example](http://lab.hakim.se/reveal-js/?parallaxBackgroundImage=https%3A%2F%2Fs3.amazonaws.com%2Fhakim-static%2Freveal-js%2Freveal-parallax-1.jpg¶llaxBackgroundSize=2100px%20900px). @@ -673,15 +486,15 @@ You can also use different in and out transitions for the same slide: ```html
                  - The train goes on … + The train goes on …
                  -
                  - and on … +
                  + and on …
                  -
                  +
                  and stops.
                  -
                  +
                  (Passengers entering and leaving)
                  @@ -690,6 +503,9 @@ You can also use different in and out transitions for the same slide: ``` +Note that this does not work with the page and cube transitions. + + ### Internal links It's easy to link between slides. The first example below targets the index of another slide whereas the second targets a slide with an ID attribute (```
                  ```): @@ -712,7 +528,7 @@ You can also add relative navigation links, similar to the built in reveal.js co ### Fragments -Fragments are used to highlight individual elements on a slide. Every element with the class ```fragment``` will be stepped through before moving on to the next slide. Here's an example: http://revealjs.com/#/fragments +Fragments are used to highlight individual elements on a slide. Every element with the class ```fragment``` will be stepped through before moving on to the next slide. Here's an example: http://lab.hakim.se/reveal-js/#/fragments The default fragment style is to start out invisible and fade in. This style can be changed by appending a different class to the fragment: @@ -721,7 +537,6 @@ The default fragment style is to start out invisible and fade in. This style can

                  grow

                  shrink

                  fade-out

                  -

                  fade-up (also down, left and right!)

                  visible only once

                  blue only once

                  highlight-red

                  @@ -767,41 +582,33 @@ Reveal.addEventListener( 'fragmenthidden', function( event ) { ### Code syntax highlighting -By default, Reveal is configured with [highlight.js](https://highlightjs.org/) for code syntax highlighting. To enable syntax highlighting, you'll have to load the highlight plugin ([plugin/highlight/highlight.js](plugin/highlight/highlight.js)) and a highlight.js CSS theme (Reveal comes packaged with the zenburn theme: [lib/css/zenburn.css](lib/css/zenburn.css)). - -Below is an example with clojure code that will be syntax highlighted. When the `data-trim` attribute is present, surrounding whitespace is automatically removed. HTML will be escaped by default. To avoid this, for example if you are using `` to call out a line of code, add the `data-noescape` attribute to the `` element. +By default, Reveal is configured with [highlight.js](http://softwaremaniacs.org/soft/highlight/en/) for code syntax highlighting. Below is an example with clojure code that will be syntax highlighted. When the `data-trim` attribute is present surrounding whitespace is automatically removed. ```html
                  -
                  
                  +	
                  
                   (def lazy-fib
                     (concat
                      [0 1]
                  -   ((fn rfib [a b]
                  +   ((fn rfib [a b]
                           (lazy-cons (+ a b) (rfib b (+ a b)))) 0 1)))
                   	
                  ``` ### Slide number -If you would like to display the page number of the current slide you can do so using the ```slideNumber``` and ```showSlideNumber``` configuration values. +If you would like to display the page number of the current slide you can do so using the ```slideNumber``` configuration value. ```javascript // Shows the slide number using default formatting Reveal.configure({ slideNumber: true }); // Slide number formatting can be configured using these variables: -// "h.v": horizontal . vertical slide number (default) -// "h/v": horizontal / vertical slide number -// "c": flattened slide number -// "c/t": flattened slide number / total slides -Reveal.configure({ slideNumber: 'c/t' }); - -// Control which views the slide number displays on using the "showSlideNumber" value: -// "all": show on all views (default) -// "speaker": only show slide numbers on speaker notes view -// "print": only show slide numbers when printing to PDF -Reveal.configure({ showSlideNumber: 'speaker' }); +// h: current slide's horizontal index +// v: current slide's vertical index +// c: current slide index (flattened) +// t: total number of slides (flattened) +Reveal.configure({ slideNumber: 'c / t' }); ``` @@ -819,26 +626,20 @@ Reveal.addEventListener( 'overviewhidden', function( event ) { /* ... */ } ); Reveal.toggleOverview(); ``` - ### Fullscreen mode Just press »F« on your keyboard to show your presentation in fullscreen mode. Press the »ESC« key to exit fullscreen mode. ### Embedded media +Embedded HTML5 `
                  diff --git a/doc/pub/Statistics/html/reveal.js/plugin/markdown/example.md b/doc/pub/Statistics/html/reveal.js/plugin/markdown/example.md index 89c75345e..6f6f577a1 100644 --- a/doc/pub/Statistics/html/reveal.js/plugin/markdown/example.md +++ b/doc/pub/Statistics/html/reveal.js/plugin/markdown/example.md @@ -29,8 +29,3 @@ Content 3.1 ## External 3.2 Content 3.2 - - -## External 3.3 - -![External Image](https://s3.amazonaws.com/static.slid.es/logo/v2/slides-symbol-512x512.png) diff --git a/doc/pub/Statistics/html/reveal.js/plugin/markdown/markdown.js b/doc/pub/Statistics/html/reveal.js/plugin/markdown/markdown.js index aa08ee5ed..15e3b40b3 100644 --- a/doc/pub/Statistics/html/reveal.js/plugin/markdown/markdown.js +++ b/doc/pub/Statistics/html/reveal.js/plugin/markdown/markdown.js @@ -4,26 +4,33 @@ * of external markdown documents. */ (function( root, factory ) { - if (typeof define === 'function' && define.amd) { - root.marked = require( './marked' ); - root.RevealMarkdown = factory( root.marked ); - root.RevealMarkdown.initialize(); - } else if( typeof exports === 'object' ) { + if( typeof exports === 'object' ) { module.exports = factory( require( './marked' ) ); - } else { + } + else { // Browser globals (root is window) root.RevealMarkdown = factory( root.marked ); root.RevealMarkdown.initialize(); } }( this, function( marked ) { + if( typeof marked === 'undefined' ) { + throw 'The reveal.js Markdown plugin requires marked to be loaded'; + } + + if( typeof hljs !== 'undefined' ) { + marked.setOptions({ + highlight: function( lang, code ) { + return hljs.highlightAuto( lang, code ).value; + } + }); + } + var DEFAULT_SLIDE_SEPARATOR = '^\r?\n---\r?\n$', - DEFAULT_NOTES_SEPARATOR = 'notes?:', + DEFAULT_NOTES_SEPARATOR = 'note:', DEFAULT_ELEMENT_ATTRIBUTES_SEPARATOR = '\\\.element\\\s*?(.+?)$', DEFAULT_SLIDE_ATTRIBUTES_SEPARATOR = '\\\.slide:\\\s*?(\\\S.+?)$'; - var SCRIPT_END_PLACEHOLDER = '__SCRIPT_END__'; - /** * Retrieves the markdown contents of a slide section @@ -31,15 +38,11 @@ */ function getMarkdownFromSlide( section ) { - // look for a ' ); - var leadingWs = text.match( /^\n?(\s*)/ )[1].length, leadingTabs = text.match( /^\n?(\t*)/ )[1].length; @@ -109,13 +112,9 @@ var notesMatch = content.split( new RegExp( options.notesSeparator, 'mgi' ) ); if( notesMatch.length === 2 ) { - content = notesMatch[0] + ''; + content = notesMatch[0] + ''; } - // prevent script end tags in the content from interfering - // with parsing - content = content.replace( /<\/script>/g, SCRIPT_END_PLACEHOLDER ); - return ''; } @@ -178,7 +177,7 @@ markdownSections += '
                  '; sectionStack[i].forEach( function( child ) { - markdownSections += '
                  ' + createMarkdownSlide( child, options ) + '
                  '; + markdownSections += '
                  ' + createMarkdownSlide( child, options ) + '
                  '; } ); markdownSections += '
                  '; @@ -380,24 +379,6 @@ return { initialize: function() { - if( typeof marked === 'undefined' ) { - throw 'The reveal.js Markdown plugin requires marked to be loaded'; - } - - if( typeof hljs !== 'undefined' ) { - marked.setOptions({ - highlight: function( code, lang ) { - return hljs.highlightAuto( code, [lang] ).value; - } - }); - } - - var options = Reveal.getConfig().markdown; - - if ( options ) { - marked.setOptions( options ); - } - processSlides(); convertSlides(); }, diff --git a/doc/pub/Statistics/html/reveal.js/plugin/markdown/marked.js b/doc/pub/Statistics/html/reveal.js/plugin/markdown/marked.js index 555c1dc1d..70af29bf9 100644 --- a/doc/pub/Statistics/html/reveal.js/plugin/markdown/marked.js +++ b/doc/pub/Statistics/html/reveal.js/plugin/markdown/marked.js @@ -3,4 +3,4 @@ * Copyright (c) 2011-2014, Christopher Jeffrey. (MIT Licensed) * https://github.com/chjj/marked */ -(function(){var block={newline:/^\n+/,code:/^( {4}[^\n]+\n*)+/,fences:noop,hr:/^( *[-*_]){3,} *(?:\n+|$)/,heading:/^ *(#{1,6}) *([^\n]+?) *#* *(?:\n+|$)/,nptable:noop,lheading:/^([^\n]+)\n *(=|-){2,} *(?:\n+|$)/,blockquote:/^( *>[^\n]+(\n(?!def)[^\n]+)*\n*)+/,list:/^( *)(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?!\1bull )\n*|\s*$)/,html:/^ *(?:comment *(?:\n|\s*$)|closed *(?:\n{2,}|\s*$)|closing *(?:\n{2,}|\s*$))/,def:/^ *\[([^\]]+)\]: *]+)>?(?: +["(]([^\n]+)[")])? *(?:\n+|$)/,table:noop,paragraph:/^((?:[^\n]+\n?(?!hr|heading|lheading|blockquote|tag|def))+)\n*/,text:/^[^\n]+/};block.bullet=/(?:[*+-]|\d+\.)/;block.item=/^( *)(bull) [^\n]*(?:\n(?!\1bull )[^\n]*)*/;block.item=replace(block.item,"gm")(/bull/g,block.bullet)();block.list=replace(block.list)(/bull/g,block.bullet)("hr","\\n+(?=\\1?(?:[-*_] *){3,}(?:\\n+|$))")("def","\\n+(?="+block.def.source+")")();block.blockquote=replace(block.blockquote)("def",block.def)();block._tag="(?!(?:"+"a|em|strong|small|s|cite|q|dfn|abbr|data|time|code"+"|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo"+"|span|br|wbr|ins|del|img)\\b)\\w+(?!:/|[^\\w\\s@]*@)\\b";block.html=replace(block.html)("comment",//)("closed",/<(tag)[\s\S]+?<\/\1>/)("closing",/])*?>/)(/tag/g,block._tag)();block.paragraph=replace(block.paragraph)("hr",block.hr)("heading",block.heading)("lheading",block.lheading)("blockquote",block.blockquote)("tag","<"+block._tag)("def",block.def)();block.normal=merge({},block);block.gfm=merge({},block.normal,{fences:/^ *(`{3,}|~{3,})[ \.]*(\S+)? *\n([\s\S]*?)\s*\1 *(?:\n+|$)/,paragraph:/^/,heading:/^ *(#{1,6}) +([^\n]+?) *#* *(?:\n+|$)/});block.gfm.paragraph=replace(block.paragraph)("(?!","(?!"+block.gfm.fences.source.replace("\\1","\\2")+"|"+block.list.source.replace("\\1","\\3")+"|")();block.tables=merge({},block.gfm,{nptable:/^ *(\S.*\|.*)\n *([-:]+ *\|[-| :]*)\n((?:.*\|.*(?:\n|$))*)\n*/,table:/^ *\|(.+)\n *\|( *[-:]+[-| :]*)\n((?: *\|.*(?:\n|$))*)\n*/});function Lexer(options){this.tokens=[];this.tokens.links={};this.options=options||marked.defaults;this.rules=block.normal;if(this.options.gfm){if(this.options.tables){this.rules=block.tables}else{this.rules=block.gfm}}}Lexer.rules=block;Lexer.lex=function(src,options){var lexer=new Lexer(options);return lexer.lex(src)};Lexer.prototype.lex=function(src){src=src.replace(/\r\n|\r/g,"\n").replace(/\t/g," ").replace(/\u00a0/g," ").replace(/\u2424/g,"\n");return this.token(src,true)};Lexer.prototype.token=function(src,top,bq){var src=src.replace(/^ +$/gm,""),next,loose,cap,bull,b,item,space,i,l;while(src){if(cap=this.rules.newline.exec(src)){src=src.substring(cap[0].length);if(cap[0].length>1){this.tokens.push({type:"space"})}}if(cap=this.rules.code.exec(src)){src=src.substring(cap[0].length);cap=cap[0].replace(/^ {4}/gm,"");this.tokens.push({type:"code",text:!this.options.pedantic?cap.replace(/\n+$/,""):cap});continue}if(cap=this.rules.fences.exec(src)){src=src.substring(cap[0].length);this.tokens.push({type:"code",lang:cap[2],text:cap[3]||""});continue}if(cap=this.rules.heading.exec(src)){src=src.substring(cap[0].length);this.tokens.push({type:"heading",depth:cap[1].length,text:cap[2]});continue}if(top&&(cap=this.rules.nptable.exec(src))){src=src.substring(cap[0].length);item={type:"table",header:cap[1].replace(/^ *| *\| *$/g,"").split(/ *\| */),align:cap[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:cap[3].replace(/\n$/,"").split("\n")};for(i=0;i ?/gm,"");this.token(cap,top,true);this.tokens.push({type:"blockquote_end"});continue}if(cap=this.rules.list.exec(src)){src=src.substring(cap[0].length);bull=cap[2];this.tokens.push({type:"list_start",ordered:bull.length>1});cap=cap[0].match(this.rules.item);next=false;l=cap.length;i=0;for(;i1&&b.length>1)){src=cap.slice(i+1).join("\n")+src;i=l-1}}loose=next||/\n\n(?!\s*$)/.test(item);if(i!==l-1){next=item.charAt(item.length-1)==="\n";if(!loose)loose=next}this.tokens.push({type:loose?"loose_item_start":"list_item_start"});this.token(item,false,bq);this.tokens.push({type:"list_item_end"})}this.tokens.push({type:"list_end"});continue}if(cap=this.rules.html.exec(src)){src=src.substring(cap[0].length);this.tokens.push({type:this.options.sanitize?"paragraph":"html",pre:!this.options.sanitizer&&(cap[1]==="pre"||cap[1]==="script"||cap[1]==="style"),text:cap[0]});continue}if(!bq&&top&&(cap=this.rules.def.exec(src))){src=src.substring(cap[0].length);this.tokens.links[cap[1].toLowerCase()]={href:cap[2],title:cap[3]};continue}if(top&&(cap=this.rules.table.exec(src))){src=src.substring(cap[0].length);item={type:"table",header:cap[1].replace(/^ *| *\| *$/g,"").split(/ *\| */),align:cap[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:cap[3].replace(/(?: *\| *)?\n$/,"").split("\n")};for(i=0;i])/,autolink:/^<([^ >]+(@|:\/)[^ >]+)>/,url:noop,tag:/^|^<\/?\w+(?:"[^"]*"|'[^']*'|[^'">])*?>/,link:/^!?\[(inside)\]\(href\)/,reflink:/^!?\[(inside)\]\s*\[([^\]]*)\]/,nolink:/^!?\[((?:\[[^\]]*\]|[^\[\]])*)\]/,strong:/^__([\s\S]+?)__(?!_)|^\*\*([\s\S]+?)\*\*(?!\*)/,em:/^\b_((?:[^_]|__)+?)_\b|^\*((?:\*\*|[\s\S])+?)\*(?!\*)/,code:/^(`+)\s*([\s\S]*?[^`])\s*\1(?!`)/,br:/^ {2,}\n(?!\s*$)/,del:noop,text:/^[\s\S]+?(?=[\\?(?:\s+['"]([\s\S]*?)['"])?\s*/;inline.link=replace(inline.link)("inside",inline._inside)("href",inline._href)();inline.reflink=replace(inline.reflink)("inside",inline._inside)();inline.normal=merge({},inline);inline.pedantic=merge({},inline.normal,{strong:/^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,em:/^_(?=\S)([\s\S]*?\S)_(?!_)|^\*(?=\S)([\s\S]*?\S)\*(?!\*)/});inline.gfm=merge({},inline.normal,{escape:replace(inline.escape)("])","~|])")(),url:/^(https?:\/\/[^\s<]+[^<.,:;"')\]\s])/,del:/^~~(?=\S)([\s\S]*?\S)~~/,text:replace(inline.text)("]|","~]|")("|","|https?://|")()});inline.breaks=merge({},inline.gfm,{br:replace(inline.br)("{2,}","*")(),text:replace(inline.gfm.text)("{2,}","*")()});function InlineLexer(links,options){this.options=options||marked.defaults;this.links=links;this.rules=inline.normal;this.renderer=this.options.renderer||new Renderer;this.renderer.options=this.options;if(!this.links){throw new Error("Tokens array requires a `links` property.")}if(this.options.gfm){if(this.options.breaks){this.rules=inline.breaks}else{this.rules=inline.gfm}}else if(this.options.pedantic){this.rules=inline.pedantic}}InlineLexer.rules=inline;InlineLexer.output=function(src,links,options){var inline=new InlineLexer(links,options);return inline.output(src)};InlineLexer.prototype.output=function(src){var out="",link,text,href,cap;while(src){if(cap=this.rules.escape.exec(src)){src=src.substring(cap[0].length);out+=cap[1];continue}if(cap=this.rules.autolink.exec(src)){src=src.substring(cap[0].length);if(cap[2]==="@"){text=cap[1].charAt(6)===":"?this.mangle(cap[1].substring(7)):this.mangle(cap[1]);href=this.mangle("mailto:")+text}else{text=escape(cap[1]);href=text}out+=this.renderer.link(href,null,text);continue}if(!this.inLink&&(cap=this.rules.url.exec(src))){src=src.substring(cap[0].length);text=escape(cap[1]);href=text;out+=this.renderer.link(href,null,text);continue}if(cap=this.rules.tag.exec(src)){if(!this.inLink&&/^/i.test(cap[0])){this.inLink=false}src=src.substring(cap[0].length);out+=this.options.sanitize?this.options.sanitizer?this.options.sanitizer(cap[0]):escape(cap[0]):cap[0];continue}if(cap=this.rules.link.exec(src)){src=src.substring(cap[0].length);this.inLink=true;out+=this.outputLink(cap,{href:cap[2],title:cap[3]});this.inLink=false;continue}if((cap=this.rules.reflink.exec(src))||(cap=this.rules.nolink.exec(src))){src=src.substring(cap[0].length);link=(cap[2]||cap[1]).replace(/\s+/g," ");link=this.links[link.toLowerCase()];if(!link||!link.href){out+=cap[0].charAt(0);src=cap[0].substring(1)+src;continue}this.inLink=true;out+=this.outputLink(cap,link);this.inLink=false;continue}if(cap=this.rules.strong.exec(src)){src=src.substring(cap[0].length);out+=this.renderer.strong(this.output(cap[2]||cap[1]));continue}if(cap=this.rules.em.exec(src)){src=src.substring(cap[0].length);out+=this.renderer.em(this.output(cap[2]||cap[1]));continue}if(cap=this.rules.code.exec(src)){src=src.substring(cap[0].length);out+=this.renderer.codespan(escape(cap[2],true));continue}if(cap=this.rules.br.exec(src)){src=src.substring(cap[0].length);out+=this.renderer.br();continue}if(cap=this.rules.del.exec(src)){src=src.substring(cap[0].length);out+=this.renderer.del(this.output(cap[1]));continue}if(cap=this.rules.text.exec(src)){src=src.substring(cap[0].length);out+=this.renderer.text(escape(this.smartypants(cap[0])));continue}if(src){throw new Error("Infinite loop on byte: "+src.charCodeAt(0))}}return out};InlineLexer.prototype.outputLink=function(cap,link){var href=escape(link.href),title=link.title?escape(link.title):null;return cap[0].charAt(0)!=="!"?this.renderer.link(href,title,this.output(cap[1])):this.renderer.image(href,title,escape(cap[1]))};InlineLexer.prototype.smartypants=function(text){if(!this.options.smartypants)return text;return text.replace(/---/g,"—").replace(/--/g,"–").replace(/(^|[-\u2014/(\[{"\s])'/g,"$1‘").replace(/'/g,"’").replace(/(^|[-\u2014/(\[{\u2018\s])"/g,"$1“").replace(/"/g,"”").replace(/\.{3}/g,"…")};InlineLexer.prototype.mangle=function(text){if(!this.options.mangle)return text;var out="",l=text.length,i=0,ch;for(;i.5){ch="x"+ch.toString(16)}out+="&#"+ch+";"}return out};function Renderer(options){this.options=options||{}}Renderer.prototype.code=function(code,lang,escaped){if(this.options.highlight){var out=this.options.highlight(code,lang);if(out!=null&&out!==code){escaped=true;code=out}}if(!lang){return"
                  "+(escaped?code:escape(code,true))+"\n
                  "}return'
                  '+(escaped?code:escape(code,true))+"\n
                  \n"};Renderer.prototype.blockquote=function(quote){return"
                  \n"+quote+"
                  \n"};Renderer.prototype.html=function(html){return html};Renderer.prototype.heading=function(text,level,raw){return"'+text+"\n"};Renderer.prototype.hr=function(){return this.options.xhtml?"
                  \n":"
                  \n"};Renderer.prototype.list=function(body,ordered){var type=ordered?"ol":"ul";return"<"+type+">\n"+body+"\n"};Renderer.prototype.listitem=function(text){return"
                • "+text+"
                • \n"};Renderer.prototype.paragraph=function(text){return"

                  "+text+"

                  \n"};Renderer.prototype.table=function(header,body){return"\n"+"\n"+header+"\n"+"\n"+body+"\n"+"
                  \n"};Renderer.prototype.tablerow=function(content){return"\n"+content+"\n"};Renderer.prototype.tablecell=function(content,flags){var type=flags.header?"th":"td";var tag=flags.align?"<"+type+' style="text-align:'+flags.align+'">':"<"+type+">";return tag+content+"\n"};Renderer.prototype.strong=function(text){return""+text+""};Renderer.prototype.em=function(text){return""+text+""};Renderer.prototype.codespan=function(text){return""+text+""};Renderer.prototype.br=function(){return this.options.xhtml?"
                  ":"
                  "};Renderer.prototype.del=function(text){return""+text+""};Renderer.prototype.link=function(href,title,text){if(this.options.sanitize){try{var prot=decodeURIComponent(unescape(href)).replace(/[^\w:]/g,"").toLowerCase()}catch(e){return""}if(prot.indexOf("javascript:")===0||prot.indexOf("vbscript:")===0){return""}}var out='
                  ";return out};Renderer.prototype.image=function(href,title,text){var out=''+text+'":">";return out};Renderer.prototype.text=function(text){return text};function Parser(options){this.tokens=[];this.token=null;this.options=options||marked.defaults;this.options.renderer=this.options.renderer||new Renderer;this.renderer=this.options.renderer;this.renderer.options=this.options}Parser.parse=function(src,options,renderer){var parser=new Parser(options,renderer);return parser.parse(src)};Parser.prototype.parse=function(src){this.inline=new InlineLexer(src.links,this.options,this.renderer);this.tokens=src.reverse();var out="";while(this.next()){out+=this.tok()}return out};Parser.prototype.next=function(){return this.token=this.tokens.pop()};Parser.prototype.peek=function(){return this.tokens[this.tokens.length-1]||0};Parser.prototype.parseText=function(){var body=this.token.text;while(this.peek().type==="text"){body+="\n"+this.next().text}return this.inline.output(body)};Parser.prototype.tok=function(){switch(this.token.type){case"space":{return""}case"hr":{return this.renderer.hr()}case"heading":{return this.renderer.heading(this.inline.output(this.token.text),this.token.depth,this.token.text)}case"code":{return this.renderer.code(this.token.text,this.token.lang,this.token.escaped)}case"table":{var header="",body="",i,row,cell,flags,j;cell="";for(i=0;i/g,">").replace(/"/g,""").replace(/'/g,"'")}function unescape(html){return html.replace(/&([#\w]+);/g,function(_,n){n=n.toLowerCase();if(n==="colon")return":";if(n.charAt(0)==="#"){return n.charAt(1)==="x"?String.fromCharCode(parseInt(n.substring(2),16)):String.fromCharCode(+n.substring(1))}return""})}function replace(regex,opt){regex=regex.source;opt=opt||"";return function self(name,val){if(!name)return new RegExp(regex,opt);val=val.source||val;val=val.replace(/(^|[^\[])\^/g,"$1");regex=regex.replace(name,val);return self}}function noop(){}noop.exec=noop;function merge(obj){var i=1,target,key;for(;iAn error occured:

                  "+escape(e.message+"",true)+"
                  "}throw e}}marked.options=marked.setOptions=function(opt){merge(marked.defaults,opt);return marked};marked.defaults={gfm:true,tables:true,breaks:false,pedantic:false,sanitize:false,sanitizer:null,mangle:true,smartLists:false,silent:false,highlight:null,langPrefix:"lang-",smartypants:false,headerPrefix:"",renderer:new Renderer,xhtml:false};marked.Parser=Parser;marked.parser=Parser.parse;marked.Renderer=Renderer;marked.Lexer=Lexer;marked.lexer=Lexer.lex;marked.InlineLexer=InlineLexer;marked.inlineLexer=InlineLexer.output;marked.parse=marked;if(typeof module!=="undefined"&&typeof exports==="object"){module.exports=marked}else if(typeof define==="function"&&define.amd){define(function(){return marked})}else{this.marked=marked}}).call(function(){return this||(typeof window!=="undefined"?window:global)}()); \ No newline at end of file +(function(){function e(e){this.tokens=[],this.tokens.links={},this.options=e||a.defaults,this.rules=p.normal,this.options.gfm&&(this.rules=this.options.tables?p.tables:p.gfm)}function t(e,t){if(this.options=t||a.defaults,this.links=e,this.rules=u.normal,this.renderer=this.options.renderer||new n,this.renderer.options=this.options,!this.links)throw new Error("Tokens array requires a `links` property.");this.options.gfm?this.rules=this.options.breaks?u.breaks:u.gfm:this.options.pedantic&&(this.rules=u.pedantic)}function n(e){this.options=e||{}}function r(e){this.tokens=[],this.token=null,this.options=e||a.defaults,this.options.renderer=this.options.renderer||new n,this.renderer=this.options.renderer,this.renderer.options=this.options}function s(e,t){return e.replace(t?/&/g:/&(?!#?\w+;)/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'")}function i(e){return e.replace(/&([#\w]+);/g,function(e,t){return t=t.toLowerCase(),"colon"===t?":":"#"===t.charAt(0)?String.fromCharCode("x"===t.charAt(1)?parseInt(t.substring(2),16):+t.substring(1)):""})}function l(e,t){return e=e.source,t=t||"",function n(r,s){return r?(s=s.source||s,s=s.replace(/(^|[^\[])\^/g,"$1"),e=e.replace(r,s),n):new RegExp(e,t)}}function o(){}function h(e){for(var t,n,r=1;rAn error occured:

                  "+s(c.message+"",!0)+"
                  ";throw c}}var p={newline:/^\n+/,code:/^( {4}[^\n]+\n*)+/,fences:o,hr:/^( *[-*_]){3,} *(?:\n+|$)/,heading:/^ *(#{1,6}) *([^\n]+?) *#* *(?:\n+|$)/,nptable:o,lheading:/^([^\n]+)\n *(=|-){2,} *(?:\n+|$)/,blockquote:/^( *>[^\n]+(\n(?!def)[^\n]+)*\n*)+/,list:/^( *)(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?!\1bull )\n*|\s*$)/,html:/^ *(?:comment *(?:\n|\s*$)|closed *(?:\n{2,}|\s*$)|closing *(?:\n{2,}|\s*$))/,def:/^ *\[([^\]]+)\]: *]+)>?(?: +["(]([^\n]+)[")])? *(?:\n+|$)/,table:o,paragraph:/^((?:[^\n]+\n?(?!hr|heading|lheading|blockquote|tag|def))+)\n*/,text:/^[^\n]+/};p.bullet=/(?:[*+-]|\d+\.)/,p.item=/^( *)(bull) [^\n]*(?:\n(?!\1bull )[^\n]*)*/,p.item=l(p.item,"gm")(/bull/g,p.bullet)(),p.list=l(p.list)(/bull/g,p.bullet)("hr","\\n+(?=\\1?(?:[-*_] *){3,}(?:\\n+|$))")("def","\\n+(?="+p.def.source+")")(),p.blockquote=l(p.blockquote)("def",p.def)(),p._tag="(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:/|[^\\w\\s@]*@)\\b",p.html=l(p.html)("comment",//)("closed",/<(tag)[\s\S]+?<\/\1>/)("closing",/])*?>/)(/tag/g,p._tag)(),p.paragraph=l(p.paragraph)("hr",p.hr)("heading",p.heading)("lheading",p.lheading)("blockquote",p.blockquote)("tag","<"+p._tag)("def",p.def)(),p.normal=h({},p),p.gfm=h({},p.normal,{fences:/^ *(`{3,}|~{3,}) *(\S+)? *\n([\s\S]+?)\s*\1 *(?:\n+|$)/,paragraph:/^/}),p.gfm.paragraph=l(p.paragraph)("(?!","(?!"+p.gfm.fences.source.replace("\\1","\\2")+"|"+p.list.source.replace("\\1","\\3")+"|")(),p.tables=h({},p.gfm,{nptable:/^ *(\S.*\|.*)\n *([-:]+ *\|[-| :]*)\n((?:.*\|.*(?:\n|$))*)\n*/,table:/^ *\|(.+)\n *\|( *[-:]+[-| :]*)\n((?: *\|.*(?:\n|$))*)\n*/}),e.rules=p,e.lex=function(t,n){var r=new e(n);return r.lex(t)},e.prototype.lex=function(e){return e=e.replace(/\r\n|\r/g,"\n").replace(/\t/g," ").replace(/\u00a0/g," ").replace(/\u2424/g,"\n"),this.token(e,!0)},e.prototype.token=function(e,t,n){for(var r,s,i,l,o,h,a,u,c,e=e.replace(/^ +$/gm,"");e;)if((i=this.rules.newline.exec(e))&&(e=e.substring(i[0].length),i[0].length>1&&this.tokens.push({type:"space"})),i=this.rules.code.exec(e))e=e.substring(i[0].length),i=i[0].replace(/^ {4}/gm,""),this.tokens.push({type:"code",text:this.options.pedantic?i:i.replace(/\n+$/,"")});else if(i=this.rules.fences.exec(e))e=e.substring(i[0].length),this.tokens.push({type:"code",lang:i[2],text:i[3]});else if(i=this.rules.heading.exec(e))e=e.substring(i[0].length),this.tokens.push({type:"heading",depth:i[1].length,text:i[2]});else if(t&&(i=this.rules.nptable.exec(e))){for(e=e.substring(i[0].length),h={type:"table",header:i[1].replace(/^ *| *\| *$/g,"").split(/ *\| */),align:i[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:i[3].replace(/\n$/,"").split("\n")},u=0;u ?/gm,""),this.token(i,t,!0),this.tokens.push({type:"blockquote_end"});else if(i=this.rules.list.exec(e)){for(e=e.substring(i[0].length),l=i[2],this.tokens.push({type:"list_start",ordered:l.length>1}),i=i[0].match(this.rules.item),r=!1,c=i.length,u=0;c>u;u++)h=i[u],a=h.length,h=h.replace(/^ *([*+-]|\d+\.) +/,""),~h.indexOf("\n ")&&(a-=h.length,h=this.options.pedantic?h.replace(/^ {1,4}/gm,""):h.replace(new RegExp("^ {1,"+a+"}","gm"),"")),this.options.smartLists&&u!==c-1&&(o=p.bullet.exec(i[u+1])[0],l===o||l.length>1&&o.length>1||(e=i.slice(u+1).join("\n")+e,u=c-1)),s=r||/\n\n(?!\s*$)/.test(h),u!==c-1&&(r="\n"===h.charAt(h.length-1),s||(s=r)),this.tokens.push({type:s?"loose_item_start":"list_item_start"}),this.token(h,!1,n),this.tokens.push({type:"list_item_end"});this.tokens.push({type:"list_end"})}else if(i=this.rules.html.exec(e))e=e.substring(i[0].length),this.tokens.push({type:this.options.sanitize?"paragraph":"html",pre:"pre"===i[1]||"script"===i[1]||"style"===i[1],text:i[0]});else if(!n&&t&&(i=this.rules.def.exec(e)))e=e.substring(i[0].length),this.tokens.links[i[1].toLowerCase()]={href:i[2],title:i[3]};else if(t&&(i=this.rules.table.exec(e))){for(e=e.substring(i[0].length),h={type:"table",header:i[1].replace(/^ *| *\| *$/g,"").split(/ *\| */),align:i[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:i[3].replace(/(?: *\| *)?\n$/,"").split("\n")},u=0;u])/,autolink:/^<([^ >]+(@|:\/)[^ >]+)>/,url:o,tag:/^|^<\/?\w+(?:"[^"]*"|'[^']*'|[^'">])*?>/,link:/^!?\[(inside)\]\(href\)/,reflink:/^!?\[(inside)\]\s*\[([^\]]*)\]/,nolink:/^!?\[((?:\[[^\]]*\]|[^\[\]])*)\]/,strong:/^__([\s\S]+?)__(?!_)|^\*\*([\s\S]+?)\*\*(?!\*)/,em:/^\b_((?:__|[\s\S])+?)_\b|^\*((?:\*\*|[\s\S])+?)\*(?!\*)/,code:/^(`+)\s*([\s\S]*?[^`])\s*\1(?!`)/,br:/^ {2,}\n(?!\s*$)/,del:o,text:/^[\s\S]+?(?=[\\?(?:\s+['"]([\s\S]*?)['"])?\s*/,u.link=l(u.link)("inside",u._inside)("href",u._href)(),u.reflink=l(u.reflink)("inside",u._inside)(),u.normal=h({},u),u.pedantic=h({},u.normal,{strong:/^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,em:/^_(?=\S)([\s\S]*?\S)_(?!_)|^\*(?=\S)([\s\S]*?\S)\*(?!\*)/}),u.gfm=h({},u.normal,{escape:l(u.escape)("])","~|])")(),url:/^(https?:\/\/[^\s<]+[^<.,:;"')\]\s])/,del:/^~~(?=\S)([\s\S]*?\S)~~/,text:l(u.text)("]|","~]|")("|","|https?://|")()}),u.breaks=h({},u.gfm,{br:l(u.br)("{2,}","*")(),text:l(u.gfm.text)("{2,}","*")()}),t.rules=u,t.output=function(e,n,r){var s=new t(n,r);return s.output(e)},t.prototype.output=function(e){for(var t,n,r,i,l="";e;)if(i=this.rules.escape.exec(e))e=e.substring(i[0].length),l+=i[1];else if(i=this.rules.autolink.exec(e))e=e.substring(i[0].length),"@"===i[2]?(n=this.mangle(":"===i[1].charAt(6)?i[1].substring(7):i[1]),r=this.mangle("mailto:")+n):(n=s(i[1]),r=n),l+=this.renderer.link(r,null,n);else if(this.inLink||!(i=this.rules.url.exec(e))){if(i=this.rules.tag.exec(e))!this.inLink&&/^
                  /i.test(i[0])&&(this.inLink=!1),e=e.substring(i[0].length),l+=this.options.sanitize?s(i[0]):i[0];else if(i=this.rules.link.exec(e))e=e.substring(i[0].length),this.inLink=!0,l+=this.outputLink(i,{href:i[2],title:i[3]}),this.inLink=!1;else if((i=this.rules.reflink.exec(e))||(i=this.rules.nolink.exec(e))){if(e=e.substring(i[0].length),t=(i[2]||i[1]).replace(/\s+/g," "),t=this.links[t.toLowerCase()],!t||!t.href){l+=i[0].charAt(0),e=i[0].substring(1)+e;continue}this.inLink=!0,l+=this.outputLink(i,t),this.inLink=!1}else if(i=this.rules.strong.exec(e))e=e.substring(i[0].length),l+=this.renderer.strong(this.output(i[2]||i[1]));else if(i=this.rules.em.exec(e))e=e.substring(i[0].length),l+=this.renderer.em(this.output(i[2]||i[1]));else if(i=this.rules.code.exec(e))e=e.substring(i[0].length),l+=this.renderer.codespan(s(i[2],!0));else if(i=this.rules.br.exec(e))e=e.substring(i[0].length),l+=this.renderer.br();else if(i=this.rules.del.exec(e))e=e.substring(i[0].length),l+=this.renderer.del(this.output(i[1]));else if(i=this.rules.text.exec(e))e=e.substring(i[0].length),l+=s(this.smartypants(i[0]));else if(e)throw new Error("Infinite loop on byte: "+e.charCodeAt(0))}else e=e.substring(i[0].length),n=s(i[1]),r=n,l+=this.renderer.link(r,null,n);return l},t.prototype.outputLink=function(e,t){var n=s(t.href),r=t.title?s(t.title):null;return"!"!==e[0].charAt(0)?this.renderer.link(n,r,this.output(e[1])):this.renderer.image(n,r,s(e[1]))},t.prototype.smartypants=function(e){return this.options.smartypants?e.replace(/--/g,"—").replace(/(^|[-\u2014/(\[{"\s])'/g,"$1‘").replace(/'/g,"’").replace(/(^|[-\u2014/(\[{\u2018\s])"/g,"$1“").replace(/"/g,"”").replace(/\.{3}/g,"…"):e},t.prototype.mangle=function(e){for(var t,n="",r=e.length,s=0;r>s;s++)t=e.charCodeAt(s),Math.random()>.5&&(t="x"+t.toString(16)),n+="&#"+t+";";return n},n.prototype.code=function(e,t,n){if(this.options.highlight){var r=this.options.highlight(e,t);null!=r&&r!==e&&(n=!0,e=r)}return t?'
                  '+(n?e:s(e,!0))+"\n
                  \n":"
                  "+(n?e:s(e,!0))+"\n
                  "},n.prototype.blockquote=function(e){return"
                  \n"+e+"
                  \n"},n.prototype.html=function(e){return e},n.prototype.heading=function(e,t,n){return"'+e+"\n"},n.prototype.hr=function(){return this.options.xhtml?"
                  \n":"
                  \n"},n.prototype.list=function(e,t){var n=t?"ol":"ul";return"<"+n+">\n"+e+"\n"},n.prototype.listitem=function(e){return"
                • "+e+"
                • \n"},n.prototype.paragraph=function(e){return"

                  "+e+"

                  \n"},n.prototype.table=function(e,t){return"\n\n"+e+"\n\n"+t+"\n
                  \n"},n.prototype.tablerow=function(e){return"\n"+e+"\n"},n.prototype.tablecell=function(e,t){var n=t.header?"th":"td",r=t.align?"<"+n+' style="text-align:'+t.align+'">':"<"+n+">";return r+e+"\n"},n.prototype.strong=function(e){return""+e+""},n.prototype.em=function(e){return""+e+""},n.prototype.codespan=function(e){return""+e+""},n.prototype.br=function(){return this.options.xhtml?"
                  ":"
                  "},n.prototype.del=function(e){return""+e+""},n.prototype.link=function(e,t,n){if(this.options.sanitize){try{var r=decodeURIComponent(i(e)).replace(/[^\w:]/g,"").toLowerCase()}catch(s){return""}if(0===r.indexOf("javascript:")||0===r.indexOf("vbscript:"))return""}var l='
                  "},n.prototype.image=function(e,t,n){var r=''+n+'":">"},r.parse=function(e,t,n){var s=new r(t,n);return s.parse(e)},r.prototype.parse=function(e){this.inline=new t(e.links,this.options,this.renderer),this.tokens=e.reverse();for(var n="";this.next();)n+=this.tok();return n},r.prototype.next=function(){return this.token=this.tokens.pop()},r.prototype.peek=function(){return this.tokens[this.tokens.length-1]||0},r.prototype.parseText=function(){for(var e=this.token.text;"text"===this.peek().type;)e+="\n"+this.next().text;return this.inline.output(e)},r.prototype.tok=function(){switch(this.token.type){case"space":return"";case"hr":return this.renderer.hr();case"heading":return this.renderer.heading(this.inline.output(this.token.text),this.token.depth,this.token.text);case"code":return this.renderer.code(this.token.text,this.token.lang,this.token.escaped);case"table":var e,t,n,r,s,i="",l="";for(n="",e=0;ebody{font-family: sans-serif;}

                  reveal.js multiplex server.

                  Generate token'); - res.end(); - }); - stream.on('readable', function() { - stream.pipe(res); - }); + fs.createReadStream(opts.baseDir + '/index.html').pipe(res); }); app.get("/token", function(req,res) { @@ -55,7 +47,7 @@ var createHash = function(secret) { }; // Actually listen -server.listen( opts.port || null ); +app.listen(opts.port || null); var brown = '\033[33m', green = '\033[32m', diff --git a/doc/pub/Statistics/html/reveal.js/plugin/multiplex/master.js b/doc/pub/Statistics/html/reveal.js/plugin/multiplex/master.js index 7f4bf4511..b6a7eb7dc 100644 --- a/doc/pub/Statistics/html/reveal.js/plugin/multiplex/master.js +++ b/doc/pub/Statistics/html/reveal.js/plugin/multiplex/master.js @@ -1,34 +1,51 @@ (function() { - // Don't emit events from inside of notes windows if ( window.location.search.match( /receiver/gi ) ) { return; } var multiplex = Reveal.getConfig().multiplex; - var socket = io.connect( multiplex.url ); + var socket = io.connect(multiplex.url); - function post() { + var notify = function( slideElement, indexh, indexv, origin ) { + if( typeof origin === 'undefined' && origin !== 'remote' ) { + var nextindexh; + var nextindexv; - var messageData = { - state: Reveal.getState(), - secret: multiplex.secret, - socketId: multiplex.id - }; + var fragmentindex = Reveal.getIndices().f; + if (typeof fragmentindex == 'undefined') { + fragmentindex = 0; + } - socket.emit( 'multiplex-statechanged', messageData ); + if (slideElement.nextElementSibling && slideElement.parentNode.nodeName == 'SECTION') { + nextindexh = indexh; + nextindexv = indexv + 1; + } else { + nextindexh = indexh + 1; + nextindexv = 0; + } + var slideData = { + indexh : indexh, + indexv : indexv, + indexf : fragmentindex, + nextindexh : nextindexh, + nextindexv : nextindexv, + secret: multiplex.secret, + socketId : multiplex.id + }; + + socket.emit('slidechanged', slideData); + } + } + + Reveal.addEventListener( 'slidechanged', function( event ) { + notify( event.currentSlide, event.indexh, event.indexv, event.origin ); + } ); + + var fragmentNotify = function( event ) { + notify( Reveal.getCurrentSlide(), Reveal.getIndices().h, Reveal.getIndices().v, event.origin ); }; - // post once the page is loaded, so the client follows also on "open URL". - window.addEventListener( 'load', post ); - - // Monitor events that trigger a change in state - Reveal.addEventListener( 'slidechanged', post ); - Reveal.addEventListener( 'fragmentshown', post ); - Reveal.addEventListener( 'fragmenthidden', post ); - Reveal.addEventListener( 'overviewhidden', post ); - Reveal.addEventListener( 'overviewshown', post ); - Reveal.addEventListener( 'paused', post ); - Reveal.addEventListener( 'resumed', post ); - -}()); + Reveal.addEventListener( 'fragmentshown', fragmentNotify ); + Reveal.addEventListener( 'fragmenthidden', fragmentNotify ); +}()); \ No newline at end of file diff --git a/doc/pub/Statistics/html/reveal.js/plugin/notes-server/client.js b/doc/pub/Statistics/html/reveal.js/plugin/notes-server/client.js index 00b277baf..628586ffb 100644 --- a/doc/pub/Statistics/html/reveal.js/plugin/notes-server/client.js +++ b/doc/pub/Statistics/html/reveal.js/plugin/notes-server/client.js @@ -41,15 +41,10 @@ } // When a new notes window connects, post our current state - socket.on( 'new-subscriber', function( data ) { + socket.on( 'connect', function( data ) { post(); } ); - // When the state changes from inside of the speaker view - socket.on( 'statechanged-speaker', function( data ) { - Reveal.setState( data.state ); - } ); - // Monitor events that trigger a change in state Reveal.addEventListener( 'slidechanged', post ); Reveal.addEventListener( 'fragmentshown', post ); diff --git a/doc/pub/Statistics/html/reveal.js/plugin/notes-server/index.js b/doc/pub/Statistics/html/reveal.js/plugin/notes-server/index.js index b95f07188..df917f112 100644 --- a/doc/pub/Statistics/html/reveal.js/plugin/notes-server/index.js +++ b/doc/pub/Statistics/html/reveal.js/plugin/notes-server/index.js @@ -1,40 +1,37 @@ -var http = require('http'); var express = require('express'); var fs = require('fs'); var io = require('socket.io'); +var _ = require('underscore'); var Mustache = require('mustache'); -var app = express(); +var app = express.createServer(); var staticDir = express.static; -var server = http.createServer(app); -io = io(server); +io = io.listen(app); var opts = { port : 1947, baseDir : __dirname + '/../../' }; -io.on( 'connection', function( socket ) { +io.sockets.on( 'connection', function( socket ) { - socket.on( 'new-subscriber', function( data ) { - socket.broadcast.emit( 'new-subscriber', data ); + socket.on( 'connect', function( data ) { + socket.broadcast.emit( 'connect', data ); }); socket.on( 'statechanged', function( data ) { - delete data.state.overview; socket.broadcast.emit( 'statechanged', data ); }); - socket.on( 'statechanged-speaker', function( data ) { - delete data.state.overview; - socket.broadcast.emit( 'statechanged-speaker', data ); - }); - }); -[ 'css', 'js', 'images', 'plugin', 'lib' ].forEach( function( dir ) { - app.use( '/' + dir, staticDir( opts.baseDir + dir ) ); +app.configure( function() { + + [ 'css', 'js', 'images', 'plugin', 'lib' ].forEach( function( dir ) { + app.use( '/' + dir, staticDir( opts.baseDir + dir ) ); + }); + }); app.get('/', function( req, res ) { @@ -55,7 +52,7 @@ app.get( '/notes/:socketId', function( req, res ) { }); // Actually listen -server.listen( opts.port || null ); +app.listen( opts.port || null ); var brown = '\033[33m', green = '\033[32m', @@ -65,5 +62,5 @@ var slidesLocation = 'http://localhost' + ( opts.port ? ( ':' + opts.port ) : '' console.log( brown + 'reveal.js - Speaker Notes' + reset ); console.log( '1. Open the slides at ' + green + slidesLocation + reset ); -console.log( '2. Click on the link in your JS console to go to the notes page' ); +console.log( '2. Click on the link your JS console to go to the notes page' ); console.log( '3. Advance through your slides and your notes will advance automatically' ); diff --git a/doc/pub/Statistics/html/reveal.js/plugin/notes-server/notes.html b/doc/pub/Statistics/html/reveal.js/plugin/notes-server/notes.html index ab8c5b17a..72d0317f1 100644 --- a/doc/pub/Statistics/html/reveal.js/plugin/notes-server/notes.html +++ b/doc/pub/Statistics/html/reveal.js/plugin/notes-server/notes.html @@ -8,7 +8,6 @@ @@ -247,7 +152,7 @@
                  -
                  Upcoming
                  +
                  UPCOMING:

                  Time Click to Reset

                  @@ -265,10 +170,6 @@
                  -
                  - - -
                  @@ -281,20 +182,11 @@ currentState, currentSlide, upcomingSlide, - layoutLabel, - layoutDropdown, connected = false; var socket = io.connect( window.location.origin ), socketId = '{{socketId}}'; - var SPEAKER_LAYOUTS = { - 'default': 'Default', - 'wide': 'Wide', - 'tall': 'Tall', - 'notes-only': 'Notes only' - }; - socket.on( 'statechanged', function( data ) { // ignore data from sockets that aren't ours @@ -303,6 +195,7 @@ if( connected === false ) { connected = true; + setupIframes( data ); setupKeyboard(); setupNotes(); setupTimer(); @@ -313,28 +206,13 @@ } ); - setupLayout(); - - // Load our presentation iframes - setupIframes(); - - // Once the iframes have loaded, emit a signal saying there's - // a new subscriber which will trigger a 'statechanged' - // message to be sent back window.addEventListener( 'message', function( event ) { var data = JSON.parse( event.data ); if( data && data.namespace === 'reveal' ) { if( /ready/.test( data.eventName ) ) { - socket.emit( 'new-subscriber', { socketId: socketId } ); - } - } - - // Messages sent by reveal.js inside of the current slide preview - if( data && data.namespace === 'reveal' ) { - if( /slidechanged|fragmentshown|fragmenthidden|overviewshown|overviewhidden|paused|resumed/.test( data.eventName ) && currentState !== JSON.stringify( data.state ) ) { - socket.emit( 'statechanged-speaker', { state: data.state } ); + socket.emit( 'connect', { socketId: socketId } ); } } @@ -389,7 +267,7 @@ /** * Creates the preview iframes. */ - function setupIframes() { + function setupIframes( data ) { var params = [ 'receiver', @@ -399,8 +277,9 @@ 'backgroundTransition=none' ].join( '&' ); - var currentURL = '/?' + params + '&postMessageEvents=true'; - var upcomingURL = '/?' + params + '&controls=false'; + var hash = '#/' + data.state.indexh + '/' + data.state.indexv; + var currentURL = '/?' + params + '&postMessageEvents=true' + hash; + var upcomingURL = '/?' + params + '&controls=false' + hash; currentSlide = document.createElement( 'iframe' ); currentSlide.setAttribute( 'width', 1280 ); @@ -472,74 +351,6 @@ } - /** - * Sets up the speaker view layout and layout selector. - */ - function setupLayout() { - - layoutDropdown = document.querySelector( '.speaker-layout-dropdown' ); - layoutLabel = document.querySelector( '.speaker-layout-label' ); - - // Render the list of available layouts - for( var id in SPEAKER_LAYOUTS ) { - var option = document.createElement( 'option' ); - option.setAttribute( 'value', id ); - option.textContent = SPEAKER_LAYOUTS[ id ]; - layoutDropdown.appendChild( option ); - } - - // Monitor the dropdown for changes - layoutDropdown.addEventListener( 'change', function( event ) { - - setLayout( layoutDropdown.value ); - - }, false ); - - // Restore any currently persisted layout - setLayout( getLayout() ); - - } - - /** - * Sets a new speaker view layout. The layout is persisted - * in local storage. - */ - function setLayout( value ) { - - var title = SPEAKER_LAYOUTS[ value ]; - - layoutLabel.innerHTML = 'Layout' + ( title ? ( ': ' + title ) : '' ); - layoutDropdown.value = value; - - document.body.setAttribute( 'data-speaker-layout', value ); - - // Persist locally - if( window.localStorage ) { - window.localStorage.setItem( 'reveal-speaker-layout', value ); - } - - } - - /** - * Returns the ID of the most recently set speaker layout - * or our default layout if none has been set. - */ - function getLayout() { - - if( window.localStorage ) { - var layout = window.localStorage.getItem( 'reveal-speaker-layout' ); - if( layout ) { - return layout; - } - } - - // Default to the first record in the layouts hash - for( var id in SPEAKER_LAYOUTS ) { - return id; - } - - } - function zeroPadInteger( num ) { var str = '00' + parseInt( num ); diff --git a/doc/pub/Statistics/html/reveal.js/plugin/notes/notes.html b/doc/pub/Statistics/html/reveal.js/plugin/notes/notes.html index 4c5b799b5..0cc8cf612 100644 --- a/doc/pub/Statistics/html/reveal.js/plugin/notes/notes.html +++ b/doc/pub/Statistics/html/reveal.js/plugin/notes/notes.html @@ -8,7 +8,6 @@