diff --git a/doc/pub/Bayesian/html/._Bayesian-bs000.html b/doc/pub/Bayesian/html/._Bayesian-bs000.html new file mode 100644 index 000000000..d02a7a85a --- /dev/null +++ b/doc/pub/Bayesian/html/._Bayesian-bs000.html @@ -0,0 +1,138 @@ + + + + + + + +Data Analysis and Machine Learning: Elements of Bayesian theory + + + + + + + + + + + + + + + + + + + +
+ +

 

 

 

+ + + + + + +
+

Data Analysis and Machine Learning: Elements of Bayesian theory

+ +

+ + +

+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, 2017

+
+

+ + +

Read »

+ + +
+ +

+ +

+ + +
+ + + + + + + +
+ © 1999-2017, Morten Hjorth-Jensen. Released under CC Attribution-NonCommercial 4.0 license +
+ + + + + + diff --git a/doc/pub/Bayesian/html/._Bayesian-bs001.html b/doc/pub/Bayesian/html/._Bayesian-bs001.html new file mode 100644 index 000000000..e989b2996 --- /dev/null +++ b/doc/pub/Bayesian/html/._Bayesian-bs001.html @@ -0,0 +1,119 @@ + + + + + + + +Data Analysis and Machine Learning: Elements of Bayesian theory + + + + + + + + + + + + + + + + + + + +
+ +

 

 

 

+ + + + +

Introduction

+
+
+

+ +

+

+
+ + +

+ +

+ + +
+ + + + + + + +
+ +
+ + + + + + diff --git a/doc/pub/Bayesian/html/Bayesian-bs.html b/doc/pub/Bayesian/html/Bayesian-bs.html new file mode 100644 index 000000000..d02a7a85a --- /dev/null +++ b/doc/pub/Bayesian/html/Bayesian-bs.html @@ -0,0 +1,138 @@ + + + + + + + +Data Analysis and Machine Learning: Elements of Bayesian theory + + + + + + + + + + + + + + + + + + + +
+ +

 

 

 

+ + + + + + +
+

Data Analysis and Machine Learning: Elements of Bayesian theory

+ +

+ + +

+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, 2017

+
+

+ + +

Read »

+ + +
+ +

+ +

+ + +
+ + + + + + + +
+ © 1999-2017, Morten Hjorth-Jensen. Released under CC Attribution-NonCommercial 4.0 license +
+ + + + + + diff --git a/doc/pub/Bayesian/html/Bayesian-reveal.html b/doc/pub/Bayesian/html/Bayesian-reveal.html new file mode 100644 index 000000000..251aea381 --- /dev/null +++ b/doc/pub/Bayesian/html/Bayesian-reveal.html @@ -0,0 +1,296 @@ + + + + + + +Data Analysis and Machine Learning: Elements of Bayesian theory + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + +
+ + + + + + + +
+ + + + +

Data Analysis and Machine Learning: Elements of Bayesian theory

+ +

+ + +

+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, 2017

+
+

+ +

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

Introduction

+
+ +

+

+
+ + + +
+
+ + + + + + + + + + + + diff --git a/doc/pub/Bayesian/html/Bayesian-solarized.html b/doc/pub/Bayesian/html/Bayesian-solarized.html new file mode 100644 index 000000000..2ba916394 --- /dev/null +++ b/doc/pub/Bayesian/html/Bayesian-solarized.html @@ -0,0 +1,113 @@ + + + + + + + +Data Analysis and Machine Learning: Elements of Bayesian theory + + + + + + + + + + + + + + + + + + + + + +

Data Analysis and Machine Learning: Elements of Bayesian theory

+ +

+ + +

+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, 2017

+
+

+









+ +

Introduction

+
+ +

+ + +

+ + + + + +
+ © 1999-2017, Morten Hjorth-Jensen. Released under CC Attribution-NonCommercial 4.0 license +
+ + + + + + diff --git a/doc/pub/Bayesian/html/Bayesian.html b/doc/pub/Bayesian/html/Bayesian.html new file mode 100644 index 000000000..dc88defae --- /dev/null +++ b/doc/pub/Bayesian/html/Bayesian.html @@ -0,0 +1,118 @@ + + + + + + + +Data Analysis and Machine Learning: Elements of Bayesian theory + + + + + + + + + + + + + + + + +

Data Analysis and Machine Learning: Elements of Bayesian theory

+ +

+ + +

+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, 2017

+
+

+









+ +

Introduction

+
+ +

+ + +

