Lecture 09: Sep 19, Randomness. Random Variables Sampling Probability Distributions Caching. James Balamuta STAT UIUC

Size: px
Start display at page:

Download "Lecture 09: Sep 19, Randomness. Random Variables Sampling Probability Distributions Caching. James Balamuta STAT UIUC"

Transcription

1 Lecture 09: Sep 19, 2018 Randomness Random Variables Sampling Probability Distributions Caching James Balamuta STAT UIUC

2 Announcements hw03 is due on Friday, Sep 21st, 6:00 PM Quiz 04 covers Week 3 CBTF. Window: Sep 18th - 20th EC Opportunity: Attend the Reflections and Projections Conference Write a 2-3 paragraph reflection about a talk and take a picture with the speaker for 1% extra credit. Fine Print Got caught using GitHub's web interface in hw01 or hw02? Let's chat.

3 Last Time SLR and MLR Estimating a linear regression with 2 parameters vs. p parameters Underlying design matrix construction Factors Provide a mapping of levels to indicator variables inside the design matrix.

4 Topic Outline Tools for Reproducibility Working with Data Simulations Visual Exploratory Data Analysis Unstructured Data Data Wrangling Functions Modeling Data Interactive Interfaces High Performance Computing

5 Topic Outline

6 Lecture Objectives Describe what a random variable is. Create and use a pseudo-random number generator. Generate random variables from probability distributions in R Explain the differences between sampling with and without replacement.

7 Random Variables

8 Definition: Sample Space contains all possible outcomes that can be obtained. They can be either: 1. discrete / finite in size, e.g. heads / tails, or 2. continuous / infinite in possibilities, e.g.weight / height Discrete Continuous "Heads" "Tails" 1 Coin 2 Coins US Height Distribution

9 Definition: Random Variables are variables that take on an unknown value in a sample space. P( X = Heads) = 0.5 P( X = Tails) = 0.5 Assumes a "fair" coin

10 Kinds of Randomness Source Source Pseudo-Random Number Generators (PRNGs) Deterministic Efficient Linear Congruential Method True Random Number Generators (TRNGs) Based on randomness from physical phenomena

11 Deterministic or Nondeterministic Source Same Input, Same Output Same Input, Different Outputs

12 LCM PRNG overview of LCM Algorithm Seed X 0, X 1, X 2, X 3,!, X n (0 X0 < m) Generated ( ) mod m X i+1 = ax i + c Generated Multiplier (0 a < m) Increment (0 c < m) Modulus (0 < m) Integer Range X 0,m 1 i! R = X i i m 0,1 ) Numeric Does not include 1

13 Prior generated value LCM Computations computation dependency X = ( ax + c)mod m i+1 i X 0 = 20, a = 13, c = 3, m = 64 ( X = 7 = 263mod64 = 13 ( 20) + 3)mod64 1 Simulated Integers ( X = 30 = 94mod64 = 13 ( 7) + 3)mod64 2 ( X = 9 = 393mod64 = 13 ( 30) + 3)mod64 3 ( X = 56 = 120mod64 = 13 ( 9) + 3)mod64 4 ( X = 27 = 731mod64 = 13 ( 56) + 3)mod64 5

14 Previously Modulus Operator a mod q 12 %% 7 # a = n*q + r => 12 = 1*7 + 5 # [1] 5 outer(9:1, 2:9, `%%`) # Compute the cross between X & Y mod 2 <int> mod 3 <int> mod 4 <int> mod 5 <int> mod 6 <int> mod 7 <int> mod 8 <int> mod 9 <int> x = x = x = x = x = x = x = x = x =

15 How could we generate Xi so that Ri includes 1?

16 # Setup values a = c = m = 2^32 # Initial Seed seed = as.numeric(sys.time()) * 1000 # Pre-allocation of numeric vector x = numeric(length = 2) Sample Implementation LCM Algorithm # Set initial value x[1] = seed x[2] = (a * x[1] + c) %% m # Real number (not including 1) r = x[2]/m

17 PRNG Periodicity a = 13, c = 0, m = 2 6 X i i X 0 = 1 X 0 = 2 X 0 = 3 X 0 =

18 Quality of R.V. uniqueness of numbers Independent Dependent a = , c = 12581, m = 2 32 a = 1229, c = 1, m = 2 11

19 Source XKCD 221: Random Number

20 Sampling

21 Definition: Sampling without Replacement involves picking values from a sample space and not adding them back for subsequent picks. In essence, a value may only be selected once. Available Available Picked

22 Definition: Sampling with Replacement involves picking values from a sample space, adding the picked value back for subsequent picks. In essence, a value may be selected multiple times.

23 Sampling picking r.v. values Sample Space Either a vector or number to sample from. Sample Size Number of values to pick from sample space. Replacement Sample without/with replacement (FALSE/TRUE). Probabilities Weighting for each observation. Optional. sample(x = <sample-space>, size = <nobs>, replace = FALSE, prob = NULL)

24 Sampling without Replacement picking r.v. values once Set a seed to control reproducibility set.seed(90210) Sample Space Either a vector or number to sample from. Sample Size Number of values to pick from sample space. Replacement Sample without/with replacement (FALSE/TRUE). sample(x = 8, size = 4, replace = FALSE) # [1] NB: Sample creates a vector of 10 from a single number. seq(1, 10) # [1]

25 Sampling without Replacement picking character r.v. values Set a seed to control reproducibility set.seed(42) Sample Space Either a vector or number to sample from. Sample Size Number of values to pick from sample space. Replacement Sample without/with replacement (FALSE/TRUE). sample(x = c("heads", "tails"), size = 1, replace = FALSE) # [1] "tails"

