Generating Random Data. Alan T. Arnholt Department of Mathematical Sciences Appalachian State University arnholt@math.appstate.edu



Similar documents
The Normal Distribution. Alan T. Arnholt Department of Mathematical Sciences Appalachian State University

Math 151. Rumbos Spring Solutions to Assignment #22

Correlation. Alan T. Arnholt Department of Mathematical Sciences Appalachian State University

3.4. The Binomial Probability Distribution. Copyright Cengage Learning. All rights reserved.

Normal Distribution as an Approximation to the Binomial Distribution

An Introduction to Basic Statistics and Probability

Contemporary Mathematics Online Math 1030 Sample Exam I Chapters No Time Limit No Scratch Paper Calculator Allowed: Scientific

The Binomial Probability Distribution

Chapter 3: DISCRETE RANDOM VARIABLES AND PROBABILITY DISTRIBUTIONS. Part 3: Discrete Uniform Distribution Binomial Distribution

Chapter 4. Probability and Probability Distributions

Chapter 4 Lecture Notes

MAT 155. Key Concept. September 27, S5.5_3 Poisson Probability Distributions. Chapter 5 Probability Distributions

AP Statistics 7!3! 6!

Joint Exam 1/P Sample Exam 1

WHERE DOES THE 10% CONDITION COME FROM?

UNIT I: RANDOM VARIABLES PART- A -TWO MARKS

STT315 Chapter 4 Random Variables & Probability Distributions KM. Chapter 4.5, 6, 8 Probability Distributions for Continuous Random Variables

Binomial random variables

Unit 4 The Bernoulli and Binomial Distributions

Sampling Distributions

2WB05 Simulation Lecture 8: Generating random variables

Binomial random variables (Review)

b) All outcomes are equally likely with probability = 1/6. The probabilities do add up to 1, as they must.

Least Squares Regression. Alan T. Arnholt Department of Mathematical Sciences Appalachian State University

ECE302 Spring 2006 HW4 Solutions February 6,

MATH 10: Elementary Statistics and Probability Chapter 5: Continuous Random Variables

Math 461 Fall 2006 Test 2 Solutions

Math 58. Rumbos Fall Solutions to Review Problems for Exam 2