+ + + + + +
+ © 1999-2017, Morten Hjorth-Jensen. Released under CC Attribution-NonCommercial 4.0 license +
+ + + + + + diff --git a/doc/pub/Bayesian/html/reveal.js/.gitignore b/doc/pub/Bayesian/html/reveal.js/.gitignore new file mode 100644 index 000000000..a5df3133d --- /dev/null +++ b/doc/pub/Bayesian/html/reveal.js/.gitignore @@ -0,0 +1,8 @@ +.DS_Store +.svn +log/*.log +tmp/** +node_modules/ +.sass-cache +css/reveal.min.css +js/reveal.min.js diff --git a/doc/pub/Bayesian/html/reveal.js/.travis.yml b/doc/pub/Bayesian/html/reveal.js/.travis.yml new file mode 100644 index 000000000..165d9ae9f --- /dev/null +++ b/doc/pub/Bayesian/html/reveal.js/.travis.yml @@ -0,0 +1,5 @@ +language: node_js +node_js: + - 0.10 +before_script: + - npm install -g grunt-cli \ No newline at end of file diff --git a/doc/pub/Bayesian/html/reveal.js/CONTRIBUTING.md b/doc/pub/Bayesian/html/reveal.js/CONTRIBUTING.md new file mode 100644 index 000000000..c2091e88f --- /dev/null +++ b/doc/pub/Bayesian/html/reveal.js/CONTRIBUTING.md @@ -0,0 +1,23 @@ +## Contributing + +Please keep the [issue tracker](http://github.com/hakimel/reveal.js/issues) limited to **bug reports**, **feature requests** and **pull requests**. + + +### Personal Support +If you have personal support or setup questions the best place to ask those are [StackOverflow](http://stackoverflow.com/questions/tagged/reveal.js). + + +### Bug Reports +When reporting a bug make sure to include information about which browser and operating system you are on as well as the necessary steps to reproduce the issue. If possible please include a link to a sample presentation where the bug can be tested. + + +### Pull Requests +- Should follow the coding style of the file you work in, most importantly: + - Tabs to indent + - Single-quoted strings +- Should be made towards the **dev branch** +- Should be submitted from a feature/topic branch (not your master) + + +### Plugins +Please do not submit plugins as pull requests. They should be maintained in their own separate repository. More information here: https://github.com/hakimel/reveal.js/wiki/Plugin-Guidelines diff --git a/doc/pub/Bayesian/html/reveal.js/Gruntfile.js b/doc/pub/Bayesian/html/reveal.js/Gruntfile.js new file mode 100644 index 000000000..b257e8f32 --- /dev/null +++ b/doc/pub/Bayesian/html/reveal.js/Gruntfile.js @@ -0,0 +1,140 @@ +/* global module:false */ +module.exports = function(grunt) { + var port = grunt.option('port') || 8000; + // Project configuration + grunt.initConfig({ + pkg: grunt.file.readJSON('package.json'), + meta: { + banner: + '/*!\n' + + ' * reveal.js <%= pkg.version %> (<%= grunt.template.today("yyyy-mm-dd, HH:MM") %>)\n' + + ' * http://lab.hakim.se/reveal-js\n' + + ' * MIT licensed\n' + + ' *\n' + + ' * Copyright (C) 2014 Hakim El Hattab, http://hakim.se\n' + + ' */' + }, + + qunit: { + files: [ 'test/*.html' ] + }, + + uglify: { + options: { + banner: '<%= meta.banner %>\n' + }, + build: { + src: 'js/reveal.js', + dest: 'js/reveal.min.js' + } + }, + + cssmin: { + compress: { + files: { + 'css/reveal.min.css': [ 'css/reveal.css' ] + } + } + }, + + sass: { + main: { + files: { + 'css/theme/darkgray.css': 'css/theme/source/darkgray.scss', + 'css/theme/beigesmall.css': 'css/theme/source/beigesmall.scss', + 'css/theme/cbc.css': 'css/theme/source/cbc.scss', + 'css/theme/default.css': 'css/theme/source/default.scss', + 'css/theme/beige.css': 'css/theme/source/beige.scss', + 'css/theme/night.css': 'css/theme/source/night.scss', + 'css/theme/serif.css': 'css/theme/source/serif.scss', + 'css/theme/simple.css': 'css/theme/source/simple.scss', + 'css/theme/sky.css': 'css/theme/source/sky.scss', + 'css/theme/moon.css': 'css/theme/source/moon.scss', + 'css/theme/solarized.css': 'css/theme/source/solarized.scss', + 'css/theme/blood.css': 'css/theme/source/blood.scss' + } + } + }, + + jshint: { + options: { + curly: false, + eqeqeq: true, + immed: true, + latedef: true, + newcap: true, + noarg: true, + sub: true, + undef: true, + eqnull: true, + browser: true, + expr: true, + globals: { + head: false, + module: false, + console: false, + unescape: false + } + }, + files: [ 'Gruntfile.js', 'js/reveal.js' ] + }, + + connect: { + server: { + options: { + port: port, + base: '.' + } + } + }, + + zip: { + 'reveal-js-presentation.zip': [ + 'index.html', + 'css/**', + 'js/**', + 'lib/**', + 'images/**', + 'plugin/**' + ] + }, + + watch: { + main: { + files: [ 'Gruntfile.js', 'js/reveal.js', 'css/reveal.css' ], + tasks: 'default' + }, + theme: { + files: [ 'css/theme/source/*.scss', 'css/theme/template/*.scss' ], + tasks: 'themes' + } + } + + }); + + // Dependencies + grunt.loadNpmTasks( 'grunt-contrib-qunit' ); + grunt.loadNpmTasks( 'grunt-contrib-jshint' ); + grunt.loadNpmTasks( 'grunt-contrib-cssmin' ); + grunt.loadNpmTasks( 'grunt-contrib-uglify' ); + grunt.loadNpmTasks( 'grunt-contrib-watch' ); + grunt.loadNpmTasks( 'grunt-contrib-sass' ); + grunt.loadNpmTasks( 'grunt-contrib-connect' ); + grunt.loadNpmTasks( 'grunt-zip' ); + + // Default task + grunt.registerTask( 'default', [ 'jshint', 'cssmin', 'uglify', 'qunit' ] ); + + // Theme task + grunt.registerTask( 'themes', [ 'sass' ] ); + + // Package presentation to archive + grunt.registerTask( 'package', [ 'default', 'zip' ] ); + + // Serve presentation locally + grunt.registerTask( 'serve', [ 'connect', 'watch' ] ); + + // Run tests + grunt.registerTask( 'test', [ 'jshint', 'qunit' ] ); + +}; diff --git a/doc/pub/Bayesian/html/reveal.js/LICENSE b/doc/pub/Bayesian/html/reveal.js/LICENSE new file mode 100644 index 000000000..09623076f --- /dev/null +++ b/doc/pub/Bayesian/html/reveal.js/LICENSE @@ -0,0 +1,19 @@ +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 +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. \ No newline at end of file diff --git a/doc/pub/Bayesian/html/reveal.js/README.md b/doc/pub/Bayesian/html/reveal.js/README.md new file mode 100644 index 000000000..573b19597 --- /dev/null +++ b/doc/pub/Bayesian/html/reveal.js/README.md @@ -0,0 +1,1052 @@ +# 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://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). 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. + + +#### 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. +- [Plugins](https://github.com/hakimel/reveal.js/wiki/Plugins,-Tools-and-Hardware): A list of plugins that can be used to extend reveal.js. + +## 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 [http://slides.com](http://slides.com). + + +## Instructions + +### Markup + +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 +
+
+
Single Horizontal Slide
+
+
Vertical Slide 1
+
Vertical Slide 2
+
+
+
+``` + +### 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-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). + +```html +
+
+``` + +#### Element Attributes + +Special syntax (in html comment) is available for adding attributes to Markdown elements. This is useful for fragments, amongst other things. + +```html +
+ +
+``` + +#### Slide Attributes + +Special syntax (in html comment) is available for adding attributes to the slide `
` elements generated by your Markdown. + +```html +
+ +
+``` + + +### Configuration + +At the end of your page you need to initialize reveal by running the following code. Note that all config values are optional and will default as specified below. + +```javascript +Reveal.initialize({ + + // Display controls in the bottom right corner + controls: true, + + // Display a presentation progress bar + progress: true, + + // Display the page number of the current slide + slideNumber: false, + + // Push each slide change to the browser history + history: false, + + // Enable keyboard shortcuts for navigation + keyboard: true, + + // Enable the slide overview mode + overview: true, + + // Vertical centering of slides + center: true, + + // Enables touch navigation on devices with touch input + touch: true, + + // Loop the presentation + loop: false, + + // Change the presentation direction to be RTL + rtl: false, + + // Turns fragments on and off globally + fragments: true, + + // Flags if the presentation is running in an embedded mode, + // i.e. contained within a limited portion of the screen + embedded: false, + + // Flags if we should show a help overlay when the questionmark + // key is pressed + help: true, + + // 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 + autoSlide: 0, + + // Stop auto-sliding after user input + autoSlideStoppable: true, + + // Enable slide navigation via mouse wheel + mouseWheel: false, + + // Hides the address bar on mobile devices + hideAddressBar: true, + + // Opens links in an iframe preview overlay + previewLinks: false, + + // Transition style + transition: 'default', // none/fade/slide/convex/concave/zoom + + // Transition speed + transitionSpeed: 'default', // default/fast/slow + + // Transition style for full page slide backgrounds + backgroundTransition: 'default', // none/fade/slide/convex/concave/zoom + + // Number of slides away from the current that are visible + viewDistance: 3, + + // Parallax background image + parallaxBackgroundImage: '', // e.g. "'https://s3.amazonaws.com/hakim-static/reveal-js/reveal-parallax-1.jpg'" + + // Parallax background size + parallaxBackgroundSize: '', // CSS syntax, e.g. "2100px 900px" + + // Amount to move parallax background (horizontal and vertical) on slide change + // Number, e.g. 100 + parallaxBackgroundHorizontal: '', + parallaxBackgroundVertical: '' + +}); +``` + + +The configuration can be updated after initialization using the ```configure``` method: + +```javascript +// Turn autoSlide off +Reveal.configure({ autoSlide: 0 }); + +// Start auto-sliding every 5s +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. + +See below for a list of configuration options related to sizing, including default values: + +```javascript +Reveal.initialize({ + + ... + + // The "normal" size of the presentation, aspect ratio will be preserved + // when the presentation is scaled to fit different resolutions. Can be + // specified using percentage units. + width: 960, + height: 700, + + // Factor of the display size that should remain empty around the content + margin: 0.1, + + // Bounds for smallest/largest possible scale to apply to content + minScale: 0.2, + maxScale: 1.5 + +}); +``` + + +### Auto-sliding + +Presentations can be configured to progress through slides automatically, without any user input. To enable this you will need to tell the framework how many milliseconds it should wait between slides: + +```javascript +// Slide every five seconds +Reveal.configure({ + autoSlide: 5000 +}); +``` +When this is turned on a control element will appear that enables users to pause and resume auto-sliding. Alternatively, sliding can be paused or resumed by pressing »a« on the keyboard. Sliding is paused automatically as soon as the user starts navigating. You can disable these controls by specifying ```autoSlideStoppable: false``` in your reveal.js config. + +You can also override the slide duration for individual slides and fragments by using the ```data-autoslide``` attribute: + +```html +
+

After 2 seconds the first fragment will be shown.

+

After 10 seconds the next fragment will be shown.

+

Now, the fragment is displayed for 2 seconds before the next slide is shown.

+
+``` + +Whenever the auto-slide mode is resumed or paused the ```autoslideresumed``` and ```autoslidepaused``` events are fired. + + +### Keyboard Bindings + +If you're unhappy with any of the default keyboard bindings you can override them using the ```keyboard``` config option: + +```javascript +Reveal.configure({ + keyboard: { + 13: 'next', // go to the next slide when the ENTER key is pressed + 27: function() {}, // do something custom when ESC is pressed + 32: null // don't do anything when SPACE is pressed (i.e. disable a reveal.js default binding) + } +}); +``` + +### 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. + +To enable lazy loading all you need to do is change your "src" attributes to "data-src" as shown below. This is supported for image, video, audio and iframe elements. Lazy loaded iframes will also unload when the containing slide is no longer visible. + +```html +
+ + + +
+``` + + +### API + +The ``Reveal`` object exposes a JavaScript API for controlling navigation and reading state: + +```javascript +// Navigation +Reveal.slide( indexh, indexv, indexf ); +Reveal.left(); +Reveal.right(); +Reveal.up(); +Reveal.down(); +Reveal.prev(); +Reveal.next(); +Reveal.prevFragment(); +Reveal.nextFragment(); + +// Toggle presentation states, optionally pass true/false to force on/off +Reveal.toggleOverview(); +Reveal.togglePause(); +Reveal.toggleAutoSlide(); + +// Change a config value at runtime +Reveal.configure({ controls: true }); + +// Returns the present configuration options +Reveal.getConfig(); + +// Fetch the current scale of the presentation +Reveal.getScale(); + +// Retrieves the previous and current slide elements +Reveal.getPreviousSlide(); +Reveal.getCurrentSlide(); + +Reveal.getIndices(); // { h: 0, v: 0 } } +Reveal.getProgress(); // 0-1 +Reveal.getTotalSlides(); + +// State checks +Reveal.isFirstSlide(); +Reveal.isLastSlide(); +Reveal.isOverview(); +Reveal.isPaused(); +Reveal.isAutoSliding(); +``` + +### Slide Changed Event + +A 'slidechanged' event is fired each time the slide is changed (regardless of state). The event object holds the index values of the current slide as well as a reference to the previous and current slide HTML nodes. + +Some libraries, like MathJax (see [#226](https://github.com/hakimel/reveal.js/issues/226#issuecomment-10261609)), get confused by the transforms and display states of slides. Often times, this can be fixed by calling their update or render function from this callback. + +```javascript +Reveal.addEventListener( 'slidechanged', function( event ) { + // event.previousSlide, event.currentSlide, event.indexh, event.indexv +} ); +``` + +### Presentation State + +The presentation's current state can be fetched by using the `getState` method. A state object contains all of the information required to put the presentation back as it was when `getState` was first called. Sort of like a snapshot. It's a simple object that can easily be stringified and persisted or sent over the wire. + +```javascript +Reveal.slide( 1 ); +// we're on slide 1 + +var state = Reveal.getState(); + +Reveal.slide( 3 ); +// we're on slide 3 + +Reveal.setState( state ); +// we're back on slide 1 +``` + +### Slide States + +If you set ``data-state="somestate"`` on a slide ``
``, "somestate" will be applied as a class on the document element when that slide is opened. This allows you to apply broad style changes to the page based on the active slide. + +Furthermore you can also listen to these changes in state via JavaScript: + +```javascript +Reveal.addEventListener( 'somestate', function() { + // TODO: Sprinkle magic +}, false ); +``` + +### 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. Below are a few examples. + +```html +
+

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.

+
+``` + +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. + + +### Parallax Background + +If you want to use a parallax scrolling background, set the first two config properties below when initializing reveal.js (the other two are optional). + +```javascript +Reveal.initialize({ + + // Parallax background image + parallaxBackgroundImage: '', // e.g. "https://s3.amazonaws.com/hakim-static/reveal-js/reveal-parallax-1.jpg" + + // Parallax background size + parallaxBackgroundSize: '', // CSS syntax, e.g. "2100px 900px" - currently only pixels are supported (don't use % or auto) + + // 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://lab.hakim.se/reveal-js/?parallaxBackgroundImage=https%3A%2F%2Fs3.amazonaws.com%2Fhakim-static%2Freveal-js%2Freveal-parallax-1.jpg¶llaxBackgroundSize=2100px%20900px). + + + +### Slide Transitions +The global presentation transition is set using the ```transition``` config value. You can override the global transition for a specific slide by using the ```data-transition``` attribute: + +```html +
+

This slide will override the presentation transition and zoom!

+
+ +
+

Choose from three transition speeds: default, fast or slow!

+
+``` + +You can also use different in and out transitions for the same slide: + +```html +
+ The train goes on … +
+
+ and on … +
+
+ and stops. +
+
+ (Passengers entering and leaving) +
+
+ And it starts again. +
+``` + + +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 (```
```): + +```html +Link +Link +``` + +You can also add relative navigation links, similar to the built in reveal.js controls, by appending one of the following classes on any element. Note that each element is automatically given an ```enabled``` class when it's a valid navigation route based on the current slide. + +```html + + + + + + +``` + + +### 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: + +```html +
+

grow

+

shrink

+

fade-out

+

visible only once

+

blue only once

+

highlight-red

+

highlight-green

+

highlight-blue

+
+``` + +Multiple fragments can be applied to the same element sequentially by wrapping it, this will fade in the text on the first step and fade it back out on the second. + +```html +
+ + I'll fade in, then out + +
+``` + +The display order of fragments can be controlled using the ```data-fragment-index``` attribute. + +```html +
+

Appears last

+

Appears first

+

Appears second

+
+``` + +### Fragment events + +When a slide fragment is either shown or hidden reveal.js will dispatch an event. + +Some libraries, like MathJax (see #505), get confused by the initially hidden fragment elements. Often times this can be fixed by calling their update or render function from this callback. + +```javascript +Reveal.addEventListener( 'fragmentshown', function( event ) { + // event.fragment = the fragment DOM element +} ); +Reveal.addEventListener( 'fragmenthidden', function( event ) { + // event.fragment = the fragment DOM element +} ); +``` + +### Code syntax highlighting + +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]
+        (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``` configuration value. + +```javascript +// Shows the slide number using default formatting +Reveal.configure({ slideNumber: true }); + +// Slide number formatting can be configured using these variables: +// 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' }); + +``` + + +### Overview mode + +Press "Esc" or "o" keys to toggle the overview mode on and off. While you're in this mode, you can still navigate between slides, +as if you were at 1,000 feet above your presentation. The overview mode comes with a few API hooks: + +```javascript +Reveal.addEventListener( 'overviewshown', function( event ) { /* ... */ } ); +Reveal.addEventListener( 'overviewhidden', function( event ) { /* ... */ } ); + +// Toggle the overview mode programmatically +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 `
+ +
+ +

 

 

 

+ + + + + + +
+

Data Analysis and Machine Learning: Elements of machine learning

+ +

+ + +

+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, 2017

+
+

+ + +

Read »

+ + +
+ +

+ +

+ + +
+ + + + + + + +
+ © 1999-2017, Morten Hjorth-Jensen. Released under CC Attribution-NonCommercial 4.0 license +
+ + + + + + diff --git a/doc/pub/NeuralNet/html/._NeuralNet-bs001.html b/doc/pub/NeuralNet/html/._NeuralNet-bs001.html new file mode 100644 index 000000000..13ade162b --- /dev/null +++ b/doc/pub/NeuralNet/html/._NeuralNet-bs001.html @@ -0,0 +1,119 @@ + + + + + + + +Data Analysis and Machine Learning: Elements of machine learning + + + + + + + + + + + + + + + + + +
+ +
+ +

 

 

 

+ + + + +

Introduction

+
+
+

+ +

+

+
+ + +

+ +

+ + +
+ + + + + + + +
+ +
+ + + + + + diff --git a/doc/pub/NeuralNet/html/NeuralNet-bs.html b/doc/pub/NeuralNet/html/NeuralNet-bs.html new file mode 100644 index 000000000..9644c2e5a --- /dev/null +++ b/doc/pub/NeuralNet/html/NeuralNet-bs.html @@ -0,0 +1,138 @@ + + + + + + + +Data Analysis and Machine Learning: Elements of machine learning + + + + + + + + + + + + + + + + + + + +
+ +

 

 

 

+ + + + + + +
+

Data Analysis and Machine Learning: Elements of machine learning

+ +

+ + +

+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, 2017

+
+

+ + +

Read »

+ + +
+ +

+ +

+ + +
+ + + + + + + +
+ © 1999-2017, Morten Hjorth-Jensen. Released under CC Attribution-NonCommercial 4.0 license +
+ + + + + + diff --git a/doc/pub/NeuralNet/html/NeuralNet-reveal.html b/doc/pub/NeuralNet/html/NeuralNet-reveal.html new file mode 100644 index 000000000..1a6e48349 --- /dev/null +++ b/doc/pub/NeuralNet/html/NeuralNet-reveal.html @@ -0,0 +1,296 @@ + + + + + + +Data Analysis and Machine Learning: Elements of machine learning + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + +
+ + + + + + + +
+ + + + +

Data Analysis and Machine Learning: Elements of machine learning

+ +

+ + +

+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, 2017

+
+

+ +

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

Introduction

+
+ +

+

+
+ + + +
+
+ + + + + + + + + + + + diff --git a/doc/pub/NeuralNet/html/NeuralNet-solarized.html b/doc/pub/NeuralNet/html/NeuralNet-solarized.html new file mode 100644 index 000000000..1e4defb55 --- /dev/null +++ b/doc/pub/NeuralNet/html/NeuralNet-solarized.html @@ -0,0 +1,113 @@ + + + + + + + +Data Analysis and Machine Learning: Elements of machine learning + + + + + + + + + + + + + + + + + + + + + +

Data Analysis and Machine Learning: Elements of machine learning

+ +

+ + +

+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, 2017

+
+

+









+ +

Introduction

+
+ +

+ + +

+ + + + + +
+ © 1999-2017, Morten Hjorth-Jensen. Released under CC Attribution-NonCommercial 4.0 license +
+ + + + + + diff --git a/doc/pub/NeuralNet/html/NeuralNet.html b/doc/pub/NeuralNet/html/NeuralNet.html new file mode 100644 index 000000000..6e5932a34 --- /dev/null +++ b/doc/pub/NeuralNet/html/NeuralNet.html @@ -0,0 +1,118 @@ + + + + + + + +Data Analysis and Machine Learning: Elements of machine learning + + + + + + + + + + + + + + + + +

Data Analysis and Machine Learning: Elements of machine learning

+ +

+ + +

+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, 2017

+
+

+









+ +

Introduction

+
+ +

+ + +

+ + + + + +
+ © 1999-2017, Morten Hjorth-Jensen. Released under CC Attribution-NonCommercial 4.0 license +
+ + + + + + diff --git a/doc/pub/NeuralNet/html/reveal.js/.gitignore b/doc/pub/NeuralNet/html/reveal.js/.gitignore new file mode 100644 index 000000000..a5df3133d --- /dev/null +++ b/doc/pub/NeuralNet/html/reveal.js/.gitignore @@ -0,0 +1,8 @@ +.DS_Store +.svn +log/*.log +tmp/** +node_modules/ +.sass-cache +css/reveal.min.css +js/reveal.min.js diff --git a/doc/pub/NeuralNet/html/reveal.js/.travis.yml b/doc/pub/NeuralNet/html/reveal.js/.travis.yml new file mode 100644 index 000000000..165d9ae9f --- /dev/null +++ b/doc/pub/NeuralNet/html/reveal.js/.travis.yml @@ -0,0 +1,5 @@ +language: node_js +node_js: + - 0.10 +before_script: + - npm install -g grunt-cli \ No newline at end of file diff --git a/doc/pub/NeuralNet/html/reveal.js/CONTRIBUTING.md b/doc/pub/NeuralNet/html/reveal.js/CONTRIBUTING.md new file mode 100644 index 000000000..c2091e88f --- /dev/null +++ b/doc/pub/NeuralNet/html/reveal.js/CONTRIBUTING.md @@ -0,0 +1,23 @@ +## Contributing + +Please keep the [issue tracker](http://github.com/hakimel/reveal.js/issues) limited to **bug reports**, **feature requests** and **pull requests**. + + +### Personal Support +If you have personal support or setup questions the best place to ask those are [StackOverflow](http://stackoverflow.com/questions/tagged/reveal.js). + + +### Bug Reports +When reporting a bug make sure to include information about which browser and operating system you are on as well as the necessary steps to reproduce the issue. If possible please include a link to a sample presentation where the bug can be tested. + + +### Pull Requests +- Should follow the coding style of the file you work in, most importantly: + - Tabs to indent + - Single-quoted strings +- Should be made towards the **dev branch** +- Should be submitted from a feature/topic branch (not your master) + + +### Plugins +Please do not submit plugins as pull requests. They should be maintained in their own separate repository. More information here: https://github.com/hakimel/reveal.js/wiki/Plugin-Guidelines diff --git a/doc/pub/NeuralNet/html/reveal.js/Gruntfile.js b/doc/pub/NeuralNet/html/reveal.js/Gruntfile.js new file mode 100644 index 000000000..b257e8f32 --- /dev/null +++ b/doc/pub/NeuralNet/html/reveal.js/Gruntfile.js @@ -0,0 +1,140 @@ +/* global module:false */ +module.exports = function(grunt) { + var port = grunt.option('port') || 8000; + // Project configuration + grunt.initConfig({ + pkg: grunt.file.readJSON('package.json'), + meta: { + banner: + '/*!\n' + + ' * reveal.js <%= pkg.version %> (<%= grunt.template.today("yyyy-mm-dd, HH:MM") %>)\n' + + ' * http://lab.hakim.se/reveal-js\n' + + ' * MIT licensed\n' + + ' *\n' + + ' * Copyright (C) 2014 Hakim El Hattab, http://hakim.se\n' + + ' */' + }, + + qunit: { + files: [ 'test/*.html' ] + }, + + uglify: { + options: { + banner: '<%= meta.banner %>\n' + }, + build: { + src: 'js/reveal.js', + dest: 'js/reveal.min.js' + } + }, + + cssmin: { + compress: { + files: { + 'css/reveal.min.css': [ 'css/reveal.css' ] + } + } + }, + + sass: { + main: { + files: { + 'css/theme/darkgray.css': 'css/theme/source/darkgray.scss', + 'css/theme/beigesmall.css': 'css/theme/source/beigesmall.scss', + 'css/theme/cbc.css': 'css/theme/source/cbc.scss', + 'css/theme/default.css': 'css/theme/source/default.scss', + 'css/theme/beige.css': 'css/theme/source/beige.scss', + 'css/theme/night.css': 'css/theme/source/night.scss', + 'css/theme/serif.css': 'css/theme/source/serif.scss', + 'css/theme/simple.css': 'css/theme/source/simple.scss', + 'css/theme/sky.css': 'css/theme/source/sky.scss', + 'css/theme/moon.css': 'css/theme/source/moon.scss', + 'css/theme/solarized.css': 'css/theme/source/solarized.scss', + 'css/theme/blood.css': 'css/theme/source/blood.scss' + } + } + }, + + jshint: { + options: { + curly: false, + eqeqeq: true, + immed: true, + latedef: true, + newcap: true, + noarg: true, + sub: true, + undef: true, + eqnull: true, + browser: true, + expr: true, + globals: { + head: false, + module: false, + console: false, + unescape: false + } + }, + files: [ 'Gruntfile.js', 'js/reveal.js' ] + }, + + connect: { + server: { + options: { + port: port, + base: '.' + } + } + }, + + zip: { + 'reveal-js-presentation.zip': [ + 'index.html', + 'css/**', + 'js/**', + 'lib/**', + 'images/**', + 'plugin/**' + ] + }, + + watch: { + main: { + files: [ 'Gruntfile.js', 'js/reveal.js', 'css/reveal.css' ], + tasks: 'default' + }, + theme: { + files: [ 'css/theme/source/*.scss', 'css/theme/template/*.scss' ], + tasks: 'themes' + } + } + + }); + + // Dependencies + grunt.loadNpmTasks( 'grunt-contrib-qunit' ); + grunt.loadNpmTasks( 'grunt-contrib-jshint' ); + grunt.loadNpmTasks( 'grunt-contrib-cssmin' ); + grunt.loadNpmTasks( 'grunt-contrib-uglify' ); + grunt.loadNpmTasks( 'grunt-contrib-watch' ); + grunt.loadNpmTasks( 'grunt-contrib-sass' ); + grunt.loadNpmTasks( 'grunt-contrib-connect' ); + grunt.loadNpmTasks( 'grunt-zip' ); + + // Default task + grunt.registerTask( 'default', [ 'jshint', 'cssmin', 'uglify', 'qunit' ] ); + + // Theme task + grunt.registerTask( 'themes', [ 'sass' ] ); + + // Package presentation to archive + grunt.registerTask( 'package', [ 'default', 'zip' ] ); + + // Serve presentation locally + grunt.registerTask( 'serve', [ 'connect', 'watch' ] ); + + // Run tests + grunt.registerTask( 'test', [ 'jshint', 'qunit' ] ); + +}; diff --git a/doc/pub/NeuralNet/html/reveal.js/LICENSE b/doc/pub/NeuralNet/html/reveal.js/LICENSE new file mode 100644 index 000000000..09623076f --- /dev/null +++ b/doc/pub/NeuralNet/html/reveal.js/LICENSE @@ -0,0 +1,19 @@ +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 +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. \ No newline at end of file diff --git a/doc/pub/NeuralNet/html/reveal.js/README.md b/doc/pub/NeuralNet/html/reveal.js/README.md new file mode 100644 index 000000000..573b19597 --- /dev/null +++ b/doc/pub/NeuralNet/html/reveal.js/README.md @@ -0,0 +1,1052 @@ +# 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://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). 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. + + +#### 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. +- [Plugins](https://github.com/hakimel/reveal.js/wiki/Plugins,-Tools-and-Hardware): A list of plugins that can be used to extend reveal.js. + +## 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 [http://slides.com](http://slides.com). + + +## Instructions + +### Markup + +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 +
+
+
Single Horizontal Slide
+
+
Vertical Slide 1
+
Vertical Slide 2
+
+
+
+``` + +### 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-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). + +```html +
+
+``` + +#### Element Attributes + +Special syntax (in html comment) is available for adding attributes to Markdown elements. This is useful for fragments, amongst other things. + +```html +
+ +
+``` + +#### Slide Attributes + +Special syntax (in html comment) is available for adding attributes to the slide `
` elements generated by your Markdown. + +```html +
+ +
+``` + + +### Configuration + +At the end of your page you need to initialize reveal by running the following code. Note that all config values are optional and will default as specified below. + +```javascript +Reveal.initialize({ + + // Display controls in the bottom right corner + controls: true, + + // Display a presentation progress bar + progress: true, + + // Display the page number of the current slide + slideNumber: false, + + // Push each slide change to the browser history + history: false, + + // Enable keyboard shortcuts for navigation + keyboard: true, + + // Enable the slide overview mode + overview: true, + + // Vertical centering of slides + center: true, + + // Enables touch navigation on devices with touch input + touch: true, + + // Loop the presentation + loop: false, + + // Change the presentation direction to be RTL + rtl: false, + + // Turns fragments on and off globally + fragments: true, + + // Flags if the presentation is running in an embedded mode, + // i.e. contained within a limited portion of the screen + embedded: false, + + // Flags if we should show a help overlay when the questionmark + // key is pressed + help: true, + + // 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 + autoSlide: 0, + + // Stop auto-sliding after user input + autoSlideStoppable: true, + + // Enable slide navigation via mouse wheel + mouseWheel: false, + + // Hides the address bar on mobile devices + hideAddressBar: true, + + // Opens links in an iframe preview overlay + previewLinks: false, + + // Transition style + transition: 'default', // none/fade/slide/convex/concave/zoom + + // Transition speed + transitionSpeed: 'default', // default/fast/slow + + // Transition style for full page slide backgrounds + backgroundTransition: 'default', // none/fade/slide/convex/concave/zoom + + // Number of slides away from the current that are visible + viewDistance: 3, + + // Parallax background image + parallaxBackgroundImage: '', // e.g. "'https://s3.amazonaws.com/hakim-static/reveal-js/reveal-parallax-1.jpg'" + + // Parallax background size + parallaxBackgroundSize: '', // CSS syntax, e.g. "2100px 900px" + + // Amount to move parallax background (horizontal and vertical) on slide change + // Number, e.g. 100 + parallaxBackgroundHorizontal: '', + parallaxBackgroundVertical: '' + +}); +``` + + +The configuration can be updated after initialization using the ```configure``` method: + +```javascript +// Turn autoSlide off +Reveal.configure({ autoSlide: 0 }); + +// Start auto-sliding every 5s +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. + +See below for a list of configuration options related to sizing, including default values: + +```javascript +Reveal.initialize({ + + ... + + // The "normal" size of the presentation, aspect ratio will be preserved + // when the presentation is scaled to fit different resolutions. Can be + // specified using percentage units. + width: 960, + height: 700, + + // Factor of the display size that should remain empty around the content + margin: 0.1, + + // Bounds for smallest/largest possible scale to apply to content + minScale: 0.2, + maxScale: 1.5 + +}); +``` + + +### Auto-sliding + +Presentations can be configured to progress through slides automatically, without any user input. To enable this you will need to tell the framework how many milliseconds it should wait between slides: + +```javascript +// Slide every five seconds +Reveal.configure({ + autoSlide: 5000 +}); +``` +When this is turned on a control element will appear that enables users to pause and resume auto-sliding. Alternatively, sliding can be paused or resumed by pressing »a« on the keyboard. Sliding is paused automatically as soon as the user starts navigating. You can disable these controls by specifying ```autoSlideStoppable: false``` in your reveal.js config. + +You can also override the slide duration for individual slides and fragments by using the ```data-autoslide``` attribute: + +```html +
+

After 2 seconds the first fragment will be shown.

+

After 10 seconds the next fragment will be shown.

+

Now, the fragment is displayed for 2 seconds before the next slide is shown.

+
+``` + +Whenever the auto-slide mode is resumed or paused the ```autoslideresumed``` and ```autoslidepaused``` events are fired. + + +### Keyboard Bindings + +If you're unhappy with any of the default keyboard bindings you can override them using the ```keyboard``` config option: + +```javascript +Reveal.configure({ + keyboard: { + 13: 'next', // go to the next slide when the ENTER key is pressed + 27: function() {}, // do something custom when ESC is pressed + 32: null // don't do anything when SPACE is pressed (i.e. disable a reveal.js default binding) + } +}); +``` + +### 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. + +To enable lazy loading all you need to do is change your "src" attributes to "data-src" as shown below. This is supported for image, video, audio and iframe elements. Lazy loaded iframes will also unload when the containing slide is no longer visible. + +```html +
+ + + +
+``` + + +### API + +The ``Reveal`` object exposes a JavaScript API for controlling navigation and reading state: + +```javascript +// Navigation +Reveal.slide( indexh, indexv, indexf ); +Reveal.left(); +Reveal.right(); +Reveal.up(); +Reveal.down(); +Reveal.prev(); +Reveal.next(); +Reveal.prevFragment(); +Reveal.nextFragment(); + +// Toggle presentation states, optionally pass true/false to force on/off +Reveal.toggleOverview(); +Reveal.togglePause(); +Reveal.toggleAutoSlide(); + +// Change a config value at runtime +Reveal.configure({ controls: true }); + +// Returns the present configuration options +Reveal.getConfig(); + +// Fetch the current scale of the presentation +Reveal.getScale(); + +// Retrieves the previous and current slide elements +Reveal.getPreviousSlide(); +Reveal.getCurrentSlide(); + +Reveal.getIndices(); // { h: 0, v: 0 } } +Reveal.getProgress(); // 0-1 +Reveal.getTotalSlides(); + +// State checks +Reveal.isFirstSlide(); +Reveal.isLastSlide(); +Reveal.isOverview(); +Reveal.isPaused(); +Reveal.isAutoSliding(); +``` + +### Slide Changed Event + +A 'slidechanged' event is fired each time the slide is changed (regardless of state). The event object holds the index values of the current slide as well as a reference to the previous and current slide HTML nodes. + +Some libraries, like MathJax (see [#226](https://github.com/hakimel/reveal.js/issues/226#issuecomment-10261609)), get confused by the transforms and display states of slides. Often times, this can be fixed by calling their update or render function from this callback. + +```javascript +Reveal.addEventListener( 'slidechanged', function( event ) { + // event.previousSlide, event.currentSlide, event.indexh, event.indexv +} ); +``` + +### Presentation State + +The presentation's current state can be fetched by using the `getState` method. A state object contains all of the information required to put the presentation back as it was when `getState` was first called. Sort of like a snapshot. It's a simple object that can easily be stringified and persisted or sent over the wire. + +```javascript +Reveal.slide( 1 ); +// we're on slide 1 + +var state = Reveal.getState(); + +Reveal.slide( 3 ); +// we're on slide 3 + +Reveal.setState( state ); +// we're back on slide 1 +``` + +### Slide States + +If you set ``data-state="somestate"`` on a slide ``
``, "somestate" will be applied as a class on the document element when that slide is opened. This allows you to apply broad style changes to the page based on the active slide. + +Furthermore you can also listen to these changes in state via JavaScript: + +```javascript +Reveal.addEventListener( 'somestate', function() { + // TODO: Sprinkle magic +}, false ); +``` + +### 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. Below are a few examples. + +```html +
+

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.

+
+``` + +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. + + +### Parallax Background + +If you want to use a parallax scrolling background, set the first two config properties below when initializing reveal.js (the other two are optional). + +```javascript +Reveal.initialize({ + + // Parallax background image + parallaxBackgroundImage: '', // e.g. "https://s3.amazonaws.com/hakim-static/reveal-js/reveal-parallax-1.jpg" + + // Parallax background size + parallaxBackgroundSize: '', // CSS syntax, e.g. "2100px 900px" - currently only pixels are supported (don't use % or auto) + + // 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://lab.hakim.se/reveal-js/?parallaxBackgroundImage=https%3A%2F%2Fs3.amazonaws.com%2Fhakim-static%2Freveal-js%2Freveal-parallax-1.jpg¶llaxBackgroundSize=2100px%20900px). + + + +### Slide Transitions +The global presentation transition is set using the ```transition``` config value. You can override the global transition for a specific slide by using the ```data-transition``` attribute: + +```html +
+

This slide will override the presentation transition and zoom!

+
+ +
+

Choose from three transition speeds: default, fast or slow!

+
+``` + +You can also use different in and out transitions for the same slide: + +```html +
+ The train goes on … +
+
+ and on … +
+
+ and stops. +
+
+ (Passengers entering and leaving) +
+
+ And it starts again. +
+``` + + +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 (```
```): + +```html +Link +Link +``` + +You can also add relative navigation links, similar to the built in reveal.js controls, by appending one of the following classes on any element. Note that each element is automatically given an ```enabled``` class when it's a valid navigation route based on the current slide. + +```html + + + + + + +``` + + +### 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: + +```html +
+

grow

+

shrink

+

fade-out

+

visible only once

+

blue only once

+

highlight-red

+

highlight-green

+

highlight-blue

+
+``` + +Multiple fragments can be applied to the same element sequentially by wrapping it, this will fade in the text on the first step and fade it back out on the second. + +```html +
+ + I'll fade in, then out + +
+``` + +The display order of fragments can be controlled using the ```data-fragment-index``` attribute. + +```html +
+

Appears last

+

Appears first

+

Appears second

+
+``` + +### Fragment events + +When a slide fragment is either shown or hidden reveal.js will dispatch an event. + +Some libraries, like MathJax (see #505), get confused by the initially hidden fragment elements. Often times this can be fixed by calling their update or render function from this callback. + +```javascript +Reveal.addEventListener( 'fragmentshown', function( event ) { + // event.fragment = the fragment DOM element +} ); +Reveal.addEventListener( 'fragmenthidden', function( event ) { + // event.fragment = the fragment DOM element +} ); +``` + +### Code syntax highlighting + +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]
+        (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``` configuration value. + +```javascript +// Shows the slide number using default formatting +Reveal.configure({ slideNumber: true }); + +// Slide number formatting can be configured using these variables: +// 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' }); + +``` + + +### Overview mode + +Press "Esc" or "o" keys to toggle the overview mode on and off. While you're in this mode, you can still navigate between slides, +as if you were at 1,000 feet above your presentation. The overview mode comes with a few API hooks: + +```javascript +Reveal.addEventListener( 'overviewshown', function( event ) { /* ... */ } ); +Reveal.addEventListener( 'overviewhidden', function( event ) { /* ... */ } ); + +// Toggle the overview mode programmatically +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 `
+ +
+ +

 

 

 

+ + + + + + +
+

Data Analysis and Machine Learning: Linear and more Advanced Regression 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, 2017

+
+

+ + +

Read »

+ + +
+ +

+ +

+ + +
+ + + + + + + +
+ © 1999-2017, Morten Hjorth-Jensen. Released under CC Attribution-NonCommercial 4.0 license +
+ + + + + + diff --git a/doc/pub/Regression/html/._Regression-bs001.html b/doc/pub/Regression/html/._Regression-bs001.html new file mode 100644 index 000000000..a8e35f833 --- /dev/null +++ b/doc/pub/Regression/html/._Regression-bs001.html @@ -0,0 +1,119 @@ + + + + + + + +Data Analysis and Machine Learning: Linear and more Advanced Regression Analysis + + + + + + + + + + + + + + + + + +
+ +
+ +

 

 

 

+ + + + +

Introduction

+
+
+

+ +

+

+
+ + +

+ +

+ + +
+ + + + + + + +
+ +
+ + + + + + diff --git a/doc/pub/Regression/html/Regression-bs.html b/doc/pub/Regression/html/Regression-bs.html new file mode 100644 index 000000000..1eaaf829a --- /dev/null +++ b/doc/pub/Regression/html/Regression-bs.html @@ -0,0 +1,138 @@ + + + + + + + +Data Analysis and Machine Learning: Linear and more Advanced Regression Analysis + + + + + + + + + + + + + + + + + + + +
+ +

 

 

 

+ + + + + + +
+

Data Analysis and Machine Learning: Linear and more Advanced Regression 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, 2017

+
+

+ + +

Read »

+ + +
+ +

+ +

+ + +
+ + + + + + + +
+ © 1999-2017, Morten Hjorth-Jensen. Released under CC Attribution-NonCommercial 4.0 license +
+ + + + + + diff --git a/doc/pub/Regression/html/Regression-reveal.html b/doc/pub/Regression/html/Regression-reveal.html new file mode 100644 index 000000000..6622714b1 --- /dev/null +++ b/doc/pub/Regression/html/Regression-reveal.html @@ -0,0 +1,296 @@ + + + + + + +Data Analysis and Machine Learning: Linear and more Advanced Regression Analysis + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + +
+ + + + + + + +
+ + + + +

Data Analysis and Machine Learning: Linear and more Advanced Regression 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, 2017

+
+

+ +

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

Introduction

+
+ +

+

+
+ + + +
+
+ + + + + + + + + + + + diff --git a/doc/pub/Regression/html/Regression-solarized.html b/doc/pub/Regression/html/Regression-solarized.html new file mode 100644 index 000000000..dec343182 --- /dev/null +++ b/doc/pub/Regression/html/Regression-solarized.html @@ -0,0 +1,113 @@ + + + + + + + +Data Analysis and Machine Learning: Linear and more Advanced Regression Analysis + + + + + + + + + + + + + + + + + + + + + +

Data Analysis and Machine Learning: Linear and more Advanced Regression 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, 2017

+
+

+









+ +

Introduction

+
+ +

+ + +

+ + + + + +
+ © 1999-2017, Morten Hjorth-Jensen. Released under CC Attribution-NonCommercial 4.0 license +
+ + + + + + diff --git a/doc/pub/Regression/html/Regression.html b/doc/pub/Regression/html/Regression.html new file mode 100644 index 000000000..3f985f456 --- /dev/null +++ b/doc/pub/Regression/html/Regression.html @@ -0,0 +1,118 @@ + + + + + + + +Data Analysis and Machine Learning: Linear and more Advanced Regression Analysis + + + + + + + + + + + + + + + + +

Data Analysis and Machine Learning: Linear and more Advanced Regression 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, 2017

+
+

+









+ +

Introduction

+
+ +

+ + +

+ + + + + +
+ © 1999-2017, Morten Hjorth-Jensen. Released under CC Attribution-NonCommercial 4.0 license +
+ + + + + + diff --git a/doc/pub/Regression/html/reveal.js/.gitignore b/doc/pub/Regression/html/reveal.js/.gitignore new file mode 100644 index 000000000..a5df3133d --- /dev/null +++ b/doc/pub/Regression/html/reveal.js/.gitignore @@ -0,0 +1,8 @@ +.DS_Store +.svn +log/*.log +tmp/** +node_modules/ +.sass-cache +css/reveal.min.css +js/reveal.min.js diff --git a/doc/pub/Regression/html/reveal.js/.travis.yml b/doc/pub/Regression/html/reveal.js/.travis.yml new file mode 100644 index 000000000..165d9ae9f --- /dev/null +++ b/doc/pub/Regression/html/reveal.js/.travis.yml @@ -0,0 +1,5 @@ +language: node_js +node_js: + - 0.10 +before_script: + - npm install -g grunt-cli \ No newline at end of file diff --git a/doc/pub/Regression/html/reveal.js/CONTRIBUTING.md b/doc/pub/Regression/html/reveal.js/CONTRIBUTING.md new file mode 100644 index 000000000..c2091e88f --- /dev/null +++ b/doc/pub/Regression/html/reveal.js/CONTRIBUTING.md @@ -0,0 +1,23 @@ +## Contributing + +Please keep the [issue tracker](http://github.com/hakimel/reveal.js/issues) limited to **bug reports**, **feature requests** and **pull requests**. + + +### Personal Support +If you have personal support or setup questions the best place to ask those are [StackOverflow](http://stackoverflow.com/questions/tagged/reveal.js). + + +### Bug Reports +When reporting a bug make sure to include information about which browser and operating system you are on as well as the necessary steps to reproduce the issue. If possible please include a link to a sample presentation where the bug can be tested. + + +### Pull Requests +- Should follow the coding style of the file you work in, most importantly: + - Tabs to indent + - Single-quoted strings +- Should be made towards the **dev branch** +- Should be submitted from a feature/topic branch (not your master) + + +### Plugins +Please do not submit plugins as pull requests. They should be maintained in their own separate repository. More information here: https://github.com/hakimel/reveal.js/wiki/Plugin-Guidelines diff --git a/doc/pub/Regression/html/reveal.js/Gruntfile.js b/doc/pub/Regression/html/reveal.js/Gruntfile.js new file mode 100644 index 000000000..b257e8f32 --- /dev/null +++ b/doc/pub/Regression/html/reveal.js/Gruntfile.js @@ -0,0 +1,140 @@ +/* global module:false */ +module.exports = function(grunt) { + var port = grunt.option('port') || 8000; + // Project configuration + grunt.initConfig({ + pkg: grunt.file.readJSON('package.json'), + meta: { + banner: + '/*!\n' + + ' * reveal.js <%= pkg.version %> (<%= grunt.template.today("yyyy-mm-dd, HH:MM") %>)\n' + + ' * http://lab.hakim.se/reveal-js\n' + + ' * MIT licensed\n' + + ' *\n' + + ' * Copyright (C) 2014 Hakim El Hattab, http://hakim.se\n' + + ' */' + }, + + qunit: { + files: [ 'test/*.html' ] + }, + + uglify: { + options: { + banner: '<%= meta.banner %>\n' + }, + build: { + src: 'js/reveal.js', + dest: 'js/reveal.min.js' + } + }, + + cssmin: { + compress: { + files: { + 'css/reveal.min.css': [ 'css/reveal.css' ] + } + } + }, + + sass: { + main: { + files: { + 'css/theme/darkgray.css': 'css/theme/source/darkgray.scss', + 'css/theme/beigesmall.css': 'css/theme/source/beigesmall.scss', + 'css/theme/cbc.css': 'css/theme/source/cbc.scss', + 'css/theme/default.css': 'css/theme/source/default.scss', + 'css/theme/beige.css': 'css/theme/source/beige.scss', + 'css/theme/night.css': 'css/theme/source/night.scss', + 'css/theme/serif.css': 'css/theme/source/serif.scss', + 'css/theme/simple.css': 'css/theme/source/simple.scss', + 'css/theme/sky.css': 'css/theme/source/sky.scss', + 'css/theme/moon.css': 'css/theme/source/moon.scss', + 'css/theme/solarized.css': 'css/theme/source/solarized.scss', + 'css/theme/blood.css': 'css/theme/source/blood.scss' + } + } + }, + + jshint: { + options: { + curly: false, + eqeqeq: true, + immed: true, + latedef: true, + newcap: true, + noarg: true, + sub: true, + undef: true, + eqnull: true, + browser: true, + expr: true, + globals: { + head: false, + module: false, + console: false, + unescape: false + } + }, + files: [ 'Gruntfile.js', 'js/reveal.js' ] + }, + + connect: { + server: { + options: { + port: port, + base: '.' + } + } + }, + + zip: { + 'reveal-js-presentation.zip': [ + 'index.html', + 'css/**', + 'js/**', + 'lib/**', + 'images/**', + 'plugin/**' + ] + }, + + watch: { + main: { + files: [ 'Gruntfile.js', 'js/reveal.js', 'css/reveal.css' ], + tasks: 'default' + }, + theme: { + files: [ 'css/theme/source/*.scss', 'css/theme/template/*.scss' ], + tasks: 'themes' + } + } + + }); + + // Dependencies + grunt.loadNpmTasks( 'grunt-contrib-qunit' ); + grunt.loadNpmTasks( 'grunt-contrib-jshint' ); + grunt.loadNpmTasks( 'grunt-contrib-cssmin' ); + grunt.loadNpmTasks( 'grunt-contrib-uglify' ); + grunt.loadNpmTasks( 'grunt-contrib-watch' ); + grunt.loadNpmTasks( 'grunt-contrib-sass' ); + grunt.loadNpmTasks( 'grunt-contrib-connect' ); + grunt.loadNpmTasks( 'grunt-zip' ); + + // Default task + grunt.registerTask( 'default', [ 'jshint', 'cssmin', 'uglify', 'qunit' ] ); + + // Theme task + grunt.registerTask( 'themes', [ 'sass' ] ); + + // Package presentation to archive + grunt.registerTask( 'package', [ 'default', 'zip' ] ); + + // Serve presentation locally + grunt.registerTask( 'serve', [ 'connect', 'watch' ] ); + + // Run tests + grunt.registerTask( 'test', [ 'jshint', 'qunit' ] ); + +}; diff --git a/doc/pub/Regression/html/reveal.js/LICENSE b/doc/pub/Regression/html/reveal.js/LICENSE new file mode 100644 index 000000000..09623076f --- /dev/null +++ b/doc/pub/Regression/html/reveal.js/LICENSE @@ -0,0 +1,19 @@ +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 +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. \ No newline at end of file diff --git a/doc/pub/Regression/html/reveal.js/README.md b/doc/pub/Regression/html/reveal.js/README.md new file mode 100644 index 000000000..573b19597 --- /dev/null +++ b/doc/pub/Regression/html/reveal.js/README.md @@ -0,0 +1,1052 @@ +# 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://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). 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. + + +#### 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. +- [Plugins](https://github.com/hakimel/reveal.js/wiki/Plugins,-Tools-and-Hardware): A list of plugins that can be used to extend reveal.js. + +## 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 [http://slides.com](http://slides.com). + + +## Instructions + +### Markup + +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 +
+
+
Single Horizontal Slide
+
+
Vertical Slide 1
+
Vertical Slide 2
+
+
+
+``` + +### 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-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). + +```html +
+
+``` + +#### Element Attributes + +Special syntax (in html comment) is available for adding attributes to Markdown elements. This is useful for fragments, amongst other things. + +```html +
+ +
+``` + +#### Slide Attributes + +Special syntax (in html comment) is available for adding attributes to the slide `
` elements generated by your Markdown. + +```html +
+ +
+``` + + +### Configuration + +At the end of your page you need to initialize reveal by running the following code. Note that all config values are optional and will default as specified below. + +```javascript +Reveal.initialize({ + + // Display controls in the bottom right corner + controls: true, + + // Display a presentation progress bar + progress: true, + + // Display the page number of the current slide + slideNumber: false, + + // Push each slide change to the browser history + history: false, + + // Enable keyboard shortcuts for navigation + keyboard: true, + + // Enable the slide overview mode + overview: true, + + // Vertical centering of slides + center: true, + + // Enables touch navigation on devices with touch input + touch: true, + + // Loop the presentation + loop: false, + + // Change the presentation direction to be RTL + rtl: false, + + // Turns fragments on and off globally + fragments: true, + + // Flags if the presentation is running in an embedded mode, + // i.e. contained within a limited portion of the screen + embedded: false, + + // Flags if we should show a help overlay when the questionmark + // key is pressed + help: true, + + // 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 + autoSlide: 0, + + // Stop auto-sliding after user input + autoSlideStoppable: true, + + // Enable slide navigation via mouse wheel + mouseWheel: false, + + // Hides the address bar on mobile devices + hideAddressBar: true, + + // Opens links in an iframe preview overlay + previewLinks: false, + + // Transition style + transition: 'default', // none/fade/slide/convex/concave/zoom + + // Transition speed + transitionSpeed: 'default', // default/fast/slow + + // Transition style for full page slide backgrounds + backgroundTransition: 'default', // none/fade/slide/convex/concave/zoom + + // Number of slides away from the current that are visible + viewDistance: 3, + + // Parallax background image + parallaxBackgroundImage: '', // e.g. "'https://s3.amazonaws.com/hakim-static/reveal-js/reveal-parallax-1.jpg'" + + // Parallax background size + parallaxBackgroundSize: '', // CSS syntax, e.g. "2100px 900px" + + // Amount to move parallax background (horizontal and vertical) on slide change + // Number, e.g. 100 + parallaxBackgroundHorizontal: '', + parallaxBackgroundVertical: '' + +}); +``` + + +The configuration can be updated after initialization using the ```configure``` method: + +```javascript +// Turn autoSlide off +Reveal.configure({ autoSlide: 0 }); + +// Start auto-sliding every 5s +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. + +See below for a list of configuration options related to sizing, including default values: + +```javascript +Reveal.initialize({ + + ... + + // The "normal" size of the presentation, aspect ratio will be preserved + // when the presentation is scaled to fit different resolutions. Can be + // specified using percentage units. + width: 960, + height: 700, + + // Factor of the display size that should remain empty around the content + margin: 0.1, + + // Bounds for smallest/largest possible scale to apply to content + minScale: 0.2, + maxScale: 1.5 + +}); +``` + + +### Auto-sliding + +Presentations can be configured to progress through slides automatically, without any user input. To enable this you will need to tell the framework how many milliseconds it should wait between slides: + +```javascript +// Slide every five seconds +Reveal.configure({ + autoSlide: 5000 +}); +``` +When this is turned on a control element will appear that enables users to pause and resume auto-sliding. Alternatively, sliding can be paused or resumed by pressing »a« on the keyboard. Sliding is paused automatically as soon as the user starts navigating. You can disable these controls by specifying ```autoSlideStoppable: false``` in your reveal.js config. + +You can also override the slide duration for individual slides and fragments by using the ```data-autoslide``` attribute: + +```html +
+

After 2 seconds the first fragment will be shown.

+

After 10 seconds the next fragment will be shown.

+

Now, the fragment is displayed for 2 seconds before the next slide is shown.

+
+``` + +Whenever the auto-slide mode is resumed or paused the ```autoslideresumed``` and ```autoslidepaused``` events are fired. + + +### Keyboard Bindings + +If you're unhappy with any of the default keyboard bindings you can override them using the ```keyboard``` config option: + +```javascript +Reveal.configure({ + keyboard: { + 13: 'next', // go to the next slide when the ENTER key is pressed + 27: function() {}, // do something custom when ESC is pressed + 32: null // don't do anything when SPACE is pressed (i.e. disable a reveal.js default binding) + } +}); +``` + +### 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. + +To enable lazy loading all you need to do is change your "src" attributes to "data-src" as shown below. This is supported for image, video, audio and iframe elements. Lazy loaded iframes will also unload when the containing slide is no longer visible. + +```html +
+ + + +
+``` + + +### API + +The ``Reveal`` object exposes a JavaScript API for controlling navigation and reading state: + +```javascript +// Navigation +Reveal.slide( indexh, indexv, indexf ); +Reveal.left(); +Reveal.right(); +Reveal.up(); +Reveal.down(); +Reveal.prev(); +Reveal.next(); +Reveal.prevFragment(); +Reveal.nextFragment(); + +// Toggle presentation states, optionally pass true/false to force on/off +Reveal.toggleOverview(); +Reveal.togglePause(); +Reveal.toggleAutoSlide(); + +// Change a config value at runtime +Reveal.configure({ controls: true }); + +// Returns the present configuration options +Reveal.getConfig(); + +// Fetch the current scale of the presentation +Reveal.getScale(); + +// Retrieves the previous and current slide elements +Reveal.getPreviousSlide(); +Reveal.getCurrentSlide(); + +Reveal.getIndices(); // { h: 0, v: 0 } } +Reveal.getProgress(); // 0-1 +Reveal.getTotalSlides(); + +// State checks +Reveal.isFirstSlide(); +Reveal.isLastSlide(); +Reveal.isOverview(); +Reveal.isPaused(); +Reveal.isAutoSliding(); +``` + +### Slide Changed Event + +A 'slidechanged' event is fired each time the slide is changed (regardless of state). The event object holds the index values of the current slide as well as a reference to the previous and current slide HTML nodes. + +Some libraries, like MathJax (see [#226](https://github.com/hakimel/reveal.js/issues/226#issuecomment-10261609)), get confused by the transforms and display states of slides. Often times, this can be fixed by calling their update or render function from this callback. + +```javascript +Reveal.addEventListener( 'slidechanged', function( event ) { + // event.previousSlide, event.currentSlide, event.indexh, event.indexv +} ); +``` + +### Presentation State + +The presentation's current state can be fetched by using the `getState` method. A state object contains all of the information required to put the presentation back as it was when `getState` was first called. Sort of like a snapshot. It's a simple object that can easily be stringified and persisted or sent over the wire. + +```javascript +Reveal.slide( 1 ); +// we're on slide 1 + +var state = Reveal.getState(); + +Reveal.slide( 3 ); +// we're on slide 3 + +Reveal.setState( state ); +// we're back on slide 1 +``` + +### Slide States + +If you set ``data-state="somestate"`` on a slide ``
``, "somestate" will be applied as a class on the document element when that slide is opened. This allows you to apply broad style changes to the page based on the active slide. + +Furthermore you can also listen to these changes in state via JavaScript: + +```javascript +Reveal.addEventListener( 'somestate', function() { + // TODO: Sprinkle magic +}, false ); +``` + +### 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. Below are a few examples. + +```html +
+

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.

+
+``` + +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. + + +### Parallax Background + +If you want to use a parallax scrolling background, set the first two config properties below when initializing reveal.js (the other two are optional). + +```javascript +Reveal.initialize({ + + // Parallax background image + parallaxBackgroundImage: '', // e.g. "https://s3.amazonaws.com/hakim-static/reveal-js/reveal-parallax-1.jpg" + + // Parallax background size + parallaxBackgroundSize: '', // CSS syntax, e.g. "2100px 900px" - currently only pixels are supported (don't use % or auto) + + // 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://lab.hakim.se/reveal-js/?parallaxBackgroundImage=https%3A%2F%2Fs3.amazonaws.com%2Fhakim-static%2Freveal-js%2Freveal-parallax-1.jpg¶llaxBackgroundSize=2100px%20900px). + + + +### Slide Transitions +The global presentation transition is set using the ```transition``` config value. You can override the global transition for a specific slide by using the ```data-transition``` attribute: + +```html +
+

This slide will override the presentation transition and zoom!

+
+ +
+

Choose from three transition speeds: default, fast or slow!

+
+``` + +You can also use different in and out transitions for the same slide: + +```html +
+ The train goes on … +
+
+ and on … +
+
+ and stops. +
+
+ (Passengers entering and leaving) +
+
+ And it starts again. +
+``` + + +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 (```
```): + +```html +Link +Link +``` + +You can also add relative navigation links, similar to the built in reveal.js controls, by appending one of the following classes on any element. Note that each element is automatically given an ```enabled``` class when it's a valid navigation route based on the current slide. + +```html + + + + + + +``` + + +### 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: + +```html +
+

grow

+

shrink

+

fade-out

+

visible only once

+

blue only once

+

highlight-red

+

highlight-green

+

highlight-blue

+
+``` + +Multiple fragments can be applied to the same element sequentially by wrapping it, this will fade in the text on the first step and fade it back out on the second. + +```html +
+ + I'll fade in, then out + +
+``` + +The display order of fragments can be controlled using the ```data-fragment-index``` attribute. + +```html +
+

Appears last

+

Appears first

+

Appears second

+
+``` + +### Fragment events + +When a slide fragment is either shown or hidden reveal.js will dispatch an event. + +Some libraries, like MathJax (see #505), get confused by the initially hidden fragment elements. Often times this can be fixed by calling their update or render function from this callback. + +```javascript +Reveal.addEventListener( 'fragmentshown', function( event ) { + // event.fragment = the fragment DOM element +} ); +Reveal.addEventListener( 'fragmenthidden', function( event ) { + // event.fragment = the fragment DOM element +} ); +``` + +### Code syntax highlighting + +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]
+        (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``` configuration value. + +```javascript +// Shows the slide number using default formatting +Reveal.configure({ slideNumber: true }); + +// Slide number formatting can be configured using these variables: +// 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' }); + +``` + + +### Overview mode + +Press "Esc" or "o" keys to toggle the overview mode on and off. While you're in this mode, you can still navigate between slides, +as if you were at 1,000 feet above your presentation. The overview mode comes with a few API hooks: + +```javascript +Reveal.addEventListener( 'overviewshown', function( event ) { /* ... */ } ); +Reveal.addEventListener( 'overviewhidden', function( event ) { /* ... */ } ); + +// Toggle the overview mode programmatically +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 `
+ +
+ +

 

 

 

+ + + + + + +
+

Data Analysis and Machine Learning: Elements of Probability Theory

+ +

+ + +

+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, 2017

+
+

+ + +

Read »

+ + +
+ +

+ +

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

 

 

 

+ + + + +

Domains and probabilities

+
+
+

+Consider the following simple example, namely the tossing of a 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-bs002.html b/doc/pub/Statistics/html/._Statistics-bs002.html new file mode 100644 index 000000000..59c7637ec --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics-bs002.html @@ -0,0 +1,419 @@ + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

 

 

 

+ + + + +

Tossing a dice

+
+
+

+The numbers in the domain are the outcomes of the physical process tossing the 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-bs003.html b/doc/pub/Statistics/html/._Statistics-bs003.html new file mode 100644 index 000000000..04610e1f5 --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics-bs003.html @@ -0,0 +1,400 @@ + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

 

 

 

+ + + + +

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 PDF. +

+
+ + +

+

+ +

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

 

 

 

+ + + + +

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-bs005.html b/doc/pub/Statistics/html/._Statistics-bs005.html new file mode 100644 index 000000000..4d3ae39fe --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics-bs005.html @@ -0,0 +1,416 @@ + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

 

 

 

+ + + + +

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-bs006.html b/doc/pub/Statistics/html/._Statistics-bs006.html new file mode 100644 index 000000000..2a006ca95 --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics-bs006.html @@ -0,0 +1,417 @@ + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

 

 

 

+ + + + +

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-bs007.html b/doc/pub/Statistics/html/._Statistics-bs007.html new file mode 100644 index 000000000..c2cfe86c8 --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics-bs007.html @@ -0,0 +1,423 @@ + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

 

 

 

+ + + + +

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-bs008.html b/doc/pub/Statistics/html/._Statistics-bs008.html new file mode 100644 index 000000000..8829ddcd2 --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics-bs008.html @@ -0,0 +1,422 @@ + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

 

 

 

+ + + + +

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} +$$ + +with +$$ +\begin{equation*} +\begin{array}{ll} +\theta(x)=0 & x < 0 \\ +\theta(x)=\frac{1}{b-a} & \in [a,b]. +\end{array} +\end{equation*} +$$ + +The normal distribution with \( b=1 \) and \( a=0 \) is used to generate random numbers. +

+
+ + +

+

+ +

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

 

 

 

+ + + + +

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-bs010.html b/doc/pub/Statistics/html/._Statistics-bs010.html new file mode 100644 index 000000000..288fc618b --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics-bs010.html @@ -0,0 +1,410 @@ + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

 

 

 

+ + + + +

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-bs011.html b/doc/pub/Statistics/html/._Statistics-bs011.html new file mode 100644 index 000000000..6785d88ba --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics-bs011.html @@ -0,0 +1,425 @@ + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

 

 

 

+ + + + +

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-bs012.html b/doc/pub/Statistics/html/._Statistics-bs012.html new file mode 100644 index 000000000..fc4bb7757 --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics-bs012.html @@ -0,0 +1,423 @@ + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

 

 

 

+ + + + +

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 \frac{1}{N}\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-bs013.html b/doc/pub/Statistics/html/._Statistics-bs013.html new file mode 100644 index 000000000..7d5cf5bf1 --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics-bs013.html @@ -0,0 +1,431 @@ + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

 

 

 

+ + + + +

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\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-bs014.html b/doc/pub/Statistics/html/._Statistics-bs014.html new file mode 100644 index 000000000..11d55fb3e --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics-bs014.html @@ -0,0 +1,431 @@ + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

 

 

 

+ + + + +

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-bs015.html b/doc/pub/Statistics/html/._Statistics-bs015.html new file mode 100644 index 000000000..8b97d8e9c --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics-bs015.html @@ -0,0 +1,422 @@ + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

 

 

 

+ + + + +

Probability Distribution Functions

+
+
+

+With a PDF we can compute expectation values of selected quantities such as + +$$ +\begin{equation*} + \langle x^k\rangle=\frac{1}{N}\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-bs016.html b/doc/pub/Statistics/html/._Statistics-bs016.html new file mode 100644 index 000000000..e01f7c678 --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics-bs016.html @@ -0,0 +1,438 @@ + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

 

 

 

+ + + + +

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-bs017.html b/doc/pub/Statistics/html/._Statistics-bs017.html new file mode 100644 index 000000000..a8b066f94 --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics-bs017.html @@ -0,0 +1,427 @@ + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

 

 

 

+ + + + +

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-bs018.html b/doc/pub/Statistics/html/._Statistics-bs018.html new file mode 100644 index 000000000..acbcca9bf --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics-bs018.html @@ -0,0 +1,430 @@ + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

 

 

 

+ + + + +

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-bs019.html b/doc/pub/Statistics/html/._Statistics-bs019.html new file mode 100644 index 000000000..4f53c5b77 --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics-bs019.html @@ -0,0 +1,417 @@ + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

 

 

 

+ + + + +

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-bs020.html b/doc/pub/Statistics/html/._Statistics-bs020.html new file mode 100644 index 000000000..0102cd1a7 --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics-bs020.html @@ -0,0 +1,424 @@ + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

 

 

 

+ + + + +

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-bs021.html b/doc/pub/Statistics/html/._Statistics-bs021.html new file mode 100644 index 000000000..06fbc96d1 --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics-bs021.html @@ -0,0 +1,447 @@ + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

 

 

 

+ + + + +

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-bs022.html b/doc/pub/Statistics/html/._Statistics-bs022.html new file mode 100644 index 000000000..bbe8fd48a --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics-bs022.html @@ -0,0 +1,424 @@ + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

 

 

 

+ + + + +

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-bs023.html b/doc/pub/Statistics/html/._Statistics-bs023.html new file mode 100644 index 000000000..18c22629e --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics-bs023.html @@ -0,0 +1,415 @@ + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

 

 

 

+ + + + +

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-bs024.html b/doc/pub/Statistics/html/._Statistics-bs024.html new file mode 100644 index 000000000..7972eacb6 --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics-bs024.html @@ -0,0 +1,428 @@ + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

 

 

 

+ + + + +

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-bs025.html b/doc/pub/Statistics/html/._Statistics-bs025.html new file mode 100644 index 000000000..8c872d838 --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics-bs025.html @@ -0,0 +1,413 @@ + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

 

 

 

+ + + + +

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-bs026.html b/doc/pub/Statistics/html/._Statistics-bs026.html new file mode 100644 index 000000000..cb4f5f201 --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics-bs026.html @@ -0,0 +1,426 @@ + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

 

 

 

+ + + + +

Meet the covariance, uncorrelated events

+
+
+

+ +

+This is easy to show, keeping in mind the linearity of +the expectation value. Consider the stochastic variables \( X_i \) and +\( X_j \), (\( i\neq j \)) +$$ +\begin{align*} +\mathrm{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, we get +$$ +\langle x_i x_j\rangle = +\langle x_i\rangle\langle x_j\rangle=\mathrm{Cov}(X_i, X_j) = 0\ \ (i\neq j). +$$ +

+
+ + +

+

+ +

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

 

 

 

+ + + + +

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-bs028.html b/doc/pub/Statistics/html/._Statistics-bs028.html new file mode 100644 index 000000000..b5408a263 --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics-bs028.html @@ -0,0 +1,416 @@ + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

 

 

 

+ + + + +

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-bs029.html b/doc/pub/Statistics/html/._Statistics-bs029.html new file mode 100644 index 000000000..06d507fd9 --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics-bs029.html @@ -0,0 +1,420 @@ + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

 

 

 

+ + + + +

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-bs030.html b/doc/pub/Statistics/html/._Statistics-bs030.html new file mode 100644 index 000000000..0d142a105 --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics-bs030.html @@ -0,0 +1,429 @@ + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

 

 

 

+ + + + +

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-bs031.html b/doc/pub/Statistics/html/._Statistics-bs031.html new file mode 100644 index 000000000..cee45286d --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics-bs031.html @@ -0,0 +1,420 @@ + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

 

 

 

+ + + + +

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-bs032.html b/doc/pub/Statistics/html/._Statistics-bs032.html new file mode 100644 index 000000000..33f8b6f4a --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics-bs032.html @@ -0,0 +1,424 @@ + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

 

 

 

+ + + + +

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-bs033.html b/doc/pub/Statistics/html/._Statistics-bs033.html new file mode 100644 index 000000000..faffc309f --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics-bs033.html @@ -0,0 +1,429 @@ + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

 

 

 

+ + + + +

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-bs034.html b/doc/pub/Statistics/html/._Statistics-bs034.html new file mode 100644 index 000000000..732e44513 --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics-bs034.html @@ -0,0 +1,418 @@ + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

 

 

 

+ + + + +

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-bs035.html b/doc/pub/Statistics/html/._Statistics-bs035.html new file mode 100644 index 000000000..fde1961f4 --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics-bs035.html @@ -0,0 +1,424 @@ + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

 

 

 

+ + + + +

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-bs036.html b/doc/pub/Statistics/html/._Statistics-bs036.html new file mode 100644 index 000000000..7ab87bc0c --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics-bs036.html @@ -0,0 +1,418 @@ + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

 

 

 

+ + + + +

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-bs037.html b/doc/pub/Statistics/html/._Statistics-bs037.html new file mode 100644 index 000000000..2c128d7db --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics-bs037.html @@ -0,0 +1,433 @@ + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

 

 

 

+ + + + +

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-bs038.html b/doc/pub/Statistics/html/._Statistics-bs038.html new file mode 100644 index 000000000..7f801e08d --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics-bs038.html @@ -0,0 +1,422 @@ + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

 

 

 

+ + + + +

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-bs039.html b/doc/pub/Statistics/html/._Statistics-bs039.html new file mode 100644 index 000000000..2ea8141f5 --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics-bs039.html @@ -0,0 +1,416 @@ + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

 

 

 

+ + + + +

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-bs040.html b/doc/pub/Statistics/html/._Statistics-bs040.html new file mode 100644 index 000000000..bbcc2b268 --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics-bs040.html @@ -0,0 +1,419 @@ + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

 

 

 

+ + + + +

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-bs041.html b/doc/pub/Statistics/html/._Statistics-bs041.html new file mode 100644 index 000000000..9e1fa24d1 --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics-bs041.html @@ -0,0 +1,428 @@ + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

 

 

 

+ + + + +

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-bs042.html b/doc/pub/Statistics/html/._Statistics-bs042.html new file mode 100644 index 000000000..83c042302 --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics-bs042.html @@ -0,0 +1,433 @@ + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

 

 

 

+ + + + +

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-bs043.html b/doc/pub/Statistics/html/._Statistics-bs043.html new file mode 100644 index 000000000..6a05cf21c --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics-bs043.html @@ -0,0 +1,417 @@ + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

 

 

 

+ + + + +

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-bs044.html b/doc/pub/Statistics/html/._Statistics-bs044.html new file mode 100644 index 000000000..031900f30 --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics-bs044.html @@ -0,0 +1,427 @@ + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

 

 

 

+ + + + +

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-bs045.html b/doc/pub/Statistics/html/._Statistics-bs045.html new file mode 100644 index 000000000..c83917d2e --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics-bs045.html @@ -0,0 +1,424 @@ + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

 

 

 

+ + + + +

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-bs046.html b/doc/pub/Statistics/html/._Statistics-bs046.html new file mode 100644 index 000000000..fca7ec1fa --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics-bs046.html @@ -0,0 +1,440 @@ + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

 

 

 

+ + + + +

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-bs047.html b/doc/pub/Statistics/html/._Statistics-bs047.html new file mode 100644 index 000000000..9fc1b3991 --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics-bs047.html @@ -0,0 +1,417 @@ + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

 

 

 

+ + + + +

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-bs048.html b/doc/pub/Statistics/html/._Statistics-bs048.html new file mode 100644 index 000000000..f9156b9a9 --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics-bs048.html @@ -0,0 +1,430 @@ + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

 

 

 

+ + + + +

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-bs049.html b/doc/pub/Statistics/html/._Statistics-bs049.html new file mode 100644 index 000000000..0981399ac --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics-bs049.html @@ -0,0 +1,416 @@ + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

 

 

 

+ + + + +

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-bs050.html b/doc/pub/Statistics/html/._Statistics-bs050.html new file mode 100644 index 000000000..e3ef9a6f8 --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics-bs050.html @@ -0,0 +1,434 @@ + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

 

 

 

+ + + + +

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-bs051.html b/doc/pub/Statistics/html/._Statistics-bs051.html new file mode 100644 index 000000000..bcf396539 --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics-bs051.html @@ -0,0 +1,418 @@ + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

 

 

 

+ + + + +

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-bs052.html b/doc/pub/Statistics/html/._Statistics-bs052.html new file mode 100644 index 000000000..a966bd0ae --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics-bs052.html @@ -0,0 +1,415 @@ + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

 

 

 

+ + + + +

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-bs053.html b/doc/pub/Statistics/html/._Statistics-bs053.html new file mode 100644 index 000000000..cde9e4711 --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics-bs053.html @@ -0,0 +1,428 @@ + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

 

 

 

+ + + + +

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-bs054.html b/doc/pub/Statistics/html/._Statistics-bs054.html new file mode 100644 index 000000000..35080b1c2 --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics-bs054.html @@ -0,0 +1,428 @@ + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

 

 

 

+ + + + +

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-bs055.html b/doc/pub/Statistics/html/._Statistics-bs055.html new file mode 100644 index 000000000..b096a8437 --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics-bs055.html @@ -0,0 +1,424 @@ + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

 

 

 

+ + + + +

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-bs056.html b/doc/pub/Statistics/html/._Statistics-bs056.html new file mode 100644 index 000000000..6a67e2324 --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics-bs056.html @@ -0,0 +1,468 @@ + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

 

 

 

+ + + + +

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-bs057.html b/doc/pub/Statistics/html/._Statistics-bs057.html new file mode 100644 index 000000000..2e69c0824 --- /dev/null +++ b/doc/pub/Statistics/html/._Statistics-bs057.html @@ -0,0 +1,418 @@ + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

 

 

 

+ + + + +

Correlation function and which random number generators should I use

+
+
+

+The following Python code plots the results for the correlation function from the above program. +

+ + +

+

+

+
+ + +

+

+ +

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

 

 

 

+ + + + +

Which RNG should I use?

+
+
+

+ +

    +
  • In the library files lib.cpp and lib.h we have included four popular RNGs taken from the widely used textbook Numerical Recipes. These are called ran0, ran1, ran2 and ran3.
  • +
  • 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} \).
  • +
+
+
+ + +

+

+ +

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

 

 

 

+ + + + +

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-bs.html b/doc/pub/Statistics/html/Statistics-bs.html new file mode 100644 index 000000000..9906ee0da --- /dev/null +++ b/doc/pub/Statistics/html/Statistics-bs.html @@ -0,0 +1,413 @@ + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

 

 

 

+ + + + + + +
+

Data Analysis and Machine Learning: Elements of Probability Theory

+ +

+ + +

+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, 2017

+
+

+ + +

Read »

+ + +
+ +

+ +

+ + +
+ + + + + + + +
+ © 1999-2017, 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 new file mode 100644 index 000000000..f4b2ed766 --- /dev/null +++ b/doc/pub/Statistics/html/Statistics-reveal.html @@ -0,0 +1,2245 @@ + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + +
+ + + + + + + + + + + + + + +
+ + + + +

Data Analysis and Machine Learning: Elements of Probability Theory

+ +

+ + +

+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, 2017

+
+

+ +

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

Domains and probabilities

+
+ +

+Consider the following simple example, namely the tossing of a 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*} +$$ +

 
+

+
+ + +
+

Tossing a dice

+
+ +

+The numbers in the domain are the outcomes of the physical process tossing the 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*} +$$ +

 
+

+
+ + +
+

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 PDF. +

+
+ + +
+

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*} +$$ +

 
+

+
+ + +
+

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. +

+
+ + +
+

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*} +$$ +

 
+

+
+ + +
+

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*} +$$ +

 
+

+
+ + +
+

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} +$$ +

 
+ +with +

 
+$$ +\begin{equation*} +\begin{array}{ll} +\theta(x)=0 & x < 0 \\ +\theta(x)=\frac{1}{b-a} & \in [a,b]. +\end{array} +\end{equation*} +$$ +

 
+ +The normal distribution with \( b=1 \) and \( a=0 \) is used to generate random numbers. +

+
+ + +
+

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 \). +

+ + +

+ +
+
+ + +
+

Exponential distribution

+
+ +

+Another important distribution in science is the exponential distribution +

 
+$$ +\begin{equation*} +p(x) = \alpha\exp{-(\alpha x)}. +\end{equation*} +$$ +

 
+

+
+ + +
+

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*} +$$ +

 
+

+
+ + +
+

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 \frac{1}{N}\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) \). +

+
+ + +
+

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\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. +

+
+ + +
+

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 \)
+ +

+
+ + +
+

Probability Distribution Functions

+
+ +

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

 
+$$ +\begin{equation*} + \langle x^k\rangle=\frac{1}{N}\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 \). +

+
+ + +
+

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*} +$$ +

 
+

+ + +
+

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*} +$$ +

 
+

+
+ + +
+

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} +$$ +

 
+

+
+ + +
+

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. +

+
+ + +
+

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 \).
  • +
+
+
+ + +
+

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) \). +
+ + +
+

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 \). +

+
+ + +
+

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*} +$$ +

 
+

+
+ + +
+

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*} +$$ +

 
+

+
+ + +
+

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. +

+
+ + +
+

Meet the covariance, uncorrelated events

+
+ +

+This is easy to show, keeping in mind the linearity of +the expectation value. Consider the stochastic variables \( X_i \) and +\( X_j \), (\( i\neq j \)) +

 
+$$ +\begin{align*} +\mathrm{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, we get +

 
+$$ +\langle x_i x_j\rangle = +\langle x_i\rangle\langle x_j\rangle=\mathrm{Cov}(X_i, X_j) = 0\ \ (i\neq j). +$$ +

 
+

+
+ + +
+

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*} +$$ +

 
+

+
+ + +
+

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} \). +

+
+ + +
+

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. +

+
+ + +
+

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} +$$ +

 
+

+
+ + +
+

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) \). +

+
+ + +
+

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. +

+
+ + +
+

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 \). +

+
+ + +
+

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. +

+
+ + +
+

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*} +$$ +

 
+

+
+ + +
+

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 \). +

+
+ + +
+

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. +

+
+ + +
+

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. + +

+
+ + +
+

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. +

+
+ + +
+

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.
  • +
+
+
+ + +
+

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 \). +

+
+ + +
+

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 \). +

