Lab #2-4 Follow-Up: Further into Python. Part 3: Random Numbers.

Slides:



Advertisements
Similar presentations
RSLAB-NTU Lab for Remote Sensing Hydrology and Spatial Modeling 1 An Introduction to R Pseudo Random Number Generation (PRNG) Prof. Ke-Sheng Cheng Dept.
Advertisements

Generating Random Numbers
Random Number Generation Graham Netherton Logan Stelly.
Random variables 1. Note  there is no chapter in the textbook that corresponds to this topic 2.
Random Number Generation. Random Number Generators Without random numbers, we cannot do Stochastic Simulation Most computer languages have a subroutine,
A Brief Introduction to Bayesian Inference Robert Van Dine 1.
Modeling and Simulation Monte carlo simulation 1 Arwa Ibrahim Ahmed Princess Nora University.
Random Numbers. Two Types of Random Numbers 1.True random numbers: True random numbers are generated in non- deterministic ways. They are not predictable.
Random number generation Algorithms and Transforms to Univariate Distributions.
BAYESIAN INFERENCE Sampling techniques
Random Number Generators. Why do we need random variables? random components in simulation → need for a method which generates numbers that are random.
Pseudorandom Number Generators
Statistics.
Chapter 14 Simulation. Monte Carlo Process Statistical Analysis of Simulation Results Verification of the Simulation Model Computer Simulation with Excel.
CSCE Monte Carlo Methods When you can’t do the math, simulate the process with random numbers Numerical integration to get areas/volumes Particle.
Random numbers in Python Nobody knows what’s next...
 The Law of Large Numbers – Read the preface to Chapter 7 on page 388 and be prepared to summarize the Law of Large Numbers.
