Lecture 09: Continuous RV. Lisa Yan July 16, 2018

Similar documents
CS 112: Computer System Modeling Fundamentals. Prof. Jenn Wortman Vaughan April 21, 2011 Lecture 8

Will Monroe July 21, with materials by Mehran Sahami and Chris Piech. Joint Distributions

Chapter 6: Simulation Using Spread-Sheets (Excel)

Probability Models.S4 Simulating Random Variables

Topic 5 - Joint distributions and the CLT

4.7 Approximate Integration

Biostatistics & SAS programming. Kevin Zhang

Random Number Generators

Multivariate probability distributions

Chapter 6 Normal Probability Distributions

Discrete Mathematics Course Review 3

Probability Model for 2 RV s

Intro to Probability Instructor: Alexandre Bouchard

Today s outline: pp

MAT137 Calculus! Lecture 31

Probability and Statistics for Final Year Engineering Students

Midterm 2. Friday, August 2, 5:10pm 7:10pm CS 70: Discrete Mathematics and Probability Theory, Summer 2013

What We ll Do... Random

Calculus I Review Handout 1.3 Introduction to Calculus - Limits. by Kevin M. Chevalier

EECS 126 Probability and Random Processes University of California, Berkeley: Fall 2017 Abhay Parekh and Jean Walrand September 21, 2017.

Lecture 8: Jointly distributed random variables

14.30 Introduction to Statistical Methods in Economics Spring 2009

% Close all figure windows % Start figure window

Discrete Mathematics and Probability Theory Spring 2017 Rao Midterm 2

Numerical Integration

THREE LECTURES ON BASIC TOPOLOGY. 1. Basic notions.

Lecture 8 Mathematics

COMPUTER SCIENCE LARGE PRACTICAL.

CS103 Handout 13 Fall 2012 May 4, 2012 Problem Set 5

NOTES: ALGEBRA FUNCTION NOTATION

Computer Organization and Levels of Abstraction

CS2351 Data Structures. Lecture 5: Sorting in Linear Time

Introduction to Mobile Robotics Bayes Filter Particle Filter and Monte Carlo Localization. Wolfram Burgard

Calculus Chapter 1 Limits. Section 1.2 Limits

Introduction to Cryptology. Lecture 2

How convincing is our Halting Problem proof? Lecture 36: Modeling Computing. Solutions. DrScheme. What is a model? Modeling Computation

CS103 Handout 14 Winter February 8, 2013 Problem Set 5

The Size of the Cantor Set

MULTI-DIMENSIONAL MONTE CARLO INTEGRATION

COT 6405 Introduction to Theory of Algorithms

Distributions of Continuous Data

(Refer Slide Time: 02.06)

Chapter 3. Bootstrap. 3.1 Introduction. 3.2 The general idea

Today. Lecture 4: Last time. The EM algorithm. We examine clustering in a little more detail; we went over it a somewhat quickly last time

Exam 2 is Tue Nov 21. Bring a pencil and a calculator. Discuss similarity to exam1. HW3 is due Tue Dec 5.

Monte Carlo Integration

Practical 2: Using Minitab (not assessed, for practice only!)

MITOCW watch?v=4dj1oguwtem

Math in Focus Vocabulary. Kindergarten

SIMULATION OF A SINGLE-SERVER QUEUEING SYSTEM

This is a good time to refresh your memory on double-integration. We will be using this skill in the upcoming lectures.

Introduction to Sets and Logic (MATH 1190)

Material from Recitation 1

Tracking Computer Vision Spring 2018, Lecture 24

Bulgarian Math Olympiads with a Challenge Twist

AP Calculus. Slide 1 / 213 Slide 2 / 213. Slide 3 / 213. Slide 4 / 213. Slide 4 (Answer) / 213 Slide 5 / 213. Derivatives. Derivatives Exploration

MATH : EXAM 3 INFO/LOGISTICS/ADVICE

Professor Stephen Sekula

Source of Slides: Introduction to Automata Theory, Languages, and Computation By John E. Hopcroft, Rajeev Motwani and Jeffrey D.

Anti-aliasing and Monte Carlo Path Tracing. Brian Curless CSE 557 Autumn 2017

Outline for Today. How can we speed up operations that work on integer data? A simple data structure for ordered dictionaries.

Topology 550A Homework 3, Week 3 (Corrections: February 22, 2012)

Package simed. November 27, 2017

A Quick Introduction to R