+
+ + +
+

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*} +$$ +

 
+

+
+ + +
+

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} \). +

+
+ + +
+

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 \). +

+
+ + +
+

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 \). +

+
+ + +
+

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 \). +

+
+ + +
+

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} +$$ +

 
+

+
+ + +
+

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 \). +

+
+ + +
+

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() 
+
+ +
+
+ + +
+

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 \). +

+
+ + +
+

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*} +$$ +

 
+

+
+ + +
+

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
+ +

+
+ + +
+

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. +

+ + +

+ +
+
+ + +
+

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. + + +

+
+ + +
+

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 
+
+ +
+
+ + +
+

Correlation function and which random number generators should I use

+
+ +

+The following Python code plots the results for the correlation function from the above program. +

+ + +

+ +
+
+ + +
+

Which RNG should I use?

+
+ +
    +

  • In the library files lib.cpp and lib.h we have included four popular RNGs taken from the widely used textbook Numerical Recipes. These are called ran0, ran1, ran2 and ran3.
  • +

  • 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} \).
  • +
+
+
+ + +
+

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-solarized.html b/doc/pub/Statistics/html/Statistics-solarized.html new file mode 100644 index 000000000..4794ac137 --- /dev/null +++ b/doc/pub/Statistics/html/Statistics-solarized.html @@ -0,0 +1,2162 @@ + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Data Analysis and Machine Learning: Elements of Probability Theory