G. Cowan Lectures on Statistical Data Analysis Lecture 10 page 1 Statistical Data Analysis: Lecture 10 1Probability, Bayes’ theorem 2Random variables and.
Review of Probability.
ETM 607 – Random Number and Random Variates
Psy B07 Chapter 1Slide 1 ANALYSIS OF VARIANCE. Psy B07 Chapter 1Slide 2 t-test refresher  In chapter 7 we talked about analyses that could be conducted.
Simulation Output Analysis
Random Number Generators CISC/QCSE 810. What is random? Flip 10 coins: how many do you expect will be heads? Measure 100 people: how are their heights.
01/24/05© 2005 University of Wisconsin Last Time Raytracing and PBRT Structure Radiometric quantities.
Essential Statistics Chapter 101 Sampling Distributions.
Dr. Richard Young Optronic Laboratories, Inc..  Uncertainty budgets are a growing requirement of measurements.  Multiple measurements are generally.
1 CIS 5371 Cryptography 3. Private-Key Encryption and Pseudorandomness B ased on: Jonathan Katz and Yehuda Lindel Introduction to Modern Cryptography.
McGraw-Hill/Irwin Copyright © 2007 by The McGraw-Hill Companies, Inc. All rights reserved. Chapter 6 Sampling Distributions.
The University of Texas at Arlington Topics in Random Processes CSE 5301 – Data Modeling Guest Lecture: Dr. Gergely Záruba.
1 1 – Radioactivity 13 N decays into 13 C + electron (e - ) + antineutrino v Tendency of an atom to decay: the “half-life” For a large sample of atoms,
1 Theoretical Physics Experimental Physics Equipment, Observation Gambling: Cards, Dice Fast PCs Random- number generators Monte- Carlo methods Experimental.
Modeling and Simulation
9.4 Random Numbers from Various Distributions. Distributions A distribution of numbers is a description of the portion of times each possible outcome.
Chapter 7 Random-Number Generation
Module 1: Statistical Issues in Micro simulation Paul Sousa.
Modeling and Simulation Random Number Generators
Random Numbers and Simulation  Generating truly random numbers is not possible Programs have been developed to generate pseudo-random numbers Programs.
1 Lesson 8: Basic Monte Carlo integration We begin the 2 nd phase of our course: Study of general mathematics of MC We begin the 2 nd phase of our course:
Random Number Generators 1. Random number generation is a method of producing a sequence of numbers that lack any discernible pattern. Random Number Generators.
BPS - 5th Ed. Chapter 11 1 Sampling Distributions.
Monte Carlo Methods.
Experimental Method and Data Process: “Monte Carlo Method” Presentation # 1 Nafisa Tasneem CHEP,KNU
Monte Carlo Methods Versatile methods for analyzing the behavior of some activity, plan or process that involves uncertainty.
Monte Carlo Methods So far we have discussed Monte Carlo methods based on a uniform distribution of random numbers on the interval [0,1] p(x) = 1 0  x.
Managerial Economics Demand Estimation & Forecasting.
Techniques in Signal Processing CSC 508 Generating Random Numbers with a Computer.
Survey – extra credits (1.5pt)! Study investigating general patterns of college students’ understanding of astronomical topics There will be 3~4 surveys.
Sampling and estimation Petter Mostad
Dynamics, Chaos, and Prediction. Aristotle, 384 – 322 BC.
1 Introduction to Statistics − Day 4 Glen Cowan Lecture 1 Probability Random variables, probability densities, etc. Lecture 2 Brief catalogue of probability.
Random numbers in C++ Nobody knows what’s next....
1/18/2016Atomic Scale Simulation1 Definition of Simulation What is a simulation? –It has an internal state “S” In classical mechanics, the state = positions.
CHAPTER 5 Simulation Modeling. Introduction In many situations a modeler is unable to construct an analytic (symbolic) model adequately explaining the.
Lecture 3: MLE, Bayes Learning, and Maximum Entropy
On the Nature of Things. Motion of Atoms Weight of atoms causes them to naturally move downward (II, 190). All atoms have equal speed in void (II, 239).
R ANDOM N UMBER G ENERATORS Modeling and Simulation CS
SS r SS r This model characterizes how S(t) is changing.
G. Cowan Lectures on Statistical Data Analysis Lecture 9 page 1 Statistical Data Analysis: Lecture 9 1Probability, Bayes’ theorem 2Random variables and.
EMIS 7300 SYSTEMS ANALYSIS METHODS FALL 2005 Dr. John Lipp Copyright © 2005 Dr. John Lipp.
G. Cowan Lectures on Statistical Data Analysis Lecture 5 page 1 Statistical Data Analysis: Lecture 5 1Probability, Bayes’ theorem 2Random variables and.
G. Cowan Lectures on Statistical Data Analysis Lecture 10 page 1 Statistical Data Analysis: Lecture 10 1Probability, Bayes’ theorem 2Random variables and.
Warsaw Summer School 2014, OSU Study Abroad Program Sampling Distribution.
Chapter 3 Generating Uniform Random Variables. In any kind of simulation, we need data, or we have to produce them. Especially in Monte Marco simulation.
1.  How does the computer generate observations from various distributions specified after input analysis?  There are two main components to the generation.
Exploring the connections…. NeurosciencePhilosophy.
Heisenberg’s Uncertainty principle
Discrete Event Simulation - 8
Lecture 2 – Monte Carlo method in finance
Computing and Statistical Data Analysis Stat 3: The Monte Carlo Method
Statistical Methods for Data Analysis Random number generators
Presentation transcript:

Lab #2-4 Follow-Up: Further into Python

Part 3: Random Numbers

Part 3: “Random” Numbers

Part 3: Pseudo-Random Numbers

Why Random Numbers? Traditional use: cryptography

Why Random Numbers? Recall Monte Carlo Estimation: Simulate the behavior of a complicated system using random numbers chosen from a reasonable distribution.

Two Kinds of Randomness 1)Chaos: A deterministic system that is so difficult to predict that we can treat it as random 2)True randomness: no underlying deterministic process

Is true randomness possible? οὐδὲν χρῆμα μάτην γίνεται, ἀλλὰ πάντα ἐκ λόγου τε καὶ ὑπ’ ἀνάγκης Leucippus (~ BC) – Leucippus Democritus ( BC)