26 Your Turn Modify the sample code such that it can roll a six-sided die once. Set a seed to control reproducibility set.seed(385) Sample Space Either a vector or number to sample from. Sample Size Number of values to pick from sample space. Replacement Sample without/with replacement (FALSE/TRUE). Probabilities Weighting for each observation. Optional. sample(x = <sample-space>, size = <nobs>, replace = FALSE, prob = NULL)

27 Sampling with Replacement picking r.v. values Set a seed to control reproducibility set.seed( ) Sample Space Either a vector or number to sample from. Sample Size Number of values to pick from sample space. Replacement Sample without/with replacement (FALSE/TRUE). sample(x = 10, size = 20, replace = TRUE) # [1]

28 Sampling with Replacement biased coin sample Set a seed to control reproducibility set.seed(376006) Sample Space Either a vector or number to sample from. Sample Size Number of values to pick from sample space. Replacement Sample without/with replacement (FALSE/TRUE). Probabilities Weighting for each observation. Optional. y = sample(x = c("heads", "tails"), size = 10, replace = TRUE, prob = c(0.4, 0.6)) y # [1] "tails" "heads" "tails" "tails" "tails" "tails" "tails" "heads" "tails" "tails"

29 Frequencies and Proportions counting sampled data # Previously obtained sample under probability of 0.4/0.6 y # [1] "tails" "heads" "tails" "tails" "tails" "tails" "tails" "heads" "tails" "tails" # Count observations and/or obtain the proportion table(y) # heads tails # 2 8 prop.table(table(y)) # heads tails # # Why doesn't this match the requested probability of 0.4 / 0.6?

30 Your Turn Create a call to sample such that it can roll a "loaded" six-sided die twice with probabilities: 1 := 0.1, 2 := 0.3, 3 = 0.1, 4 := 0.15, 5 := 0.15, 6 := 0.2 Sample Space Either a vector or number to sample from. Sample Size Number of values to pick from sample space. Replacement Sample without/with replacement (FALSE/TRUE). Probabilities Weighting for each observation. Optional. sample(x = <sample-space>, size = <nobs>, replace = FALSE, prob = NULL) Source

31 Probability Distributions

32 Definition: Probability Distribution provides the outcome of a statistical event with the probability it occurs. Source

33 Supported Distributions possible distributions Distribution Functions Distribution Functions Beta pbeta qbeta dbeta rbeta Log Normal plnorm qlnorm dlnorm rlnorm Binomial pbinom qbinom dbinom rbinom Negative Binomial pnbinom qnbinom dnbinom rnbinom Cauchy pcauchy qcauchy dcauchy rcauchy Normal pnorm qnorm dnorm rnorm Chi-Squared pchisq qchisq dchisq rchisq Poison ppois qpois dpois rpois Exponential pexp qexp dexp rexp Student's t pt qt dt rt F pf qf df rf Studentized Range ptukey qtukey dtukey rtukey Gamma pgamma qgamma dgamma rgamma Uniform punif qunif dunif runif Geometric pgeom qgeom dgeom rgeom Weibull pweibull qweibull dweibull rweibull Hypergeometric phyper qhyper dhyper rhyper Wilcoxon Rank Sum pwilcox qwilcox dwilcox rwilcox Logistic plogis qlogis dlogis rlogis Wilcoxon Signed Rank psignrank qsignrank dsignrank rsignrank See for more Distributions the CRAN Task View

34 Normal Distribution an example of a probability distribution f ( x µ,σ ) = ( 1 exp x µ ) 2 σ 2π 2σ 2 µ is the mean σ is the standard deviation σ 2 is the variance

35 Distribution Functions d: density or the probability density function (PDF) p: probability or the cumulative distribution function (CDF) q: quantile or the inverse CDF r: random variable generation. # Normal PDF dnorm(c(-1, 0, 1)) # [1] # Normal CDF pnorm(c(-1, 0, 1)) # [1] # Normal icdf qnorm(c(0.15, 0.5, 0.84)) # [1] # Normal RNG set.seed(15) rnorm(2) # [1]

36 Cumulative and Density # Compute the probability pnorm(1.96) # [1] F X ( x) = P( X x) # Compute the density # at a specific point (uh oh) dnorm(1.96) # [1] # Only works for discrete # distributions.. Why? f X ( x) = F X ( x) # Integration required to # match output of pnorm integrate(dnorm(x), lower = -10, upper = 1.96 ) # with # absolute error < 2e-07

37 Quantiles finding the p-th quantile # Obtain the x value for # a probability of qnorm(0.975) # [1] # Note, this is taking the # inverse of pnorm, c.f. F X ( 1 F ( X p) ) = p x = F X 1 ( p) qnorm( pnorm( ) ) # [1] pnorm( qnorm(0.975) ) # [1] F X ( x) = P( X x)

38 Random Values generating lots of numbers # Set a seed set.seed(1) # Generate 1000 values # from a standard normal rnorm(1000) # [1] # [2] # [3] Box-Muller Transform

39 # Random Number Generation r*(n, param1 =, param2 = ) Generic Distribution Form pattern in statistical distribution functions # * represents a supported distribution (e.g. norm, t, f, chisq) # Density d*(x, param1 =, param2 =, log = FALSE) # Probability p*(q, param1 =, param2 =, lower.tail = TRUE, log.p = FALSE) # Quantile (inverse probability) q*(p, param1 =, param2 =, lower.tail = TRUE, log.p = FALSE)

40 Your Turn Using the qnorm() function, determine what the quantiles are at probabilities 0.5, 0.95, and Have you seen these values before?

41 Caching

42 Definition: Caches refers to storing data locally in order to speed up subsequent retrievals. Source