Lecture 11. Lecture 11: External Sorting

Algorithms. Appendix B. B.1 Matrix Algorithms. Matrix/Matrix multiplication. Vector/Matrix multiplication. This appendix is about algorithms.

CS 237 Fall 2018, Homework 08 Solution

MA651 Topology. Lecture 4. Topological spaces 2

Anti-aliasing and Monte Carlo Path Tracing

Lecture 4: examples of topological spaces, coarser and finer topologies, bases and closed sets

Lecture 27: Review. Reading: All chapters in ISLR. STATS 202: Data mining and analysis. December 6, 2017

Lecture 3: Recursion; Structural Induction

UCSD CSE 21, Spring 2014 [Section B00] Mathematics for Algorithm and System Analysis

CSC 261/461 Database Systems Lecture 21 and 22. Spring 2017 MW 3:25 pm 4:40 pm January 18 May 3 Dewey 1101

Computational Methods. Randomness and Monte Carlo Methods

Introduction to Machine Learning

CS510 \ Lecture Ariel Stolerman

1 Overview, Models of Computation, Brent s Theorem

2 The Fractional Chromatic Gap

Week 9: Planar and non-planar graphs. 7 and 9 November, 2018

Recursive Estimation

LAB #2: SAMPLING, SAMPLING DISTRIBUTIONS, AND THE CLT

Lectures on Challenging Mathematics. Integrated Mathematics 3. Idea Math. Algebra (part 2) Summer Internal Use

Point-Set Topology 1. TOPOLOGICAL SPACES AND CONTINUOUS FUNCTIONS

Solving Linear Recurrence Relations (8.2)

Monte Carlo Integration

Chapter 1 Introduction to Statistics

Lecture 4. Digital Image Enhancement. 1. Principle of image enhancement 2. Spatial domain transformation. Histogram processing

Midterm CSE 21 Spring 2012

INTRODUCTION TO TOPOLOGY

Computer Applications for Engineers ET 601

Lecture 13. Math 22 Summer 2017 July 17, 2017

Monte Carlo Techniques. Professor Stephen Sekula Guest Lecture PHY 4321/7305 Sep. 3, 2014

Sampling and Monte-Carlo Integration

CS302 Topic: Simulation, Part II

Lecture 12. Lecture 12: The IO Model & External Sorting

and F is an antiderivative of f

CS144: Intro to Computer Networks Homework 1 Scan and submit your solution online. Due Friday January 30, 4pm

CPSC 536N: Randomized Algorithms Term 2. Lecture 5

Last week: Breadth-First Search

Transcription:

Lecture 09: Continuous RV Lisa Yan July 16, 2018

Announcements As of Sunday July 17 2pm, PS3 has been updated (typo in problem 10) Midterm: Practice midterm up in next 24hrs PS4 out on Wednesday SCPD email out later today 2

Counting successes vs counting time until success Counting # of successes 1. Start and finish experiment. 2. Review and count successes. 1 trial: Ber(p) Amount of time until success 1. Start experiment. 2. Once success is observed, finish the experiment. Geo(p) 1 success N trials: Bin(n,p) NegBin(r,p) r successes Duration of time: Poi(l) Today s lecture 3

Balls, Urns, and Supreme Court Supreme Court case: Berghuis v. Smith If a group is underrepresented in a jury pool, how do you tell? Article by Erin Miller Friday, January 22, 2010 Thanks to (former CS109er) Josh Falk for this article Justice Breyer [Stanford Alum] opened the questioning by invoking the binomial theorem. He hypothesized a scenario involving an urn with a thousand balls, and sixty are red, and nine hundred forty are black, and then you select them at random twelve at a time. According to Justice Breyer and the binomial theorem, if the red balls were black jurors then you would expect something like a third to a half of juries would have at least one black person on them. Justice Scalia s rejoinder: We don t have any urns here. 4

Balls, Urns, and Supreme Court If a group is underrepresented in a jury pool, how do you tell? Urn with 1000 balls, 60 red, 940 black. Select 12 at a time. What is P( 1 black person in a 12-person jury)? Solution: Note: Ball draws not independent (draw without replacement) Recall: HypGeo == combinatorics/equally likely outcomes P(draw 1 red ball) = 1 P(draw 12 black balls) 0.5261 P(draw 12 black balls) = "# $% / $### 0.4739 $% Approximate using Binomial: Assume P(red ball) = 60/1000 (with replacement) Define X = # red balls drawn out of 12, X ~ Bin(12, 60/1000 = 0.06) P(X 1) = 1 P(X = 0)» 1 0.4759 = 0.5240 5