+ +

+ + +

+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, 2017

+
+

+









+ +

Domains and probabilities

+
+ +

+Consider the following simple example, namely the tossing of a 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*} +$$ +

+ + +

+









+ +

Tossing a dice

+
+ +

+The numbers in the domain are the outcomes of the physical process tossing the 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*} +$$ +

+ + +

+









+ +

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 PDF. +

+ + +

+









+ +

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*} +$$ +

+ + +

+









+ +

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. +

+ + +

+









+ +

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*} +$$ +

+ + +

+









+ +

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*} +$$ +

+ + +

+









+ +

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), +\label{eq:unifromPDF} +\end{equation} +$$ + +with +$$ +\begin{equation*} +\begin{array}{ll} +\theta(x)=0 & x < 0 \\ +\theta(x)=\frac{1}{b-a} & \in [a,b]. +\end{array} +\end{equation*} +$$ + +The normal distribution with \( b=1 \) and \( a=0 \) is used to generate random numbers. +

+ + +

+









+ +

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 \). +

+ + +

+ +
+ + +

+









+ +

Exponential distribution

+
+ +

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

+ + +

+









+ +

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 +\label{eq:expectation_value_of_h_wrt_p} +\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*} +$$ +

+ + +

+









+ +

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 \frac{1}{N}\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) \). +

