Computational modeling

Similar documents
Introduction to computational modelling

Computational modeling

Lecture 2 Binomial and Poisson Probability Distributions

ELEG 3143 Probability & Stochastic Process Ch. 2 Discrete Random Variables

Lecture 2. Binomial and Poisson Probability Distributions

Lecture 10: Probability distributions TUESDAY, FEBRUARY 19, 2019

Simultaneous Equations Solve for x and y (What are the values of x and y): Summation What is the value of the following given x = j + 1. x i.

Great Theoretical Ideas in Computer Science

Business Statistics PROBABILITY DISTRIBUTIONS

STA 247 Solutions to Assignment #1

4. Discrete Probability Distributions. Introduction & Binomial Distribution

Lecture 2: Repetition of probability theory and statistics

Topics in Computer Mathematics

Discrete Probability. Chemistry & Physics. Medicine

Expected Value II. 1 The Expected Number of Events that Happen

Materials Genome Assessment

Scientific Measurement

Randomized Algorithms

2. The Binomial Distribution

Unit 4 Probability. Dr Mahmoud Alhussami

HW2 Solutions, for MATH441, STAT461, STAT561, due September 9th

Lecture notes for probability. Math 124

MAT Mathematics in Today's World

Name: Practice Final Exam May 8, 2012

What is a random variable

Exam III #1 Solutions

Random Variable. Discrete Random Variable. Continuous Random Variable. Discrete Random Variable. Discrete Probability Distribution

Discrete Structures for Computer Science

Recap. The study of randomness and uncertainty Chances, odds, likelihood, expected, probably, on average,... PROBABILITY INFERENTIAL STATISTICS

Discrete Random Variables

Chapter 2: The Random Variable

Crash Course in Statistics for Neuroscience Center Zurich University of Zurich

Statistical Methods for the Social Sciences, Autumn 2012

Random Variables. Statistics 110. Summer Copyright c 2006 by Mark E. Irwin

6.041SC Probabilistic Systems Analysis and Applied Probability, Fall 2013 Transcript Tutorial:A Random Number of Coin Flips

Statistics and Sampling distributions

STAT/SOC/CSSS 221 Statistical Concepts and Methods for the Social Sciences. Random Variables

Discrete Random Variables

TOPIC 12: RANDOM VARIABLES AND THEIR DISTRIBUTIONS

CS70: Jean Walrand: Lecture 15b.

Algorithms for Uncertainty Quantification

Lecture #13 Tuesday, October 4, 2016 Textbook: Sections 7.3, 7.4, 8.1, 8.2, 8.3

Random Variable. Pr(X = a) = Pr(s)

Week 2. Section Texas A& M University. Department of Mathematics Texas A& M University, College Station 22 January-24 January 2019

Outline. Probability. Math 143. Department of Mathematics and Statistics Calvin College. Spring 2010

Math 243 Section 3.1 Introduction to Probability Lab

CH 3 P1. Two fair dice are rolled. What is the conditional probability that at least one lands on 6 given that the dice land on different numbers?

Presentation on Theo e ry r y o f P r P o r bab a il i i l t i y

Probability (10A) Young Won Lim 6/12/17

Stochastic Processes. Review of Elementary Probability Lecture I. Hamid R. Rabiee Ali Jalali

PHYS 114 Exam 1 Answer Key NAME:

Discrete Mathematics and Probability Theory Fall 2013 Vazirani Note 12. Random Variables: Distribution and Expectation

Carleton University. Final Examination Winter DURATION: 2 HOURS No. of students: 152

V. Probability. by David M. Lane and Dan Osherson

Lecture 2 : CS6205 Advanced Modeling and Simulation

With Question/Answer Animations. Chapter 7

Example 1. The sample space of an experiment where we flip a pair of coins is denoted by:

Chapter 5 : Probability. Exercise Sheet. SHilal. 1 P a g e