Goals for today Continuous RV Probability Density Functions (PDFs) Cumulative Distribution Functions (CDFs) Uniform Random Variable Exponential Random Variable 6

From Discrete to Continuous So far, everything has been discrete: Finite or countably infinite values (e.g., integers) Values are binary or represent a count How many But not everything random in this world is discrete Continous random variables have (uncountably) infinite values Height (cm), weight (lbs), time (seconds), etc. How much The general TL;DR is replace b x=a p(x) " a bf(x)dx with 7

Continuous Random Variables X is a Continuous Random Variable if there is a function (#) 0 for x such that: % & ( ) = +. (#) /#, is a Probability Density Function (PDF) if: % ( = +. # /# = 1 1 The cumulative distribution function (CDF) of X is then: 3. & = +. # /# 1, - 8

Probability Density Functions is a Probability Density Function (PDF) if: " % = ' ) *) = 1 ( ()) is not a probability It is a density (probability/units of X) Meaningless without a subinterval over X. ". % / = ' 0 1 2 ()) *) 9

random.random() random.random() in Python: Let X = random.random(). 1. P(X = 0.6) 2. P(X < 0.6) 3. P(X 0.6) 4. P(X > 0.6) 5. P(0.4 < X < 0.6) = 0 = 0.6 = 0.6 = 1 0.6 = 0.4 = 0.2 10

PDFs (continuous) vs PMFs (discrete) Recall the PMF (discrete X): But for PDF (continuous X): + " = $ % = ", ' $ % = " =. / For continuous 0 and small e: $ " 4 5 % " + 4 5 = /9 : ; / /< : ; 0, 1, >0(") ()*, ( = 1 0, 1, = 0 P(X = a) for continuous X is meaningless $ % = 1 $ % = 2 >0 1 >0 2 = 0(1) 0(2) Ratio of probabilities is still meaningful 11

Cumulative Distribution Functions For a continuous random variable X, the CDF is: " = $ % < " = $ % " = ( +, -, ) Density + (PDF) is derivative of CDF : + " = - -" (") * 12

random.random() random.random() in Python: Let X = random.random(). 1. Draw the PDF of X. 2. Draw the CDF of X. 13

A simple example Let X be a continuous RV with PDF: " # = % & 4# 2#* if 0 # 2 0 otherwise 1. What is C? 1 = / 3 03 " # 1# = / Support of PDF 4 * " # 1# = / 4 * -. = / # 1# = 1 0 & 4# 2# * 1# = & 2# * 2 5 3 #7 4 * = & 8 9: 7 2. What is P(X > 1)? P X > 1 = / 9 3 C > 7 = 1 à C = 7 > " # 1# = / 9 * 3 8 4# 2#* 1# = 3 8 = 3 8 8 16 3 2 2 3 à P(X > 1) = 9 * 2# * 2 * 5 3 #7 9 Picture checks out 14