43 Cache in Action large value calculation * ```{r cache-large-computation, cache = TRUE} x = rnorm(10000*10000) system.time({ sorted_x = sort(x) }) ``` # user system elapsed # * The code chunk will be run once, the resulting objects are then stored within a file in the caches directory, and the stored data is then displayed on subsequent runs.

44 There are only two hard things in Computer Science: cache invalidation and naming things Phil Karlton

45 Warning Do not try the next example in an RMarkdown document with set.seed

46 Caution Required randomness and storage ```{r bad-sampling} x = rnorm(3) x ``` # [1] ```{r cached-calc, cache = TRUE} x y = x + 2 y ``` # [1] # [1]

47 Redux Caution Required re-running the aforementioned code ```{r bad-sampling} x = rnorm(3) x ``` # [1] ```{r cached-calc, cache = TRUE} x y = x + 2 y ``` # [1] # [1]

48 Depends On specifying dependency ```{r sampling, cache = TRUE} x = rnorm(3) x ``` # [1] ```{r cached-calc, cache = TRUE, dependson = "sampling"} x y = x + 2 y ``` # [1] # [1]

49 Recap Random Variables Variables that take on an unknown value LCM is one way to generate random numbers Distributions Probability Density/Mass Functions (PD/MF) is d* Cumulative Distribution Function (CDF) is p* Inverse CDF is q* Random Variables from Distribution is r* Sampling Sample without replacement does not add the picked object back. Sample with replacement does add the picked object back. Caches Speed up computationally intensive reports by storing results and re-using them.

50 This work is licensed under the Creative Commons Attribution-NonCommercial- ShareAlike 4.0 International License

R Functions for Probability Distributions

R Functions for Probability Distributions R Functions for Probability Distributions Young W. Lim 2018-03-22 Thr Young W. Lim R Functions for Probability Distributions 2018-03-22 Thr 1 / 15 Outline 1 R Functions for Probability Distributions Based

More information

Lecture 10: Sep 24, v2. Hypothesis Testing. Testing Frameworks. James Balamuta STAT UIUC

Lecture 10: Sep 24, v2. Hypothesis Testing. Testing Frameworks. James Balamuta STAT UIUC Lecture 10: Sep 24, 2018 - v2 Hypothesis Testing Testing Frameworks James Balamuta STAT 385 @ UIUC Announcements hw04 is due Friday, Sep 21st, 2018 at 6:00 PM Quiz 05 covers Week 4 contents @ CBTF. Window:

More information

Introduction to R and Programming

Introduction to R and Programming Introduction to R and Programming Nathaniel E. Helwig Assistant Professor of Psychology and Statistics University of Minnesota (Twin Cities) Updated 04-Jan-2017 Nathaniel E. Helwig (U of Minnesota) Introduction

More information

1 Probability Distributions

1 Probability Distributions 1 Probability Distributions A probability distribution describes how the values of a random variable are distributed. For example, the collection of all possible outcomes of a sequence of coin tossing

More information

Matematisk statistik allmän kurs, MASA01:A, HT-15 Laborationer

Matematisk statistik allmän kurs, MASA01:A, HT-15 Laborationer Lunds universitet Matematikcentrum Matematisk statistik Matematisk statistik allmän kurs, MASA01:A, HT-15 Laborationer General information on labs During the rst half of the course MASA01 we will have

More information

Chapter 3: Methods for Generating Random Variables

Chapter 3: Methods for Generating Random Variables Chapter 3: Methods for Generating Random Variables Lecturer: Zhao Jianhua Department of Statistics Yunnan University of Finance and Economics Outline 3.1 Introduction Random Generators of Common Probability

More information

GOV 2001/ 1002/ E-2001 Section 3 Theories of Inference

GOV 2001/ 1002/ E-2001 Section 3 Theories of Inference GOV 2001/ 1002/ E-2001 Section 3 Theories of Inference Solé Prillaman Harvard University February 11, 2015 1 / 48 LOGISTICS Reading Assignment- Unifying Political Methodology chs 2 and 4. Problem Set 3-

More information

Package skellam. R topics documented: December 15, Version Date

Package skellam. R topics documented: December 15, Version Date Version 0.2.0 Date 2016-12-13 Package skellam December 15, 2016 Title Densities and Sampling for the Skellam Distribution Author Jerry W. Lewis, Patrick E. Brown , Michail Tsagris

More information

Dr. Junchao Xia Center of Biophysics and Computational Biology. Fall /13/ /12

Dr. Junchao Xia Center of Biophysics and Computational Biology. Fall /13/ /12 BIO5312 Biostatistics R Session 03: Random Number and Probability Distributions Dr. Junchao Xia Center of Biophysics and Computational Biology Fall 2016 9/13/2016 1 /12 Random Number Generator Random number

More information

R Based Probability Distributions

R Based Probability Distributions General Comments R Based Probability Distributions When a parameter name is ollowed by an equal sign, the value given is the deault. Consider a random variable that has the range, a x b. The parameter,

More information

Probability theory and inference statistics! Dr. Paola Grosso! SNE research group!! (preferred!)!!

Probability theory and inference statistics! Dr. Paola Grosso! SNE research group!!  (preferred!)!! Probability theory and inference statistics Dr. Paola Grosso SNE research group p.grosso@uva.nl paola.grosso@os3.nl (preferred) Roadmap Lecture 1: Monday Sep. 22nd Collecting data Presenting data Descriptive

More information

Package Delaporte. August 13, 2017

Package Delaporte. August 13, 2017 Type Package Package Delaporte August 13, 2017 Title Statistical Functions for the Delaporte Distribution Version 6.1.0 Date 2017-08-13 Description Provides probability mass, distribution, quantile, random-variate

More information

Generating Random Numbers