Chapter 2.5 Random Variables and Probability The Modern View (cont.)

Discrete Probability Distributions

Lecture 2: Probability Distributions

Econ 325: Introduction to Empirical Economics

functions Poisson distribution Normal distribution Arbitrary functions

BINOMIAL DISTRIBUTION

Probability and Probability Distributions. Dr. Mohammed Alahmed

COMP6053 lecture: Sampling and the central limit theorem. Markus Brede,

Data Analysis and Monte Carlo Methods

Introduction and Overview STAT 421, SP Course Instructor

Business Statistics. Lecture 3: Random Variables and the Normal Distribution

UNIT NUMBER PROBABILITY 6 (Statistics for the binomial distribution) A.J.Hobson

Basic Statistics and Probability Chapter 3: Probability

success and failure independent from one trial to the next?

4452 Mathematical Modeling Lecture 14: Discrete and Continuous Probability

CS 246 Review of Proof Techniques and Probability 01/14/19

CS 361: Probability & Statistics

P (A) = P (B) = P (C) = P (D) =

PHP2510: Principles of Biostatistics & Data Analysis. Lecture X: Hypothesis testing. PHP 2510 Lec 10: Hypothesis testing 1

Chapter 7 Wednesday, May 26th

Essential Learning Outcomes for Algebra 2

Introduction to Machine Learning CMU-10701

MATH 3C: MIDTERM 1 REVIEW. 1. Counting

REPEATED TRIALS. p(e 1 ) p(e 2 )... p(e k )

Week 1 Quantitative Analysis of Financial Markets Distributions A

Chapter 5. Means and Variances

FINAL EXAM CHEAT SHEET/STUDY GUIDE. You can use this as a study guide. You will also be able to use it on the Final Exam on

We're in interested in Pr{three sixes when throwing a single dice 8 times}. => Y has a binomial distribution, or in official notation, Y ~ BIN(n,p).

STT 315 Problem Set #3

Introduction to Probability

Probability Distributions.

MLE/MAP + Naïve Bayes

RVs and their probability distributions

Review of Elementary Probability Lecture I Hamid R. Rabiee

Why should you care?? Intellectual curiosity. Gambling. Mathematically the same as the ESP decision problem we discussed in Week 4.

Math 1313 Experiments, Events and Sample Spaces

Probability 1 (MATH 11300) lecture slides

Question Paper Code : AEC11T03

Brief Review of Probability

Class 26: review for final exam 18.05, Spring 2014

3 PROBABILITY TOPICS

Random Variables Example:

Transcription:

Computational modeling Lecture 4 : Central Limit Theorem Theory: Normal distribution Programming: Arrays Instructor : Cedric Weber Course : 4CCP1000

Schedule Class/Week Chapter Topic Milestones 1 Monte Carlo UNIX system / Fortran 2 Monte Carlo Fibonacci sequence 3 Monte Carlo Random variables 4 Monte Carlo Central Limit Theorem 5 Monte Carlo Monte Carlo integration Milestone 1 6 Differential equations The Pendulum 7 Differential equations A Quantum Particle in a box 8 Differential equations The Tacoma bridge Milestone 2 9 Linear Algebra System of equations 10 Linear Algebra Matrix operations Milestone 3 2

What did you learn last time? 1. Summing up sequences with a do loop " " "ý " " 2. Defining your own functions " ý " 3. Using a random generator to produce random values ý " 4. Generating files and plotting them with xmgrace " "ý 5. Using modules to build up your own library" " "ý " 3

Where are we going? 100% Lecture 1: Introduction 90% 80% 70% Lecture 2: Fibonacci sequence / do loop Lecture 3: Random variables / functions 60% 50% 40% 30% 20% 10% Milestone 1 : Monte Carlo integration Lecture 4: Summing up random variables / multiple events statistics 0% week 1 week 2 week 3 week 4 week 5 week 6 week 7 week 8 week 9 week 10 4