Expectation and Variance Discrete RV: Continuous RV: " = $ & ' ( & % )(") = $ )(&) ' ( & % ", = $ &, ' ( & % Both continuous and discrete RVs: " =. )(") =. ", =. 0 /0 0 /0 0 /0 3" + 5 = 3 " + 5 Var(") = (" ["]) < = " < (["]) < Var(3" + 5) = 3 < Var(") &1 ( & 2& )(&)1 ( & 2& &, 1 ( & 2& 16

Linearly increasing density 2# if 0 # 1 " # = % 0 otherwise " # 1. E[X] *, +, 2. Var(X) 4 5 6 = * # " #.# = *, +, / 0 # 6 " #.# = * # " #.# = * / / 0 0 # 6 " #.# = * Var 5 = 4 5 6 4 5 6 = 1 2 2 3 2 # 2#.# = 1 6 / = 1 18 0 0 3 #3 / = # 2 3 # 6 2 2#.# = 1 0 4 #8 / = 1 2 17

Break Attendance: tinyurl.com/cs109summer2018 18

Uniform Random Variable Uniform RV, X: X ~ Unif(a, b) 1 if $ *, ( " # $ = &( * 0 otherwise ; : =. 0 /0 $ " # $ 2$ =. 3 4 $ 1 ( * 2$ = 1 ( * 1 5 = 1 ( * 1 2 (7 * 7 = 1 2 ( + * ( * ( * 4 2 $7 3 = 1 2 * + ( E : = 1 2 * + ( Var : = ( * 7 12 19

Uniformly fun Let X ~ Unif(0, 20). 0. Draw the PDF of X. 1. P(X < 6)? 2. P(4 < X < 17)? ) 1 " # < 6 = ' ( 20 -. = 6 20 = 3 10 " 4 < # < 17 = ' : ;< 1 20 Let X ~ Unif(a,b). What is P(a X b), where a a b b? 17 -. = 20 4 20 = 13 20 3 1 " 0 < # < 1 = ' 2 4 6 -. =. 4 6 7 2 3 = 1 0 4 6 20

Riding the Marguerite Bus Suppose the Marguerite bus stops at the Gates building at 15-minute intervals (2:00, 2:15, 2:30, etc.). Passenger arrives at stop uniformly b/t 2:00-2:30pm. X ~ Unif(0, 30) 1. P(passenger waits < 5 minutes for bus)? " 10 < & < 15 + " 25 < & < 30 = -./.0 1 30 12 + - 30 4/ 1 2. P(passenger waits > 14 minutes for bus)? " 0 < & < 1 + " 15 < & < 16. 1.5 = - / 30 12 + - 1.0 30 12 30 12 = 5 30 + 5 30 = 1 3 = 1 30 + 1 30 = 1 15 2:00pm Must arrive: 2:10-2:15 2:25-2:30 2:00pm 2:15pm 2:30pm Must arrive: 2:00-2:01 2:15-2:16 2:15pm 21

Small Calculus Review Product rule for derivatives: " # $ = " # $ + " # $ Derivative and integral of exponential: ' ( ) '* Written another way: (fg) = f g + f g ', = +, '* +,. = +, Integration by parts: /. # 0 =. # 0 / 0 #. 22

Exponential Random Variable Exponential RV, X: X ~ Exp(l) " # $ = & '()*+ if $ 0 0 otherwise. / = 1 λ Var(/) = 1 λ 7 CDF (where a 0): 8 # 9 = : / 9 = < = > '( )*+?$ = ' 1 > @ ' ()*+ = = 1 ( )*> ( )* = = 1 ( )*> 1 8 # 9 = 1 ( )*> 23

Expectation of the Exponential < 0 5 12 = 0 5 2 < 2 5 10 Given that " # = %& '() for # 0, show:, - = 1 λ 1. Don t panic, think happy thoughts 2. Integration by parts: find u, v, du, dv 3. Substitute (a.k.a plug and chug ) Solution: 0 = # 12 = %& '() 1# 10 = 1# 2 = & '() f #%& '() 1# = 0 5 12 = 0 5 2 2 5 10 = #& '() & '() 1# f, - = #& '() 8 8 6 7 + 7 & '() 1# = #& '() 8 : 6 7 & '() 8 6 7 ; E, - = : ; = 0 : ; 0 0 : ; 24

PSA: The CDF is nice For a continuous random variable X, the CDF is: " = $ % < " = $ % " = ( +, -, ) If you learn how to use cumulative distribution functions, you can avoid integrals. For continuous X: P(X < a) = P(X a) = F(a) Consequently, P(X > a) = P(X a) = 1 F(a) Cool fact (if " <. and +, is continuous): P(a < X < b) = F(b) F(a) 1 * Proof:. " = ) +, -, ) +, -, * 1 * 1 Proof= ) +, -, + * +, -, ) +, -, = * +, -, * 25

Website visits X ~ Exp(l ): ) * + = 1 "./0 Suppose a visitor to your website leaves after X minutes. On average, visitors leave the site after 5 minutes. The length of stay, X, is exponentially distributed. 1. P(X > 10)? 2. P(10 < X < 20)? Solution: Define: X ~ Exp(l), where l = 1/E[X] = 1/5 1. P(X > 10)? 2. P(10 < X < 20)? = 1 F(10) = 1 (1 " 10(1/5) ) = " 2 0.1353 = F(20) F(10) = (1 " 4 ) (1 " 2 ) 0.1170 26

Discrete RV analogs to Continuous RVs Discrete PMF Die rolling, p(x) = 1/6, X {1,,6} Continuous PDF X ~ Unif(a, b ), X [",#] $ % (') X ~ Geo(p), X {1, 2, } ' X ~ Exp(l ), X [0, ) f (x) x 27