+ + +

+









+ +

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\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. +

+ + +

+









+ +

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 \)
+ +

+ + +

+









+ +

Probability Distribution Functions

+
+ +

+With a PDF we can compute expectation values of selected quantities such as + +$$ +\begin{equation*} + \langle x^k\rangle=\frac{1}{N}\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 \). +

+ + +

+









+ +

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*} +$$ + +

+









+ +

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*} +$$ +

+ + +

+









+ +

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)}. +\label{_auto1} +\end{equation} +$$ +

+ + +

+









+ +

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. +

+ + +

+









+ +

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 \).
  • +
+
+ + +

+









+ +

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) \). + +

+









+ +

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 \). +

+ + +

+









+ +

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*} +$$ +

+ + +

+









+ +

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 +\label{_auto2}\\ +&=\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, +\label{eq:def_covariance} +\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*} +$$ +

+ + +

+









+ +

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. +

+ + +

+









+ +

Meet the covariance, uncorrelated events

+
+ +

+ +

+This is easy to show, keeping in mind the linearity of +the expectation value. Consider the stochastic variables \( X_i \) and +\( X_j \), (\( i\neq j \)) +$$ +\begin{align*} +\mathrm{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, we get +$$ +\langle x_i x_j\rangle = +\langle x_i\rangle\langle x_j\rangle=\mathrm{Cov}(X_i, X_j) = 0\ \ (i\neq j). +$$ +

+ + +

+









+ +

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*} +$$ +