6. Let X be a binomial random variable with distribution B(10, 0.6). What is the probability that X equals 8? A) (0.6) (0.4) B) 8! C) 45(0.6) (0.

JANUARY 2016 EXAMINATIONS. Life Insurance I

Lecture 8. Confidence intervals and the central limit theorem

Mind on Statistics. Chapter 8

Ch5: Discrete Probability Distributions Section 5-1: Probability Distribution

Sample Questions for Mastery #5

2 Binomial, Poisson, Normal Distribution

Lecture 6: Discrete & Continuous Probability and Random Variables

Mathematics of Life Contingencies. Math W Instructor: Edward Furman Homework 1

Lecture 5 : The Poisson Distribution

Chapter 15 Binomial Distribution Properties

Discrete Math in Computer Science Homework 7 Solutions (Max Points: 80)

Review #2. Statistics

CHAPTER 6: Continuous Uniform Distribution: 6.1. Definition: The density function of the continuous random variable X on the interval [A, B] is.

You flip a fair coin four times, what is the probability that you obtain three heads.

Question: What is the probability that a five-card poker hand contains a flush, that is, five cards of the same suit?

STAT 315: HOW TO CHOOSE A DISTRIBUTION FOR A RANDOM VARIABLE

Math 425 (Fall 08) Solutions Midterm 2 November 6, 2008

Chapter 4. Probability Distributions

Lecture 10: Depicting Sampling Distributions of a Sample Proportion

Math 431 An Introduction to Probability. Final Exam Solutions

The power of a test is the of. by using a particular and a. value of the that is an to the value

ECON1003: Analysis of Economic Data Fall 2003 Answers to Quiz #2 11:40a.m. 12:25p.m. (45 minutes) Tuesday, October 28, 2003

Section 5 Part 2. Probability Distributions for Discrete Random Variables

Math 370/408, Spring 2008 Prof. A.J. Hildebrand. Actuarial Exam Practice Problem Set 2 Solutions

Section 5-3 Binomial Probability Distributions

Practice Problems #4

Stats on the TI 83 and TI 84 Calculator

Introduction to the Practice of Statistics Sixth Edition Moore, McCabe Section 5.1 Homework Answers

PROBABILITY AND SAMPLING DISTRIBUTIONS

Chapter 5 Discrete Probability Distribution. Learning objectives

Practice Problems for Homework #6. Normal distribution and Central Limit Theorem.

Chapter 5: Normal Probability Distributions - Solutions

Chapter 9 Monté Carlo Simulation

BA 275 Review Problems - Week 6 (10/30/06-11/3/06) CD Lessons: 53, 54, 55, 56 Textbook: pp , ,

Chapter 3 RANDOM VARIATE GENERATION

Solutions: Problems for Chapter 3. Solutions: Problems for Chapter 3

ACMS Section 02 Elements of Statistics October 28, Midterm Examination II

Statistics 100A Homework 7 Solutions

Opgaven Onderzoeksmethoden, Onderdeel Statistiek

Practice problems for Homework 12 - confidence intervals and hypothesis testing. Open the Homework Assignment 12 and solve the problems.

AP STATISTICS (Warm-Up Exercises)

MATH 140 Lab 4: Probability and the Standard Normal Distribution

Normal Approximation. Contents. 1 Normal Approximation. 1.1 Introduction. Anthony Tanbakuchi Department of Mathematics Pima Community College


Lecture 3: Continuous distributions, expected value & mean, variance, the normal distribution

The Normal distribution

Final Mathematics 5010, Section 1, Fall 2004 Instructor: D.A. Levin

6.2 Normal distribution. Standard Normal Distribution:

Summary of Formulas and Concepts. Descriptive Statistics (Ch. 1-4)

The normal approximation to the binomial

Binomial Distribution n = 20, p = 0.3

An Introduction to Statistics Course (ECOE 1302) Spring Semester 2011 Chapter 10- TWO-SAMPLE TESTS

Some special discrete probability distributions

Introduction to Hypothesis Testing. Hypothesis Testing. Step 1: State the Hypotheses

AP Stats - Probability Review

12.5: CHI-SQUARE GOODNESS OF FIT TESTS

University of California, Los Angeles Department of Statistics. Random variables

ST 371 (IV): Discrete Random Variables

ACMS Section 02 Elements of Statistics October 28, 2010 Midterm Examination II Answers

Statistics 100A Homework 4 Solutions

e.g. arrival of a customer to a service station or breakdown of a component in some system.

Principle of Data Reduction

SOLUTIONS: 4.1 Probability Distributions and 4.2 Binomial Distributions

Chapter 8 Hypothesis Testing Chapter 8 Hypothesis Testing 8-1 Overview 8-2 Basics of Hypothesis Testing

Math/Stats 342: Solutions to Homework

Lecture Note 1 Set and Probability Theory. MIT Spring 2006 Herman Bennett

Statistics 100A Homework 8 Solutions

Solutions for Review Problems for Exam 2 Math You roll two fair dice. (a) Draw a tree diagram for this experiment.

4. Continuous Random Variables, the Pareto and Normal Distributions

I. Pointwise convergence

Practice problems for Homework 11 - Point Estimation

Transcription:

Generating Random Data Alan T. Arnholt Department of Mathematical Sciences Appalachian State University arnholt@math.appstate.edu Spring 2006 R Notes 1 Copyright c 2006 Alan T. Arnholt

2 Generating Random Samples Overview of Sampling Binomial Distribution Overview of the Binomial Distribution The R Script

3 Using sample() sample(x, size, replace = FALSE, prob = NULL) takes a sample of the specified size from the elements of x by sampling either with or without replacement.

Using sample() sample(x, size, replace = FALSE, prob = NULL) takes a sample of the specified size from the elements of x by sampling either with or without replacement. To sample with replacement, type replace=true. To sample without replacement, enter replace=false.

5 Using sample() sample(x, size, replace = FALSE, prob = NULL) takes a sample of the specified size from the elements of x by sampling either with or without replacement. To sample with replacement, type replace=true. To sample without replacement, enter replace=false. The sampling need not be uniform. Probabilities of selecting the values in x can be specified with the argument prob.

6 BSDA Example 3.12 Simulate 18,000 rolls of a fair die and determine the frequency of occurrence of each possible outcome. > die <- 1:6 > rolls <- sample(x=die,size=18000,replace=true) > table(rolls) rolls 1 2 3 4 5 6 2969 3063 2994 3042 3021 2911 > round(table(rolls)/length(rolls),3) rolls 1 2 3 4 5 6 0.165 0.170 0.166 0.169 0.168 0.162

7 Bernoulli Trial A Bernoulli trial is a random experiment with only two possible outcomes. The outcomes are mutually exclusive and exhaustive. For example, success or failure, true or false, alive or dead, male or female, etc. A Bernoulli random variable X, can take on two values, where X(success) = 1 and X(failure) = 0. The probability that X is a success is π, and the probability that X is a failure is = 1 π.

8 Generating Bernoulli Trials with sample() Example 3.15 from BSDA - Suppose a field-goal kicker has an 80% success rate inside the 35 yard line. Simulate eight kicks inside the 35 for ten consecutive seasons. To perform the simulation, we will use sample()

9 Generating Bernoulli Trials with sample() Example 3.15 from BSDA - Suppose a field-goal kicker has an 80% success rate inside the 35 yard line. Simulate eight kicks inside the 35 for ten consecutive seasons. To perform the simulation, we will use sample() Eighty Bernoulli trials are generated which can be thought of as ten games with eight field-goal attempts each.

10 R-Code > set.seed(13) > fg <- sample(x=c(0,1),size=8*10,replace=true, + prob=c(.20,.80)) > fgm <- matrix(fg,nrow=10) > fgmd <- cbind(fgm,apply(fgm,1,mean)*100) > fgmd [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [1,] 1 1 1 1 1 1 1 1 100.0 [2,] 1 0 1 1 1 1 1 1 87.5 [3,] 1 0 1 0 0 1 0 1 50.0 [4,] 1 1 1 0 1 0 1 1 75.0 [5,] 0 1 1 1 1 1 1 1 87.5 [6,] 1 1 1 1 0 1 1 0 75.0 [7,] 1 1 1 1 1 1 1 1 100.0 [8,] 1 1 1 1 1 1 1 1 100.0 [9,] 0 0 1 1 1 1 1 1 75.0 [10,] 1 1 1 1 1 1 1 1 100.0

11 Binomial Distribution When a sequence of Bernoulli trials conforms to the following list of requirements it is called a binomial experiment. 1. The experiment consists of a fixed number (n) of Bernoulli trials.

12 Binomial Distribution When a sequence of Bernoulli trials conforms to the following list of requirements it is called a binomial experiment. 1. The experiment consists of a fixed number (n) of Bernoulli trials. 2. The probability of success for each trial, denoted by π, is constant from trial to trial. The probability of failure is = (1 π).

13 Binomial Distribution When a sequence of Bernoulli trials conforms to the following list of requirements it is called a binomial experiment. 1. The experiment consists of a fixed number (n) of Bernoulli trials. 2. The probability of success for each trial, denoted by π, is constant from trial to trial. The probability of failure is = (1 π). 3. The trials are independent.

14 Binomial Distribution When a sequence of Bernoulli trials conforms to the following list of requirements it is called a binomial experiment. 1. The experiment consists of a fixed number (n) of Bernoulli trials. 2. The probability of success for each trial, denoted by π, is constant from trial to trial. The probability of failure is = (1 π). 3. The trials are independent. 4. The random variable of interest, X, is the number of observed successes during the n trials.

5 Binomial PDF The Binomial probability distribution function (pdf) is written P(X = x n, π) = n! (n x)!x! πx (1 π) n x, x = 0, 1, 2,...,n. If X has a Binomial distribution with parameters n and π, then the mean and standard deviation of X are µ X = E[X] = nπ

16 Binomial PDF The Binomial probability distribution function (pdf) is written P(X = x n, π) = n! (n x)!x! πx (1 π) n x, x = 0, 1, 2,...,n. If X has a Binomial distribution with parameters n and π, then the mean and standard deviation of X are µ X = E[X] = nπ σ X = nπ(1 π)

17 Binomial PDF The Binomial probability distribution function (pdf) is written P(X = x n, π) = n! (n x)!x! πx (1 π) n x, x = 0, 1, 2,...,n. If X has a Binomial distribution with parameters n and π, then the mean and standard deviation of X are µ X = E[X] = nπ σ X = nπ(1 π)

18 Using dbinom() dbinom(x, size, prob) computes the probability that P(X = x n, π) given X Bin(n = size, π = prob).

19 Using dbinom() dbinom(x, size, prob) computes the probability that P(X = x n, π) given X Bin(n = size, π = prob). Example: The mortality rate of a certain disease is 34%. Of ten patients who have the disease, what is the probability that more than half will die from the disease?

0 Using dbinom() dbinom(x, size, prob) computes the probability that P(X = x n, π) given X Bin(n = size, π = prob). Example: The mortality rate of a certain disease is 34%. Of ten patients who have the disease, what is the probability that more than half will die from the disease? Note: X Bin(n = 10, π = 0.34), and we want to find P(X > 5) = 1 P(X 5) = P(X = 5) + P(X = 4) + P(X = 3) + P(X = 2) + P(X = 1) + P(X = 0).

21 Doing the Math P(X = 5) = = ( ) 10 0.34 5 (1 0.34) 10 5 5 10! 5! (10 5)! 0.345 (1 0.34) 10 5 = 0.1433887 > choose(10,5)*.34^5*(1-.34)^(10-5) [1] 0.1433887 > dbinom(5,10,.34) [1] 0.1433887

22 Link to the R Script Go to my web page Script for Generating Random Data Homework: problems 3.32-3.52 See me if you need help!