Is true randomness possible? Nothing occurs at random, but everything for a reason and by necessity. Leucippus (~ BC) – Leucippus Democritus ( BC)

Why Does It Matter?

Is true randomness possible? We may regard the present state of the universe as the effect of its past and the cause of its future. An intellect which at a certain moment would know all forces that set nature in motion, and all positions of all items of which nature is composed, if this intellect were also vast enough to submit these data to analysis, it would embrace in a single formula the movements of the greatest bodies of the universe and those of the tiniest atom; for such an intellect nothing would be uncertain and the future just like the past would be present before its eyes. P.-S. Laplace ( )

Is true randomness possible? The theory says a lot, but does not really bring us any closer to the secret of the “old one”. I, at any rate, am convinced that He does not throw dice. A. Einstein ( )

Is true randomness possible? E. Schrödinger ( ) Copenhagen Interpretation: Yes

Quantum Weirdness and Consciousness (“Free Will?”) R. Penrose (1931-)

Free Will Without Quantum Weirdness H. Bergson ( ) Freedom is therefore a fact, and among the facts which we observe there is none clearer. The truth is we change without ceasing...there is no essential difference between passing from one state to another and persisting in the same state. … Just because we close our eyes to the unceasing variation of every physical state, we are obliged when the change has become so formidable as to force itself on our attention, to speak as if a new state were placed alongside the previous one.

H. Bergson ( ) Freedom as Flux The truth is we change without ceasing...there is no essential difference between passing from one state to another and persisting in the same state. … Heraclitus (~ BC) Πάντα ῥεῖ ( All things flow ) ‒ Heraclitus

Two Models for Generating Random Numbers

Two Methods for Generating Random Numbers Numerical “recipes” (Algorithms) Special-purpose hardware (rare)

Generating Pseudo- Random Numbers Linear Congruential Method: Start with arbitrary “seed” value x Multiply x by another number a and add a third number c Divide by another number m and take the remainder Remainder is new x; repeat x new = (a x old + c) rem m

Generating Pseudo- Random Numbers Linear Congruential Method: Start with arbitrary “seed” value x Multiply x by another number a and add a third number c Divide by another number m and take the remainder Remainder is new x; repeat x new = (a x old + c) mod m

# Generates N pseuedo-random numbers using the Linear # Congruential Method def lincongr(n): # Arbitrary constants A = 5 C = 11 # should have no common divisor with A M = 7 SEED = 0 x = SEED for k in range(n): print(x) x = (A * x + C) % M remainder (mod)

Output for N = def lincongr(n): # Arbitrary constants A = 5 C = 11 M = 7 SEED = 0 x = SEED for k in range(n): print(x) x = (A * x + C) % M

Output for N = def lincongr(n): # Arbitrary constants A = 5 C = 11 M = 7 # So this is the maximum! SEED = 0 x = SEED for k in range(n): print(x) x = (A * x + C) % M

Yields a Uniform Distribution

Shape is given by i.e., something that reaches a peak at x = 0 and tapers off rapidly as x grows positive or negative: Normal (Gaussian) Distributions How can we build such a distribution from our uniformly-distributed random numbers?

Start with two uniform, independent random distributions: a from 0 to 2  r from 0 to 1 Then compute Obtain two normal distributions b sin(a) +  b cos(a) +  Box-Muller-Gauss Method for Normal Distributions with Mean  And Standard Deviation 

Exponential Distributions Common pattern is exponentially decaying PDF, also called 1/f noise (a.k.a. pink noise) noise = random f = frequency; i.e., larger events are less common pink because uniform distribution is “white” (white light = all frequencies) “Universality” is a current topic of controversy (Shalizi 2006)

Exponential Method for PDF |k|e kt where t > 0, k < 0 Start with uniform random r between 0 and 1 Compute ln(r) / k E.g., ln(r) / (-2) gives 1/f noise

Concluding Topics Where do e and ln come from ? The Black Swan!