+ + +

+









+ +

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} \). +

+ + +

+









+ +

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. +

+ + +

+









+ +

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}, +\label{eq:exptmean} +\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). +\label{eq:exptvariance} +\end{equation} +$$ +

+ + +

+









+ +

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. +\label{eq:sampleexptvariance} +\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) \). +

+ + +

+









+ +

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. +

+ + +

+









+ +

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. \eqref{eq:exptvariance} +$$ +\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 \). +

+ + +

+









+ +

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. +

+ + +

+









+ +

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*} +$$ +

+ + +

+









+ +

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} +\label{eq:autocorrelformal} +\end{equation} +$$ + +which gives us a useful measure of the correlation pair correlation +starting always at \( 1 \) for \( d=0 \). +

+ + +

+









+ +

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 +\label{eq:error_estimate_corr_time} +\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 +\label{eq:autocorrelation_time} +\end{equation} +$$ + + + +For a correlation free experiment, \( \tau \) +equals 1. +

+ + +

+









+ +

Definition of Correlation Functions and Standard Deviation

+
+ +

+From the point of view of +Eq. \eqref{eq:error_estimate_corr_time} 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. + +

+ + +

+









+ +

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. +

+ + +

+









+ +

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.
  • +
+
+ + +

+









+ +

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 \). +

