## Are you sure?

This action might not be possible to undo. Are you sure you want to continue?

Peter Bell February 21, 2008

1

Introduction

In this practical you will use Matlab to help solve a variety of problems in probability theory. You should be familiar with the material covered in lectures 17 and 18. No other resources are required. You will use two of Matlab’s random-number functions, rand and randperm, to simulate random experiments. These can be used to check your solutions to simple problems – for more complex problems where it is diﬃcult or impossible to ﬁnd an analytic solution, these simulation-based methods are often a good alternative.

2

Simple simulation

Carrying out probability experiments is known as sampling. In probability theory it is useful to distinguish between sampling with replacement and sampling without replacement. In the former case, the conditions of a probability experiment remain the same from one experiment to the next, so that the probabilities do not change. In the latter case, the conditions change, based on the outcome of previous experiments. For example, consider selecting balls from a bag containing 3 red balls and 3 green balls. If the balls are replaced after each experiment, the probability of selecting a green or red ball will always be 0.5. However, if the balls are not replaced, selecting a green 1

8 then say B has occurred. B occurs with probability 0.25. Examples of sampling with replacement include tossing a coin or throwing a die. Say that a 1 has been thrown on the ith experiment if the w(i) is less than or equal to 0. This experiment could be simulated as follows: • Set w = rand(1. and randperm to simulate sampling without replacement. Use w = rand(100. You should: 1. 2.m) function generates an n × m matrix of random numbers. say event A has occurred. A vector of these numbers can be used to simulate repeated experiments.5.2.ball on the ﬁrst experiment will make selecting a green ball less likely for the second experiment. 2.1 Sampling with replacement The rand(n. For example. • Then if w ≤ 0. uniformly distributed between 0 and 1. where each possible outcome has a ﬁxed probability. if 0. Count how many times a 4 has been thrown from the 100 experiments – call it n. If the experiment is repeated many times.5 ≤ w ≤ 0. Estimate the probability of throwing a 4 as: p(4) = 2 n 100 . 3. You will investigate this for the simple example of rolling a four-sided die. where each number from 1 to 4 occurs with probability 0. and otherwise say C has occurred. consider an experiment where event A occurs with probability 0. The more experiments there are. the results can be used to estimate event probabilities. simulating 100 throws of the die. you can use the rand function to simulate sampling with replacement. the more accurate the estimation becomes.1) to generate a 100-dimensional random vector. Examples of sampling without replacement include lottery draws or selections for a football team.25. In Matlab.5.1).3 and C occurs with probability 0.