Part 1 : Theory Central limit theorem 5

Jacob Bernoulli (1654-1705): Game Theory q Simple idea: lets define the outcome of an experiment X i, and the result of the experiment is either X i =0 or X i =1. When I repeat the experiment, I sometimes get X i =0, and sometimes I obtain X i =1" q Letʼs think of X i as a coin, which is flipped (head/tail). " q Experiment: flip the coin 1000 times" q how many tail, how many head?" q Definition of a Probability: " q P(head) = N(head) / total P(tail) = N(tail) / total " " q Reference: The Life and Times of the Central Limit Theorem, William J. Adams" = 500 = 500 6

Flipping many coins Now, what if I throw many coins at the same time? Each coin is labeled with an index We attribute the value 0 to tail, 1 to head X =(X 1,X 2,X 3,X 4,X 5,X 6,X 7 ) 0 0 1 0 0 1 1 To describe the outcome of this experiment, we define the variable S n : S n = X 1 + X 2 +... + X n In the experiment above I get : S n = 3 Now, I throw the coins again We get (fill the blank) : S n = [ ]? 1 1 1 0 0 1 0

I repeat the experiments many times I throw 7 coins, count how many heads I obtain, I do it again I obtain the sequence : Central limit theorem S=3, S=4, S=1, S=7, S=4, S=3, S=4, S=5, S=4, S=0, S=2.. I count how many times I obtain S=0, how many times I obtain S=1,, and how many times I obtain S=7 Number of occurence Question: if I throw the coins 700 times, how many times will you obtain the result S=0? As many times as you obtain S=1, S=2, S=3, S=4, S=5, S=6 and S=7 right? S=0 S=1 S=2 S=3 S=4 S=5 100 75 50 25 0 S=6 S=7 8

Simulating this experiment with a computer This program will be written in the practice session Result : The number of S 1,S 2,S 3 S 7 obtained 200 150 100 50 S=0 S=1 S=2 S=3 S=4 S=5 0 This histogram gives the probability P(S) to obtain S, if we divide the number of occurrence of each S i by the total number of experiments (700 in this case) Who can spot something wrong in the histogram? 9 S=6 S=7

Seriously? Nope, I am not cheating you Central limit theorem (CLT) : the sum of a large collection of random variables (S n = X 1 + + X n ) is distributed as a binomial law (or gaussian) P (S) =e (S µ)2 /(2σ 2 ) Where m is called the average and s the variance First discussed by Abraham De Moivre (1667-1754) Physical experiment in a laboratory: There is a large number of unknown parameters which are uncontrolled and contribute to your physical measurement (measure velocity with a timer, ) CLT : by repeating the same measurement, you will obtain a distribution of results (data), this distribution will a gaussian centered around the average value (m=your final measurement) and with a given width (s=your error bars) 10

Gaussian function m=0, s=1 m=0, s=3 m=1, s=1 Average m Variance s 11

Example 1 : gambling (Dices) Problem to be solved in the practice session Throwing to the casino a pair of dice at the same time Sum of a pair of dice takes values from 2 to 12 Where do you put your bet? S=2? Rolling many dices : Distribution is again gaussian 12

Example 2: Galton q Balls are bumping against many ticks during their fall q Balls are collected at the end of the free fall q Gaussian distribution http://www.elica.net (software to perform simple model calculations) 13

Example 3: population height Distribution of people according to their height is a gaussian as well (top: college male students, bottom: men in black and women in white) Pr Joiner s students, class of 1975, Penn state Joiner, B. L. (1975), Living Histograms, International Statistical Review, 3, 339 340. Connecticut State College (J. Heredity 5:511 518, 1914). 14

Fuzzy CLT 15 Larry Gonick, The Cartoon Guide to Statistics, New York, NY : Collins Reference / HarperPerennial 1993, p. 83.

Normal is everywhere 16

Convergence to the Normal distribution by increasing the number of coins to ~1000 average variance 17