+ + +

+









+ +

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 \). +

+ + +

+









+ +

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*} +$$ +

+ + +

+









+ +

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), +\label{eq:mz1} +\end{equation} +$$ + +followed by +$$ +\begin{equation} + N_l=(69069N_{l-1}+1013904243)\mathrm{MOD}(2^{32}), +\label{eq:mz2} +\end{equation} +$$ + +which according to the authors has a period larger than \( 2^{94} \). +

+ + +

+









+ +

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 \). +

+ + +

+









+ +

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 \). +

+ + +

+









+ +

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), +\label{eq:rntrick1} +\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 \). +

+ + +

+









+ +

Random number generator RNG, RAN0

+
+ +

+We can now rewrite Eq. \eqref{eq:rntrick1} as + +$$ +\begin{equation} +(aN_{i-1}) \mathrm{MOD} (M)= (aN_{i-1}-[N_{i-1}/q](aq+r))\mathrm{MOD} (M), +\label{eq:rntrick2} +\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), +\label{eq:rntrick3} +\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). +\label{eq:rntrick4} +\end{equation} +$$ +

+ + +

+









+ +

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 \). +

+ + +

+









+ +

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() 
+
+ +
+ + +

+









+ +

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 \). +

+ + +

+









+ +

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*} +$$ +

+ + +

+









+ +

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
+ +

+ + +

+









+ +

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. +

+ + +

+ +
+ + +

+









+ +

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. \eqref{eq:autocorrelformal}. +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. + + +

+ + +

+









+ +

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 
+
+ +
+ + +

+









+ +

Correlation function and which random number generators should I use

+
+ +

+The following Python code plots the results for the correlation function from the above program. +

+ + +

+ +
+ + +

+









+ +

Which RNG should I use?

+
+ +

+ +

    +
  • In the library files lib.cpp and lib.h we have included four popular RNGs taken from the widely used textbook Numerical Recipes. These are called ran0, ran1, ran2 and ran3.
  • +
  • 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} \).
  • +
+
+ + +

+









+ +

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);
+
+ +
+ + +

+ + + + +

+ © 1999-2017, 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 new file mode 100644 index 000000000..6aaebcdc0 --- /dev/null +++ b/doc/pub/Statistics/html/Statistics.html @@ -0,0 +1,2167 @@ + + + + + + + +Data Analysis and Machine Learning: Elements of Probability Theory + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Data Analysis and Machine Learning: Elements of Probability Theory

+ +

+ + +

+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, 2017

+
+

+









+ +

Domains and probabilities

+
+ +

+Consider the following simple example, namely the tossing of a 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*} +$$ +

+ + +

+









+ +

Tossing a dice

+
+ +

+The numbers in the domain are the outcomes of the physical process tossing the 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*} +$$ +

+ + +

+









+ +

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 PDF. +

+ + +

+









+ +

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*} +$$ +

+ + +

+









+ +

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. +

+ + +

+









+ +

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*} +$$ +

+ + +

+









+ +

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*} +$$ +

+ + +

+









+ +

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), +\label{eq:unifromPDF} +\end{equation} +$$ + +with +$$ +\begin{equation*} +\begin{array}{ll} +\theta(x)=0 & x < 0 \\ +\theta(x)=\frac{1}{b-a} & \in [a,b]. +\end{array} +\end{equation*} +$$ + +The normal distribution with \( b=1 \) and \( a=0 \) is used to generate random numbers. +

+ + +

+









+ +

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 \). +

+ + +

+ +
+ + +

+









+ +

Exponential distribution

+
+ +

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

+ + +

+









+ +

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 +\label{eq:expectation_value_of_h_wrt_p} +\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*} +$$ +

+ + +

+









+ +

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 \frac{1}{N}\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) \). +

+ + +

+









+ +

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\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. +

+ + +

+









+ +

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 \)
+ +

+ + +

+









+ +

Probability Distribution Functions

+
+ +

+With a PDF we can compute expectation values of selected quantities such as + +$$ +\begin{equation*} + \langle x^k\rangle=\frac{1}{N}\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 \). +

+ + +

+









+ +

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*} +$$ + +

+









+ +

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*} +$$ +

+ + +

+









+ +

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)}. +\label{_auto1} +\end{equation} +$$ +

+ + +

+









+ +

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. +

+ + +

+









+ +

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 \).
  • +
+
+ + +

+









+ +

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) \). + +

+









+ +

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 \). +

+ + +

+









+ +

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*} +$$ +

+ + +

+









+ +

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 +\label{_auto2}\\ +&=\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, +\label{eq:def_covariance} +\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*} +$$ +

+ + +

+









+ +

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. +

+ + +

+









+ +

Meet the covariance, uncorrelated events

+
+ +

+ +

+This is easy to show, keeping in mind the linearity of +the expectation value. Consider the stochastic variables \( X_i \) and +\( X_j \), (\( i\neq j \)) +$$ +\begin{align*} +\mathrm{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, we get +$$ +\langle x_i x_j\rangle = +\langle x_i\rangle\langle x_j\rangle=\mathrm{Cov}(X_i, X_j) = 0\ \ (i\neq j). +$$ +

+ + +

+









+ +

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*} +$$ +

+ + +

+









+ +

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} \). +

+ + +

+









+ +

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. +

+ + +

+









+ +

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}, +\label{eq:exptmean} +\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). +\label{eq:exptvariance} +\end{equation} +$$ +

+ + +

+









+ +

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. +\label{eq:sampleexptvariance} +\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) \). +

+ + +

+









+ +

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. +

+ + +

+









+ +

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. \eqref{eq:exptvariance} +$$ +\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 \). +

+ + +

+









+ +

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. +

+ + +

+









+ +

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*} +$$ +

+ + +

+









+ +

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} +\label{eq:autocorrelformal} +\end{equation} +$$ + +which gives us a useful measure of the correlation pair correlation +starting always at \( 1 \) for \( d=0 \). +

+ + +

+









+ +

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 +\label{eq:error_estimate_corr_time} +\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 +\label{eq:autocorrelation_time} +\end{equation} +$$ + + + +For a correlation free experiment, \( \tau \) +equals 1. +

+ + +

+









+ +

Definition of Correlation Functions and Standard Deviation

+
+ +

+From the point of view of +Eq. \eqref{eq:error_estimate_corr_time} 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. + +

+ + +

+









+ +

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. +

+ + +

+









+ +

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.
  • +
+
+ + +

+









+ +

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 \). +

+ + +

+









+ +

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 \). +

+ + +

+









+ +

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*} +$$ +

+ + +

+









+ +

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), +\label{eq:mz1} +\end{equation} +$$ + +followed by +$$ +\begin{equation} + N_l=(69069N_{l-1}+1013904243)\mathrm{MOD}(2^{32}), +\label{eq:mz2} +\end{equation} +$$ + +which according to the authors has a period larger than \( 2^{94} \). +

+ + +

+









+ +

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 \). +

+ + +

+









+ +

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 \). +

+ + +

+









+ +

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), +\label{eq:rntrick1} +\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 \). +

+ + +

+









+ +

Random number generator RNG, RAN0

+
+ +

+We can now rewrite Eq. \eqref{eq:rntrick1} as + +$$ +\begin{equation} +(aN_{i-1}) \mathrm{MOD} (M)= (aN_{i-1}-[N_{i-1}/q](aq+r))\mathrm{MOD} (M), +\label{eq:rntrick2} +\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), +\label{eq:rntrick3} +\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). +\label{eq:rntrick4} +\end{equation} +$$ +

+ + +

+









+ +

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 \). +

+ + +

+









+ +

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() 
+
+ +
+ + +

+









+ +

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 \). +

+ + +

+









+ +

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*} +$$ +

+ + +

+









+ +

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
+ +

+ + +

+









+ +

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. +

+ + +

+ +
+ + +

+









+ +

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. \eqref{eq:autocorrelformal}. +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. + + +

+ + +

+









+ +

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 
+
+ +
+ + +

+









+ +

Correlation function and which random number generators should I use

+
+ +

+The following Python code plots the results for the correlation function from the above program. +

+ + +

+ +
+ + +

+









+ +

Which RNG should I use?

+
+ +

+ +

    +
  • In the library files lib.cpp and lib.h we have included four popular RNGs taken from the widely used textbook Numerical Recipes. These are called ran0, ran1, ran2 and ran3.
  • +
  • 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} \).
  • +
+
+ + +

+









+ +

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);
+
+ +
+ + +

+ + + + +