Generating Random Numbers Generating Random Numbers Seungchul Baek Department of Mathematics and Statistics, UMBC STAT 633: Statistical Computing 1 / 67 Introduction Simulation is a very powerful tool for statisticians. It allows

More information

Probability measures A probability measure, P, is a real valued function from the collection of possible events so that the following

Probability measures A probability measure, P, is a real valued function from the collection of possible events so that the following This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike License. Your use of this material constitutes acceptance of that license and the conditions of use of materials on this

More information

MAS1802: Problem Solving II (Statistical Computing with R)

MAS1802: Problem Solving II (Statistical Computing with R) MAS1802: Problem Solving II (Statistical Computing with R) Dr Lee Fawcett School of Mathematics, Statistics & Physics Semester 2, 2017/2018 Part V Random Number Generation Some thoughts... When writing

More information

Package ppcc. June 28, 2017

Package ppcc. June 28, 2017 Type Package Version 1.0 Date 2017-06-27 Title Probability Plot Correlation Coefficient Test Author Thorsten Pohlert Package ppcc June 28, 2017 Maintainer Thorsten Pohlert Description

More information

Brief Review of Probability

Brief Review of Probability Maura Department of Economics and Finance Università Tor Vergata Outline 1 Distribution Functions Quantiles and Modes of a Distribution 2 Example 3 Example 4 Distributions Outline Distribution Functions

More information

Package alphaoutlier

Package alphaoutlier Type Package Package Outlier September 9, 2016 Title Obtain Alpha-Outlier Regions for Well-Known Probability Distributions Version 1.2.0 Date 2016-09-09 Author Andre Rehage, Sonja Kuhnt Maintainer Andre

More information

Lecture 4: Random Variables and Distributions

Lecture 4: Random Variables and Distributions Lecture 4: Random Variables and Distributions Goals Random Variables Overview of discrete and continuous distributions important in genetics/genomics Working with distributions in R Random Variables A

More information

Introduction to Statistical Data Analysis Lecture 3: Probability Distributions

Introduction to Statistical Data Analysis Lecture 3: Probability Distributions Introduction to Statistical Data Analysis Lecture 3: Probability Distributions James V. Lambers Department of Mathematics The University of Southern Mississippi James V. Lambers Statistical Data Analysis

More information

TMA4265: Stochastic Processes

TMA4265: Stochastic Processes General information TMA4265: Stochastic Processes Andrea Riebler August 18th, 2015 You find all important information on the course webpage: https://wiki.math.ntnu.no/tma4265/2015h/start Please check this

More information

TMA4265: Stochastic Processes

TMA4265: Stochastic Processes General information You nd all important information on the course webpage: TMA4265: Stochastic Processes https://wiki.math.ntnu.no/tma4265/2014h/start Please check this website regularly! Lecturers: Andrea

More information

Quantitative Understanding in Biology Module I: Statistics Lecture II: Probability Density Functions and the Normal Distribution

Quantitative Understanding in Biology Module I: Statistics Lecture II: Probability Density Functions and the Normal Distribution Quantitative Understanding in Biology Module I: Statistics Lecture II: Probability Density Functions and the Normal Distribution The Binomial Distribution Consider a series of N repeated, independent yes/no

More information

Name: Firas Rassoul-Agha

Name: Firas Rassoul-Agha Midterm 1 - Math 5010 - Spring 016 Name: Firas Rassoul-Agha Solve the following 4 problems. You have to clearly explain your solution. The answer carries no points. Only the work does. CALCULATORS ARE

More information

Random Variables. Definition: A random variable (r.v.) X on the probability space (Ω, F, P) is a mapping

Random Variables. Definition: A random variable (r.v.) X on the probability space (Ω, F, P) is a mapping Random Variables Example: We roll a fair die 6 times. Suppose we are interested in the number of 5 s in the 6 rolls. Let X = number of 5 s. Then X could be 0, 1, 2, 3, 4, 5, 6. X = 0 corresponds to the

More information

FW 544: Computer Lab Probability basics in R

FW 544: Computer Lab Probability basics in R FW 544: Computer Lab Probability basics in R During this laboratory, students will be taught the properties and uses of several continuous and discrete statistical distributions that are commonly used

More information

Package invgamma. May 7, 2017

Package invgamma. May 7, 2017 Package invgamma May 7, 2017 Type Package Title The Inverse Gamma Distribution Version 1.1 URL https://github.com/dkahle/invgamma BugReports https://github.com/dkahle/invgamma/issues Description Light

More information

GOV 2001/ 1002/ Stat E-200 Section 1 Probability Review

GOV 2001/ 1002/ Stat E-200 Section 1 Probability Review GOV 2001/ 1002/ Stat E-200 Section 1 Probability Review Solé Prillaman Harvard University January 28, 2015 1 / 54 LOGISTICS Course Website: j.mp/g2001 lecture notes, videos, announcements Canvas: problem

More information

Statistical distributions: Synopsis

Statistical distributions: Synopsis Statistical distributions: Synopsis Basics of Distributions Special Distributions: Binomial, Exponential, Poisson, Gamma, Chi-Square, F, Extreme-value etc Uniform Distribution Empirical Distributions Quantile

More information

Package jmuoutlier. February 17, 2017

Package jmuoutlier. February 17, 2017 Type Package Package jmuoutlier February 17, 2017 Title Permutation Tests for Nonparametric Statistics Version 1.3 Date 2017-02-17 Author Steven T. Garren [aut, cre] Maintainer Steven T. Garren

More information

Lecture 1: Random number generation, permutation test, and the bootstrap. August 25, 2016

Lecture 1: Random number generation, permutation test, and the bootstrap. August 25, 2016 Lecture 1: Random number generation, permutation test, and the bootstrap August 25, 2016 Statistical simulation 1/21 Statistical simulation (Monte Carlo) is an important part of statistical method research.