Write a Matlab program to repeat the above simulation 100 times. of how many times that a red ball was drawn ﬁrst. 5000 and 10000 experiments. 0.25? Repeat the steps above for 500. Calculate the true probability on paper. then a green ball second. 5000 and 10000 experiments. Suppose you wish to choose two balls from a bag containing three red balls and three green balls. in order draw = perm(1:2) balls = bag(draw) You will repeat this simulation to estimate the probability of drawing a red ball ﬁrst. How close is this estimate to the true value. What do you ﬁnd? 3 . How close is your estimate? 4.2). you could simulate N experiments using rand(N. with each row corresponding to one experiment. and a green ball second. 2=green ball % random ordering of the numbers 1 to 6 % simulating the order in which balls are drawn % only consider the first two balls % find the actual two balls drawn. After repeating the simulation. 2. green) = n 100 3. 1000. A single experiment can be simulated as follows: bag = [ 1 1 1 2 2 2 ] perm = randperm(6) % 1=red ball.4. 1000. Produce a count. What do you ﬁnd? If each experiment involved rolling 2 dice. 2. Repeat the above steps for 500. 1. n. estimate the probability using p(red.2 Sampling without replacement The randperm(m) function produces a random ordering of the numbers from 1 to m.

calculate the solutions to the following problems (use the lecture notes to help). You will need to decide whether the problem is equivalent to sampling with replacement or sampling without replacement. check your answer by writing a Matlab program to simulate the problem and estimating the required probability from a very large number of experiments.3 Problems On paper. using the methods from Section 2. (Optional ) A four-sided die is thrown 6 times. and the winner must match all ﬁve balls (ordering doesn’t matter). What is the probability of throwing two 4s consecutively? (This is much easier to simulate than to calculate by hand!) 4 . 1. This is repeated three times. What is the probability of getting two heads and two tails (in any order)? 2. In each case. A lottery has balls numbered from 1 to 10. What is the probability that a double 4 is thrown at least once out of the three times? 4. A fair coin is tossed four times. Two four sided dice are thrown at the same time. Five balls are drawn. What is the probability of winning? 3.

- ProbabilityParzenBook.pdf
- Lecture Note on Statistics
- Ch2 Probability
- Statistics B
- Modeliranje Rizika u Projektu Vjetroelektrana
- Topic 4 - Probability (Old Notes)
- Master of Commerece (Revised) (Wef 01-Jan-2012)
- Print~Mishrak
- Net test sample paper
- STATICTICS
- Prob Review
- 1330951186.11100.Webmail191.Mynet.com_7283426524 Extra Exercises for Experimental - Copy
- 8.Abstract Format Raffiq
- Probability
- Discrete Probability Distributions.docx
- IPV7
- 12 11 05 Rubric
- Sampling
- Fall 2010 Final
- hardPROB.pdf
- CityofThieves_v2
- chp2
- Essay Week 1
- Probability
- Watcher Cheat Sheet
- Esantionare Schutt
- An Evidence Fusion method with importance discounting factors based on neutrosophic probability analysis in DSmT framework
- Chapter 5 Textbook Solutions
- chapter 6.ppt
- 1803

- tmp8659.tmp
- Raymond Merrill Jessop ruling
- Quantitative Methods for Economic
- Business Statistics Level 3/Series 2 2008 (Code 3009)
- Trend of Narratives in the Age of Misinformation
- UT Dallas Syllabus for se3341.001 06f taught by Michael Baron (mbaron)
- wp1408(1)
- UT Dallas Syllabus for te3341.001.07s taught by John Fonseka (kjp)
- Role of Social Networks in Information Diffusion
- Business Statstics/Series-3-2007(Code3009)
- ch10-2web-Revised
- Affidavit
- A Mathematical Theory of Communication
- Study of the Barrier Probability in a Classical Risk Model for two different claim amount distributions with same Mean
- UT Dallas Syllabus for opre6363.501.09s taught by Holly Lutze (hsl041000)
- Deciding in Messy Situations
- UT Dallas Syllabus for ee6349.521.07u taught by Mohammad Saquib (saquib)
- UT Dallas Syllabus for ce6352.501.08s taught by Galigekere Dattatreya (datta)
- What Price the Court of St. James? Political Influences on Ambassadorial Postings of the United States of America
- UT Dallas Syllabus for se3341.501.08s taught by Pankaj Choudhary (pkc022000)
- Shoppin' Bag of Pueblo, Inc., a Colorado Corporation and F.H. Markets, Inc., a Colorado Corporation v. Dillon Companies, Inc., a Kansas Corporation, 783 F.2d 159, 10th Cir. (1986)
- tmp51D9.tmp
- UT Dallas Syllabus for math5320.501 05s taught by Thomas Butts (tbutts)
- 2013-19
- UT Dallas Syllabus for cs3341.501.11s taught by Michael Baron (mbaron)
- As 3778.2.4-2007 Measurement of Water Flow in Open Channels General - Estimation of Uncertainty of a Flow Rat
- tmpCB3F.tmp
- tmp97E5
- tmpF426.tmp
- tmp83ED.tmp

Sign up to vote on this title

UsefulNot usefulClose Dialog## Are you sure?

This action might not be possible to undo. Are you sure you want to continue?

Close Dialog## This title now requires a credit

Use one of your book credits to continue reading from where you left off, or restart the preview.

Loading