Part 2 : Programming Arrays 18

Collection of variables 1. Program something 2. Integer(4) :: x1,x2,x3,x4,x5 3. Integer(4) :: x6,x7 4. x1 = 1 5. x2 = 2 6. x3 = 3 7. x4 = 4 8. x5 = 5 9. x6 = 6 10. x7 = 7 Ø We need to define a collection of variables Ø X1,.,X10 Ø We need to assign values to these variables Ø Time consuming! 11. end program 19

Arrays An array is a collection of variables, grouped under the same name myarray is the array s name for the array in this example Each box of the array corresponds to a real(8) variable, which can take any value To access a particular variable in the group, the position of the variable in the array needs to be provided, example : write(*,*) myarray(2) 20

Arrays Variables real(8) aa = 16 :: aa Arrays real(8) :: myarray(7) myarray(2) = 16 16 16 21

Variables real(8) :: aa aa = 16 Arrays Arrays real(8) :: myarray(7) myarray(2) = 16 Accessing member 2 Number of members (7) 16 16 22

Array: Global assignment real(8) ":: myarray(3)" " myarray(2) = 0" real(8) ":: myarray(3)" " myarray = 0" How many members/elements does the array myarray have?" " "Answer : " " [FILL IN]" What do you think the difference is between those two operations? " On the left side, "which element is set to zero? " On the right side, "which element is set to zero? " 23

Array: Global assignment real(8) ":: myarray(3)" " myarray(2) = 0" real(8) ":: myarray(3)" " myarray = 0" 0 0 0 0 24

Array: global operations 1. program testarray 2. real(8) :: myarray(10) 3. myarray = 2.0 Is this operation global and affects the whole array, or is it local and only affects one element? [Tick] global local 4. write(*,*) the second element of the array has the value:, myarray(2) 5. myarray = sin ( myarray ) 6. end program 25

Defining an array s dimension The last index of the array is y real(8) :: myarray( x : y ) The first index of the array is x (if not specified x=1) by default : x=1 x can be zero : x=0 x can be negative : x=- 5 Real(8):: myarray(1:5), myarray(5) Real(8):: myarray(0:7) Real(8):: myarray(- 5:5) 26

Arrays & Coins What we will practice today : we define an array which contains the number of outcomes obtained by repeating the experiment of throwing 7 coins. Each box of the array is counting the number of outcomes obtained with a given sum of coins, S=0, S=1, S=2, S=3, S=4, S=5, S=7 Each time an experiment is realized, we measure S, and we increment myarray(s): myarray(s) = myarray(s)+1" myarray is the histogram of the obtained S 2

Outcome of experiment: Arrays & flipping coins S=3 0 0 1 0 0 1 1 We keep track that we obtained one more event S=3 by repeating our experiment : " " " " "myarray(3) = myarray(3) + 1" S=4 1 1 1 0 0 1 0 We now want to keep track that we obtained S=4: " " " " "myarray(4) = myarray(4) + 1" 28

Summation of all values contained in the array myarray : y=sum(myarray)" Returns the minimum value contained in myarray : y=minval(myarray) Returns the maximum value contained in myarray : y=maxval(myarray)" Functions of arrays Returns the dimension of the array (i in this example should be an integer) : i =size(myarray) 29

Combined conditional statements BLOCK 1 BLOCK 2 1. Program something 2. Implicit none 3. Real(8) :: a 4. a=0.2 5. If ( a > 0.1 && a < 0.5 ) then 6. write(*,*) It is true 7. else 8. write(*,*) It is false 9. end if The if statement executes: the block 1 if the condition a>0.1 and the condition a<0.5 are satisfied The block 2 if either of a>0.1 or a<0.5 is NOT satisfied 10. end program 30

Practice Problems u Exercice 1 : Central limit theorem, convergence to a Normal distribution with random variables (X i =0,1) u Exercice 2 : Rolling dices at the casino 31