More information

R STATISTICAL COMPUTING

R STATISTICAL COMPUTING R STATISTICAL COMPUTING some R Examples Dennis Friday 2 nd and Saturday 3 rd May, 14. Topics covered Vector and Matrix operation. File Operations. Evaluation of Probability Density Functions. Testing of

More information

Pembangkitan Bilangan Acak dan Resampling

Pembangkitan Bilangan Acak dan Resampling Pembangkitan Bilangan Acak dan Resampling τρ Pembangkitan Bilangan Acak Resampling Jackknife Bootstrap Topics Random Generators in R Distribution R name Additional Arguments beta beta shape1, shape2, ncp

More information

IE 303 Discrete-Event Simulation L E C T U R E 6 : R A N D O M N U M B E R G E N E R A T I O N

IE 303 Discrete-Event Simulation L E C T U R E 6 : R A N D O M N U M B E R G E N E R A T I O N IE 303 Discrete-Event Simulation L E C T U R E 6 : R A N D O M N U M B E R G E N E R A T I O N Review of the Last Lecture Continuous Distributions Uniform distributions Exponential distributions and memoryless

More information

STT 315 Problem Set #3

STT 315 Problem Set #3 1. A student is asked to calculate the probability that x = 3.5 when x is chosen from a normal distribution with the following parameters: mean=3, sd=5. To calculate the answer, he uses this command: >

More information

z and t tests for the mean of a normal distribution Confidence intervals for the mean Binomial tests

z and t tests for the mean of a normal distribution Confidence intervals for the mean Binomial tests z and t tests for the mean of a normal distribution Confidence intervals for the mean Binomial tests Chapters 3.5.1 3.5.2, 3.3.2 Prof. Tesler Math 283 Fall 2018 Prof. Tesler z and t tests for mean Math

More information

Chi-squared (χ 2 ) (1.10.5) and F-tests (9.5.2) for the variance of a normal distribution ( )

Chi-squared (χ 2 ) (1.10.5) and F-tests (9.5.2) for the variance of a normal distribution ( ) Chi-squared (χ ) (1.10.5) and F-tests (9.5.) for the variance of a normal distribution χ tests for goodness of fit and indepdendence (3.5.4 3.5.5) Prof. Tesler Math 83 Fall 016 Prof. Tesler χ and F tests

More information

Outline PMF, CDF and PDF Mean, Variance and Percentiles Some Common Distributions. Week 5 Random Variables and Their Distributions

Outline PMF, CDF and PDF Mean, Variance and Percentiles Some Common Distributions. Week 5 Random Variables and Their Distributions Week 5 Random Variables and Their Distributions Week 5 Objectives This week we give more general definitions of mean value, variance and percentiles, and introduce the first probability models for discrete

More information

Lecture 2. October 21, Department of Biostatistics Johns Hopkins Bloomberg School of Public Health Johns Hopkins University.

Lecture 2. October 21, Department of Biostatistics Johns Hopkins Bloomberg School of Public Health Johns Hopkins University. Lecture 2 Department of Biostatistics Johns Hopkins Bloomberg School of Public Health Johns Hopkins University October 21, 2007 1 2 3 4 5 6 Define probability calculus Basic axioms of probability Define

More information

Random number generators

Random number generators s generators Comp Sci 1570 Introduction to Outline s 1 2 s generator s The of a sequence of s or symbols that cannot be reasonably predicted better than by a random chance, usually through a random- generator

More information

Random number generation

Random number generation CE 391F April 4, 2013 ANNOUNCEMENTS Homework 3 due today Homework 4 coming... Announcements Webinar announcement Femke van Wageningen-Kessels from TU Delft will be giving a webinar titled Traffic Flow

More information

Precept 4: Hypothesis Testing

Precept 4: Hypothesis Testing Precept 4: Hypothesis Testing Soc 500: Applied Social Statistics Ian Lundberg Princeton University October 6, 2016 Learning Objectives 1 Introduce vectorized R code 2 Review homework and talk about RMarkdown

More information

In Chapter 17, I delve into probability in a semiformal way, and introduce distributions

In Chapter 17, I delve into probability in a semiformal way, and introduce distributions IN THIS CHAPTER»» Understanding the beta version»» Pursuing Poisson»» Grappling with gamma»» Speaking eponentially Appendi A More About Probability In Chapter 7, I delve into probability in a semiformal

More information

Systems Simulation Chapter 7: Random-Number Generation

Systems Simulation Chapter 7: Random-Number Generation Systems Simulation Chapter 7: Random-Number Generation Fatih Cavdur fatihcavdur@uludag.edu.tr April 22, 2014 Introduction Introduction Random Numbers (RNs) are a necessary basic ingredient in the simulation

More information

CPSC 531: Random Numbers. Jonathan Hudson Department of Computer Science University of Calgary

CPSC 531: Random Numbers. Jonathan Hudson Department of Computer Science University of Calgary CPSC 531: Random Numbers Jonathan Hudson Department of Computer Science University of Calgary http://www.ucalgary.ca/~hudsonj/531f17 Introduction In simulations, we generate random values for variables

More information

Homework for 1/13 Due 1/22

Homework for 1/13 Due 1/22 Name: ID: Homework for 1/13 Due 1/22 1. [ 5-23] An irregularly shaped object of unknown area A is located in the unit square 0 x 1, 0 y 1. Consider a random point distributed uniformly over the square;

More information

Textbook: Survivial Analysis Techniques for Censored and Truncated Data 2nd edition, by Klein and Moeschberger