+ © 1999-2017, 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 new file mode 100644 index 000000000..a5df3133d --- /dev/null +++ b/doc/pub/Statistics/html/reveal.js/.gitignore @@ -0,0 +1,8 @@ +.DS_Store +.svn +log/*.log +tmp/** +node_modules/ +.sass-cache +css/reveal.min.css +js/reveal.min.js diff --git a/doc/pub/Statistics/html/reveal.js/.travis.yml b/doc/pub/Statistics/html/reveal.js/.travis.yml new file mode 100644 index 000000000..165d9ae9f --- /dev/null +++ b/doc/pub/Statistics/html/reveal.js/.travis.yml @@ -0,0 +1,5 @@ +language: node_js +node_js: + - 0.10 +before_script: + - npm install -g grunt-cli \ No newline at end of file diff --git a/doc/pub/Statistics/html/reveal.js/CONTRIBUTING.md b/doc/pub/Statistics/html/reveal.js/CONTRIBUTING.md new file mode 100644 index 000000000..c2091e88f --- /dev/null +++ b/doc/pub/Statistics/html/reveal.js/CONTRIBUTING.md @@ -0,0 +1,23 @@ +## Contributing + +Please keep the [issue tracker](http://github.com/hakimel/reveal.js/issues) limited to **bug reports**, **feature requests** and **pull requests**. + + +### Personal Support +If you have personal support or setup questions the best place to ask those are [StackOverflow](http://stackoverflow.com/questions/tagged/reveal.js). + + +### Bug Reports +When reporting a bug make sure to include information about which browser and operating system you are on as well as the necessary steps to reproduce the issue. If possible please include a link to a sample presentation where the bug can be tested. + + +### Pull Requests +- Should follow the coding style of the file you work in, most importantly: + - Tabs to indent + - Single-quoted strings +- Should be made towards the **dev branch** +- Should be submitted from a feature/topic branch (not your master) + + +### Plugins +Please do not submit plugins as pull requests. They should be maintained in their own separate repository. More information here: https://github.com/hakimel/reveal.js/wiki/Plugin-Guidelines diff --git a/doc/pub/Statistics/html/reveal.js/Gruntfile.js b/doc/pub/Statistics/html/reveal.js/Gruntfile.js new file mode 100644 index 000000000..b257e8f32 --- /dev/null +++ b/doc/pub/Statistics/html/reveal.js/Gruntfile.js @@ -0,0 +1,140 @@ +/* global module:false */ +module.exports = function(grunt) { + var port = grunt.option('port') || 8000; + // Project configuration + grunt.initConfig({ + pkg: grunt.file.readJSON('package.json'), + meta: { + banner: + '/*!\n' + + ' * reveal.js <%= pkg.version %> (<%= grunt.template.today("yyyy-mm-dd, HH:MM") %>)\n' + + ' * http://lab.hakim.se/reveal-js\n' + + ' * MIT licensed\n' + + ' *\n' + + ' * Copyright (C) 2014 Hakim El Hattab, http://hakim.se\n' + + ' */' + }, + + qunit: { + files: [ 'test/*.html' ] + }, + + uglify: { + options: { + banner: '<%= meta.banner %>\n' + }, + build: { + src: 'js/reveal.js', + dest: 'js/reveal.min.js' + } + }, + + cssmin: { + compress: { + files: { + 'css/reveal.min.css': [ 'css/reveal.css' ] + } + } + }, + + sass: { + main: { + files: { + 'css/theme/darkgray.css': 'css/theme/source/darkgray.scss', + 'css/theme/beigesmall.css': 'css/theme/source/beigesmall.scss', + 'css/theme/cbc.css': 'css/theme/source/cbc.scss', + 'css/theme/default.css': 'css/theme/source/default.scss', + 'css/theme/beige.css': 'css/theme/source/beige.scss', + 'css/theme/night.css': 'css/theme/source/night.scss', + 'css/theme/serif.css': 'css/theme/source/serif.scss', + 'css/theme/simple.css': 'css/theme/source/simple.scss', + 'css/theme/sky.css': 'css/theme/source/sky.scss', + 'css/theme/moon.css': 'css/theme/source/moon.scss', + 'css/theme/solarized.css': 'css/theme/source/solarized.scss', + 'css/theme/blood.css': 'css/theme/source/blood.scss' + } + } + }, + + jshint: { + options: { + curly: false, + eqeqeq: true, + immed: true, + latedef: true, + newcap: true, + noarg: true, + sub: true, + undef: true, + eqnull: true, + browser: true, + expr: true, + globals: { + head: false, + module: false, + console: false, + unescape: false + } + }, + files: [ 'Gruntfile.js', 'js/reveal.js' ] + }, + + connect: { + server: { + options: { + port: port, + base: '.' + } + } + }, + + zip: { + 'reveal-js-presentation.zip': [ + 'index.html', + 'css/**', + 'js/**', + 'lib/**', + 'images/**', + 'plugin/**' + ] + }, + + watch: { + main: { + files: [ 'Gruntfile.js', 'js/reveal.js', 'css/reveal.css' ], + tasks: 'default' + }, + theme: { + files: [ 'css/theme/source/*.scss', 'css/theme/template/*.scss' ], + tasks: 'themes' + } + } + + }); + + // Dependencies + grunt.loadNpmTasks( 'grunt-contrib-qunit' ); + grunt.loadNpmTasks( 'grunt-contrib-jshint' ); + grunt.loadNpmTasks( 'grunt-contrib-cssmin' ); + grunt.loadNpmTasks( 'grunt-contrib-uglify' ); + grunt.loadNpmTasks( 'grunt-contrib-watch' ); + grunt.loadNpmTasks( 'grunt-contrib-sass' ); + grunt.loadNpmTasks( 'grunt-contrib-connect' ); + grunt.loadNpmTasks( 'grunt-zip' ); + + // Default task + grunt.registerTask( 'default', [ 'jshint', 'cssmin', 'uglify', 'qunit' ] ); + + // Theme task + grunt.registerTask( 'themes', [ 'sass' ] ); + + // Package presentation to archive + grunt.registerTask( 'package', [ 'default', 'zip' ] ); + + // Serve presentation locally + grunt.registerTask( 'serve', [ 'connect', 'watch' ] ); + + // Run tests + grunt.registerTask( 'test', [ 'jshint', 'qunit' ] ); + +}; diff --git a/doc/pub/Statistics/html/reveal.js/LICENSE b/doc/pub/Statistics/html/reveal.js/LICENSE new file mode 100644 index 000000000..09623076f --- /dev/null +++ b/doc/pub/Statistics/html/reveal.js/LICENSE @@ -0,0 +1,19 @@ +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 +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. \ No newline at end of file diff --git a/doc/pub/Statistics/html/reveal.js/README.md b/doc/pub/Statistics/html/reveal.js/README.md new file mode 100644 index 000000000..573b19597 --- /dev/null +++ b/doc/pub/Statistics/html/reveal.js/README.md @@ -0,0 +1,1052 @@ +# 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://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). 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. + + +#### 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. +- [Plugins](https://github.com/hakimel/reveal.js/wiki/Plugins,-Tools-and-Hardware): A list of plugins that can be used to extend reveal.js. + +## 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 [http://slides.com](http://slides.com). + + +## Instructions + +### Markup + +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 +
+
+
Single Horizontal Slide
+
+
Vertical Slide 1
+
Vertical Slide 2
+
+
+
+``` + +### 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-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). + +```html +
+
+``` + +#### Element Attributes + +Special syntax (in html comment) is available for adding attributes to Markdown elements. This is useful for fragments, amongst other things. + +```html +
+ +
+``` + +#### Slide Attributes + +Special syntax (in html comment) is available for adding attributes to the slide `
` elements generated by your Markdown. + +```html +
+ +
+``` + + +### Configuration + +At the end of your page you need to initialize reveal by running the following code. Note that all config values are optional and will default as specified below. + +```javascript +Reveal.initialize({ + + // Display controls in the bottom right corner + controls: true, + + // Display a presentation progress bar + progress: true, + + // Display the page number of the current slide + slideNumber: false, + + // Push each slide change to the browser history + history: false, + + // Enable keyboard shortcuts for navigation + keyboard: true, + + // Enable the slide overview mode + overview: true, + + // Vertical centering of slides + center: true, + + // Enables touch navigation on devices with touch input + touch: true, + + // Loop the presentation + loop: false, + + // Change the presentation direction to be RTL + rtl: false, + + // Turns fragments on and off globally + fragments: true, + + // Flags if the presentation is running in an embedded mode, + // i.e. contained within a limited portion of the screen + embedded: false, + + // Flags if we should show a help overlay when the questionmark + // key is pressed + help: true, + + // 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 + autoSlide: 0, + + // Stop auto-sliding after user input + autoSlideStoppable: true, + + // Enable slide navigation via mouse wheel + mouseWheel: false, + + // Hides the address bar on mobile devices + hideAddressBar: true, + + // Opens links in an iframe preview overlay + previewLinks: false, + + // Transition style + transition: 'default', // none/fade/slide/convex/concave/zoom + + // Transition speed + transitionSpeed: 'default', // default/fast/slow + + // Transition style for full page slide backgrounds + backgroundTransition: 'default', // none/fade/slide/convex/concave/zoom + + // Number of slides away from the current that are visible + viewDistance: 3, + + // Parallax background image + parallaxBackgroundImage: '', // e.g. "'https://s3.amazonaws.com/hakim-static/reveal-js/reveal-parallax-1.jpg'" + + // Parallax background size + parallaxBackgroundSize: '', // CSS syntax, e.g. "2100px 900px" + + // Amount to move parallax background (horizontal and vertical) on slide change + // Number, e.g. 100 + parallaxBackgroundHorizontal: '', + parallaxBackgroundVertical: '' + +}); +``` + + +The configuration can be updated after initialization using the ```configure``` method: + +```javascript +// Turn autoSlide off +Reveal.configure({ autoSlide: 0 }); + +// Start auto-sliding every 5s +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. + +See below for a list of configuration options related to sizing, including default values: + +```javascript +Reveal.initialize({ + + ... + + // The "normal" size of the presentation, aspect ratio will be preserved + // when the presentation is scaled to fit different resolutions. Can be + // specified using percentage units. + width: 960, + height: 700, + + // Factor of the display size that should remain empty around the content + margin: 0.1, + + // Bounds for smallest/largest possible scale to apply to content + minScale: 0.2, + maxScale: 1.5 + +}); +``` + + +### Auto-sliding + +Presentations can be configured to progress through slides automatically, without any user input. To enable this you will need to tell the framework how many milliseconds it should wait between slides: + +```javascript +// Slide every five seconds +Reveal.configure({ + autoSlide: 5000 +}); +``` +When this is turned on a control element will appear that enables users to pause and resume auto-sliding. Alternatively, sliding can be paused or resumed by pressing »a« on the keyboard. Sliding is paused automatically as soon as the user starts navigating. You can disable these controls by specifying ```autoSlideStoppable: false``` in your reveal.js config. + +You can also override the slide duration for individual slides and fragments by using the ```data-autoslide``` attribute: + +```html +
+

After 2 seconds the first fragment will be shown.

+

After 10 seconds the next fragment will be shown.

+

Now, the fragment is displayed for 2 seconds before the next slide is shown.

+
+``` + +Whenever the auto-slide mode is resumed or paused the ```autoslideresumed``` and ```autoslidepaused``` events are fired. + + +### Keyboard Bindings + +If you're unhappy with any of the default keyboard bindings you can override them using the ```keyboard``` config option: + +```javascript +Reveal.configure({ + keyboard: { + 13: 'next', // go to the next slide when the ENTER key is pressed + 27: function() {}, // do something custom when ESC is pressed + 32: null // don't do anything when SPACE is pressed (i.e. disable a reveal.js default binding) + } +}); +``` + +### 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. + +To enable lazy loading all you need to do is change your "src" attributes to "data-src" as shown below. This is supported for image, video, audio and iframe elements. Lazy loaded iframes will also unload when the containing slide is no longer visible. + +```html +
+ + + +
+``` + + +### API + +The ``Reveal`` object exposes a JavaScript API for controlling navigation and reading state: + +```javascript +// Navigation +Reveal.slide( indexh, indexv, indexf ); +Reveal.left(); +Reveal.right(); +Reveal.up(); +Reveal.down(); +Reveal.prev(); +Reveal.next(); +Reveal.prevFragment(); +Reveal.nextFragment(); + +// Toggle presentation states, optionally pass true/false to force on/off +Reveal.toggleOverview(); +Reveal.togglePause(); +Reveal.toggleAutoSlide(); + +// Change a config value at runtime +Reveal.configure({ controls: true }); + +// Returns the present configuration options +Reveal.getConfig(); + +// Fetch the current scale of the presentation +Reveal.getScale(); + +// Retrieves the previous and current slide elements +Reveal.getPreviousSlide(); +Reveal.getCurrentSlide(); + +Reveal.getIndices(); // { h: 0, v: 0 } } +Reveal.getProgress(); // 0-1 +Reveal.getTotalSlides(); + +// State checks +Reveal.isFirstSlide(); +Reveal.isLastSlide(); +Reveal.isOverview(); +Reveal.isPaused(); +Reveal.isAutoSliding(); +``` + +### Slide Changed Event + +A 'slidechanged' event is fired each time the slide is changed (regardless of state). The event object holds the index values of the current slide as well as a reference to the previous and current slide HTML nodes. + +Some libraries, like MathJax (see [#226](https://github.com/hakimel/reveal.js/issues/226#issuecomment-10261609)), get confused by the transforms and display states of slides. Often times, this can be fixed by calling their update or render function from this callback. + +```javascript +Reveal.addEventListener( 'slidechanged', function( event ) { + // event.previousSlide, event.currentSlide, event.indexh, event.indexv +} ); +``` + +### Presentation State + +The presentation's current state can be fetched by using the `getState` method. A state object contains all of the information required to put the presentation back as it was when `getState` was first called. Sort of like a snapshot. It's a simple object that can easily be stringified and persisted or sent over the wire. + +```javascript +Reveal.slide( 1 ); +// we're on slide 1 + +var state = Reveal.getState(); + +Reveal.slide( 3 ); +// we're on slide 3 + +Reveal.setState( state ); +// we're back on slide 1 +``` + +### Slide States + +If you set ``data-state="somestate"`` on a slide ``
``, "somestate" will be applied as a class on the document element when that slide is opened. This allows you to apply broad style changes to the page based on the active slide. + +Furthermore you can also listen to these changes in state via JavaScript: + +```javascript +Reveal.addEventListener( 'somestate', function() { + // TODO: Sprinkle magic +}, false ); +``` + +### 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. Below are a few examples. + +```html +
+

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.

+
+``` + +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. + + +### Parallax Background + +If you want to use a parallax scrolling background, set the first two config properties below when initializing reveal.js (the other two are optional). + +```javascript +Reveal.initialize({ + + // Parallax background image + parallaxBackgroundImage: '', // e.g. "https://s3.amazonaws.com/hakim-static/reveal-js/reveal-parallax-1.jpg" + + // Parallax background size + parallaxBackgroundSize: '', // CSS syntax, e.g. "2100px 900px" - currently only pixels are supported (don't use % or auto) + + // 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://lab.hakim.se/reveal-js/?parallaxBackgroundImage=https%3A%2F%2Fs3.amazonaws.com%2Fhakim-static%2Freveal-js%2Freveal-parallax-1.jpg¶llaxBackgroundSize=2100px%20900px). + + + +### Slide Transitions +The global presentation transition is set using the ```transition``` config value. You can override the global transition for a specific slide by using the ```data-transition``` attribute: + +```html +
+

This slide will override the presentation transition and zoom!

+
+ +
+

Choose from three transition speeds: default, fast or slow!

+
+``` + +You can also use different in and out transitions for the same slide: + +```html +
+ The train goes on … +
+
+ and on … +
+
+ and stops. +
+
+ (Passengers entering and leaving) +
+
+ And it starts again. +
+``` + + +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 (```
```): + +```html +Link +Link +``` + +You can also add relative navigation links, similar to the built in reveal.js controls, by appending one of the following classes on any element. Note that each element is automatically given an ```enabled``` class when it's a valid navigation route based on the current slide. + +```html + + + + + + +``` + + +### 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: + +```html +
+

grow

+

shrink

+

fade-out

+

visible only once

+

blue only once

+

highlight-red

+

highlight-green

+

highlight-blue

+
+``` + +Multiple fragments can be applied to the same element sequentially by wrapping it, this will fade in the text on the first step and fade it back out on the second. + +```html +
+ + I'll fade in, then out + +
+``` + +The display order of fragments can be controlled using the ```data-fragment-index``` attribute. + +```html +
+

Appears last

+

Appears first

+

Appears second

+
+``` + +### Fragment events + +When a slide fragment is either shown or hidden reveal.js will dispatch an event. + +Some libraries, like MathJax (see #505), get confused by the initially hidden fragment elements. Often times this can be fixed by calling their update or render function from this callback. + +```javascript +Reveal.addEventListener( 'fragmentshown', function( event ) { + // event.fragment = the fragment DOM element +} ); +Reveal.addEventListener( 'fragmenthidden', function( event ) { + // event.fragment = the fragment DOM element +} ); +``` + +### Code syntax highlighting + +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]
+        (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``` configuration value. + +```javascript +// Shows the slide number using default formatting +Reveal.configure({ slideNumber: true }); + +// Slide number formatting can be configured using these variables: +// 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' }); + +``` + + +### Overview mode + +Press "Esc" or "o" keys to toggle the overview mode on and off. While you're in this mode, you can still navigate between slides, +as if you were at 1,000 feet above your presentation. The overview mode comes with a few API hooks: + +```javascript +Reveal.addEventListener( 'overviewshown', function( event ) { /* ... */ } ); +Reveal.addEventListener( 'overviewhidden', function( event ) { /* ... */ } ); + +// Toggle the overview mode programmatically +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 `