Textbook: Survivial Analysis Techniques for Censored and Truncated Data 2nd edition, by Klein and Moeschberger Lecturer: James Degnan Office: SMLC 342 Office hours: MW 12:00 1:00 or by appointment E-mail: jamdeg@unm.edu Please include STAT474 or STAT574 in the subject line of the email to make sure I don t overlook

More information

Slides 8: Statistical Models in Simulation

Slides 8: Statistical Models in Simulation Slides 8: Statistical Models in Simulation Purpose and Overview The world the model-builder sees is probabilistic rather than deterministic: Some statistical model might well describe the variations. An

More information

Exam 2 Practice Questions, 18.05, Spring 2014

Exam 2 Practice Questions, 18.05, Spring 2014 Exam 2 Practice Questions, 18.05, Spring 2014 Note: This is a set of practice problems for exam 2. The actual exam will be much shorter. Within each section we ve arranged the problems roughly in order

More information

7 Random samples and sampling distributions

7 Random samples and sampling distributions 7 Random samples and sampling distributions 7.1 Introduction - random samples We will use the term experiment in a very general way to refer to some process, procedure or natural phenomena that produces

More information

Lecture 2: Repetition of probability theory and statistics

Lecture 2: Repetition of probability theory and statistics Algorithms for Uncertainty Quantification SS8, IN2345 Tobias Neckel Scientific Computing in Computer Science TUM Lecture 2: Repetition of probability theory and statistics Concept of Building Block: Prerequisites:

More information

Topics in Computer Mathematics

Topics in Computer Mathematics Random Number Generation (Uniform random numbers) Introduction We frequently need some way to generate numbers that are random (by some criteria), especially in computer science. Simulations of natural

More information

Random Variables Example:

Random Variables Example: Random Variables Example: We roll a fair die 6 times. Suppose we are interested in the number of 5 s in the 6 rolls. Let X = number of 5 s. Then X could be 0, 1, 2, 3, 4, 5, 6. X = 0 corresponds to the

More information

Sampling Inspection. Young W. Lim Wed. Young W. Lim Sampling Inspection Wed 1 / 26

Sampling Inspection. Young W. Lim Wed. Young W. Lim Sampling Inspection Wed 1 / 26 Sampling Inspection Young W. Lim 2018-07-18 Wed Young W. Lim Sampling Inspection 2018-07-18 Wed 1 / 26 Outline 1 Sampling Inspection Based on Background Single Sampling Inspection Scheme Simulating Sampling

More information

Random Number Generation. CS1538: Introduction to simulations

Random Number Generation. CS1538: Introduction to simulations Random Number Generation CS1538: Introduction to simulations Random Numbers Stochastic simulations require random data True random data cannot come from an algorithm We must obtain it from some process

More information

Topics. Pseudo-Random Generators. Pseudo-Random Numbers. Truly Random Numbers

Topics. Pseudo-Random Generators. Pseudo-Random Numbers. Truly Random Numbers Topics Pseudo-Random Generators Why do we need random numbers? Truly random and Pseudo-random numbers. Definition of pseudo-random-generator What do we expect from pseudorandomness? Testing for pseudo-randomness.

More information

Chapter 2: Random Variables

Chapter 2: Random Variables ECE54: Stochastic Signals and Systems Fall 28 Lecture 2 - September 3, 28 Dr. Salim El Rouayheb Scribe: Peiwen Tian, Lu Liu, Ghadir Ayache Chapter 2: Random Variables Example. Tossing a fair coin twice:

More information

Generalized linear models

Generalized linear models Generalized linear models Douglas Bates November 01, 2010 Contents 1 Definition 1 2 Links 2 3 Estimating parameters 5 4 Example 6 5 Model building 8 6 Conclusions 8 7 Summary 9 1 Generalized Linear Models

More information

Computer Science, Informatik 4 Communication and Distributed Systems. Simulation. Discrete-Event System Simulation. Dr.

Computer Science, Informatik 4 Communication and Distributed Systems. Simulation. Discrete-Event System Simulation. Dr. Simulation Discrete-Event System Simulation Chapter 4 Statistical Models in Simulation Purpose & Overview The world the model-builder sees is probabilistic rather than deterministic. Some statistical model

More information

15 Discrete Distributions

15 Discrete Distributions Lecture Note 6 Special Distributions (Discrete and Continuous) MIT 4.30 Spring 006 Herman Bennett 5 Discrete Distributions We have already seen the binomial distribution and the uniform distribution. 5.

More information

Statistics and Econometrics I

Statistics and Econometrics I Statistics and Econometrics I Random Variables Shiu-Sheng Chen Department of Economics National Taiwan University October 5, 2016 Shiu-Sheng Chen (NTU Econ) Statistics and Econometrics I October 5, 2016

More information

Transformations of Standard Uniform Distributions

Transformations of Standard Uniform Distributions Transformations of Standard Uniform Distributions We have seen that the R function runif uses a random number generator to simulate a sample from the standard uniform distribution UNIF(0, 1). All of our

More information

Chapter 3. Chapter 3 sections

Chapter 3. Chapter 3 sections sections 3.1 Random Variables and Discrete Distributions 3.2 Continuous Distributions 3.4 Bivariate Distributions 3.5 Marginal Distributions 3.6 Conditional Distributions 3.7 Multivariate Distributions

More information

Pseudo-Random Generators

Pseudo-Random Generators Pseudo-Random Generators Topics Why do we need random numbers? Truly random and Pseudo-random numbers. Definition of pseudo-random-generator What do we expect from pseudorandomness? Testing for pseudo-randomness.

More information

Using R in 200D Luke Sonnet

Using R in 200D Luke Sonnet Using R in 200D Luke Sonnet Contents Working with data frames 1 Working with variables........................................... 1 Analyzing data............................................... 3 Random

More information

STA442/2101: Assignment 5

STA442/2101: Assignment 5 STA442/2101: Assignment 5 Craig Burkett Quiz on: Oct 23 rd, 2015 The questions are practice for the quiz next week, and are not to be handed in. I would like you to bring in all of the code you used to

More information

Introduction and Overview STAT 421, SP Course Instructor

Introduction and Overview STAT 421, SP Course Instructor Introduction and Overview STAT 421, SP 212 Prof. Prem K. Goel Mon, Wed, Fri 3:3PM 4:48PM Postle Hall 118 Course Instructor Prof. Goel, Prem E mail: goel.1@osu.edu Office: CH 24C (Cockins Hall) Phone: 614

More information

Collaborative Statistics: Symbols and their Meanings

Collaborative Statistics: Symbols and their Meanings OpenStax-CNX module: m16302 1 Collaborative Statistics: Symbols and their Meanings Susan Dean Barbara Illowsky, Ph.D. This work is produced by OpenStax-CNX and licensed under the Creative Commons Attribution

More information

Experiment, Sample Space, and Event. Event Operations

Experiment, Sample Space, and Event. Event Operations STAT 503 Probability and Probability Distributions 1 Experiment, Sample Space, and Event Experiment: the process of obtaining observations. Sample space: all possible outcomes of an experiment. Event:

More information

Sources of randomness

Sources of randomness Random Number Generator Chapter 7 In simulations, we generate random values for variables with a specified distribution Ex., model service times using the exponential distribution Generation of random

More information

Math/Stat 3850 Exam 1

Math/Stat 3850 Exam 1 2/21/18 Name: Math/Stat 3850 Exam 1 There are 10 questions, worth a total of 100 points. You may use R, your calculator, and any written or internet resources on this test, although you are not allowed

More information

Chapter 3 Single Random Variables and Probability Distributions (Part 1)

Chapter 3 Single Random Variables and Probability Distributions (Part 1) Chapter 3 Single Random Variables and Probability Distributions (Part 1) Contents What is a Random Variable? Probability Distribution Functions Cumulative Distribution Function Probability Density Function

More information

AMS 132: Discussion Section 2

AMS 132: Discussion Section 2 Prof. David Draper Department of Applied Mathematics and Statistics University of California, Santa Cruz AMS 132: Discussion Section 2 All computer operations in this course will be described for the Windows

More information

STAT509: Discrete Random Variable

STAT509: Discrete Random Variable University of South Carolina September 16, 2014 Motivation So far, we have already known how to calculate probabilities of events. Suppose we toss a fair coin three times, we know that the probability

More information

Chapter 2. Discrete Distributions

Chapter 2. Discrete Distributions Chapter. Discrete Distributions Objectives ˆ Basic Concepts & Epectations ˆ Binomial, Poisson, Geometric, Negative Binomial, and Hypergeometric Distributions ˆ Introduction to the Maimum Likelihood Estimation

More information

Distributions of Functions of Random Variables. 5.1 Functions of One Random Variable

Distributions of Functions of Random Variables. 5.1 Functions of One Random Variable Distributions of Functions of Random Variables 5.1 Functions of One Random Variable 5.2 Transformations of Two Random Variables 5.3 Several Random Variables 5.4 The Moment-Generating Function Technique

More information

STAT 414: Introduction to Probability Theory

STAT 414: Introduction to Probability Theory STAT 414: Introduction to Probability Theory Spring 2016; Homework Assignments Latest updated on April 29, 2016 HW1 (Due on Jan. 21) Chapter 1 Problems 1, 8, 9, 10, 11, 18, 19, 26, 28, 30 Theoretical Exercises

More information

Chapter 4: Monte Carlo Methods. Paisan Nakmahachalasint

Chapter 4: Monte Carlo Methods. Paisan Nakmahachalasint Chapter 4: Monte Carlo Methods Paisan Nakmahachalasint Introduction Monte Carlo Methods are a class of computational algorithms that rely on repeated random sampling to compute their results. Monte Carlo

More information

System Simulation Part II: Mathematical and Statistical Models Chapter 5: Statistical Models

System Simulation Part II: Mathematical and Statistical Models Chapter 5: Statistical Models System Simulation Part II: Mathematical and Statistical Models Chapter 5: Statistical Models Fatih Cavdur fatihcavdur@uludag.edu.tr March 20, 2012 Introduction Introduction The world of the model-builder

More information

R in 02402: Introduction to Statistic

R in 02402: Introduction to Statistic R in 02402: Introduction to Statistic Per Bruun Brockhoff DTU Informatics, DK-2800 Lyngby 8. november 2011 Indhold 1 Using R on the Databar-System at DTU 5 1.1 Access.......................................

More information

Relationship between probability set function and random variable - 2 -

Relationship between probability set function and random variable - 2 - 2.0 Random Variables A rat is selected at random from a cage and its sex is determined. The set of possible outcomes is female and male. Thus outcome space is S = {female, male} = {F, M}. If we let X be

More information

Stat 451 Lecture Notes Simulating Random Variables

Stat 451 Lecture Notes Simulating Random Variables Stat 451 Lecture Notes 05 12 Simulating Random Variables Ryan Martin UIC www.math.uic.edu/~rgmartin 1 Based on Chapter 6 in Givens & Hoeting, Chapter 22 in Lange, and Chapter 2 in Robert & Casella 2 Updated:

More information

Mathematics 343 Class Notes 1. Goal: To define probability and statistics and explain the relationship between the two

Mathematics 343 Class Notes 1. Goal: To define probability and statistics and explain the relationship between the two Mathematics 343 Class Notes 1 1 Introduction Goal: To define probability and statistics and explain the relationship between the two 1.1 What are Probability and Statistics? 1. Probability Definition 1.1.

More information

Outline. Unit 3: Inferential Statistics for Continuous Data. Outline. Inferential statistics for continuous data. Inferential statistics Preliminaries

Outline. Unit 3: Inferential Statistics for Continuous Data. Outline. Inferential statistics for continuous data. Inferential statistics Preliminaries Unit 3: Inferential Statistics for Continuous Data Statistics for Linguists with R A SIGIL Course Designed by Marco Baroni 1 and Stefan Evert 1 Center for Mind/Brain Sciences (CIMeC) University of Trento,

More information

Math 105 Course Outline

Math 105 Course Outline Math 105 Course Outline Week 9 Overview This week we give a very brief introduction to random variables and probability theory. Most observable phenomena have at least some element of randomness associated

More information

STAT 418: Probability and Stochastic Processes

STAT 418: Probability and Stochastic Processes STAT 418: Probability and Stochastic Processes Spring 2016; Homework Assignments Latest updated on April 29, 2016 HW1 (Due on Jan. 21) Chapter 1 Problems 1, 8, 9, 10, 11, 18, 19, 26, 28, 30 Theoretical

More information

CMPSCI 240: Reasoning Under Uncertainty

CMPSCI 240: Reasoning Under Uncertainty CMPSCI 240: Reasoning Under Uncertainty Lecture 5 Prof. Hanna Wallach wallach@cs.umass.edu February 7, 2012 Reminders Pick up a copy of B&T Check the course website: http://www.cs.umass.edu/ ~wallach/courses/s12/cmpsci240/

More information

( x) ( ) F ( ) ( ) ( ) Prob( ) ( ) ( ) X x F x f s ds

( x) ( ) F ( ) ( ) ( ) Prob( ) ( ) ( ) X x F x f s ds Applied Numerical Analysis Pseudo Random Number Generator Lecturer: Emad Fatemizadeh What is random number: A sequence in which each term is unpredictable 29, 95, 11, 60, 22 Application: Monte Carlo Simulations

More information

Pseudo-Random Generators

Pseudo-Random Generators Pseudo-Random Generators Why do we need random numbers? Simulation Sampling Numerical analysis Computer programming (e.g. randomized algorithm) Elementary and critical element in many cryptographic protocols

More information

INTRODUCTION TO R FOR DECISION MAKING OPTIMIZATION & SIMULATION

INTRODUCTION TO R FOR DECISION MAKING OPTIMIZATION & SIMULATION 1 INTRODUCTION TO R FOR DECISION MAKING OPTIMIZATION & SIMULATION Kannapha Amaruchkul Graduate School of Applied Statistics National Institute of Development Administration (NIDA), Bangkok, Thailand Friday

More information

EE/CpE 345. Modeling and Simulation. Fall Class 10 November 18, 2002

EE/CpE 345. Modeling and Simulation. Fall Class 10 November 18, 2002 EE/CpE 345 Modeling and Simulation Class 0 November 8, 2002 Input Modeling Inputs(t) Actual System Outputs(t) Parameters? Simulated System Outputs(t) The input data is the driving force for the simulation

More information

Normal (Gaussian) distribution The normal distribution is often relevant because of the Central Limit Theorem (CLT):

Normal (Gaussian) distribution The normal distribution is often relevant because of the Central Limit Theorem (CLT): Lecture Three Normal theory null distributions Normal (Gaussian) distribution The normal distribution is often relevant because of the Central Limit Theorem (CLT): A random variable which is a sum of many

More information

Probability Distributions

Probability Distributions Probability Distributions Series of events Previously we have been discussing the probabilities associated with a single event: Observing a 1 on a single roll of a die Observing a K with a single card

More information

Stat 135, Fall 2006 A. Adhikari HOMEWORK 6 SOLUTIONS

Stat 135, Fall 2006 A. Adhikari HOMEWORK 6 SOLUTIONS Stat 135, Fall 2006 A. Adhikari HOMEWORK 6 SOLUTIONS 1a. Under the null hypothesis X has the binomial (100,.5) distribution with E(X) = 50 and SE(X) = 5. So P ( X 50 > 10) is (approximately) two tails

More information

Continuous random variables

Continuous random variables Continuous random variables Continuous r.v. s take an uncountably infinite number of possible values. Examples: Heights of people Weights of apples Diameters of bolts Life lengths of light-bulbs We cannot

More information

2 Random Variable Generation

2 Random Variable Generation 2 Random Variable Generation Most Monte Carlo computations require, as a starting point, a sequence of i.i.d. random variables with given marginal distribution. We describe here some of the basic methods

More information

EE/CpE 345. Modeling and Simulation. Fall Class 5 September 30, 2002

EE/CpE 345. Modeling and Simulation. Fall Class 5 September 30, 2002 EE/CpE 345 Modeling and Simulation Class 5 September 30, 2002 Statistical Models in Simulation Real World phenomena of interest Sample phenomena select distribution Probabilistic, not deterministic Model

More information

Simulating Random Variables

Simulating Random Variables Simulating Random Variables Timothy Hanson Department of Statistics, University of South Carolina Stat 740: Statistical Computing 1 / 23 R has many built-in random number generators... Beta, gamma (also

More information

Chapter 2. Continuous random variables

Chapter 2. Continuous random variables Chapter 2 Continuous random variables Outline Review of probability: events and probability Random variable Probability and Cumulative distribution function Review of discrete random variable Introduction

More information

Statistical Concepts. Distributions of Data

Statistical Concepts. Distributions of Data Module : Review of Basic Statistical Concepts. Understanding Probability Distributions, Parameters and Statistics A variable that can take on any value in a range is called a continuous variable. Example:

More information