This preview shows page 1-2 out of 7 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 7 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 7 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 7 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Simulation v2.0Simulating ProbabilitiesPurpose: In this lab you will study some "laws" of probability by using the computer tosimulate random experiments. You'll learna) how expected outcomes differ from actual outcomes, and how this difference isaffected by repeating the experiment a large number of times.b) how to calculate "experimental" probabilitiesc) how the Central Limit Theorem behaves with coin-tossing experimentsData: There are no data for this assignment. You will generate your own data.Assignment: There is no "take home" section in this lab. You should instead turn in youranswers to all of the questions below. You do not need to include graphs in youranswers.Before ClassYou should be familiar with these terms:Probability, event, expected value, randomYou should bring paper on which to record your observations.Before we begin...You've learned some of Stata's computational abilities, but Stata also allows users towrite fairly sophisticated programs. We're not going to ask you to do this, but insteadyou're going to use some programs that others have written in order to run simulations.These programs are not sold with Stata, but you can still install them. If you are workingin the lab, you probably won't have to do this. If you are working from home, you willneed to add these programs before you can complete the exercises. Instructions fordownloading these programs are given below.Start up Stata and issue the command:heads, saveIf the program "heads" is installed on your computer, a graph should appear. This is agraph of the cumulative (total) proportion of tosses that lands "heads" for a fair coin, ifyou were to toss it 100 times.If "heads" is not working on your computer and you are either in the Statistics Lab or athome, follow these instructions:1. Click on the word "HELP" on the menu bar2. Click on the line that reads "STB and User-Written Programs"Simulation v2.03. Click on the colored letters which read: http://www.stata.com4. Click on the colored letters which read users5. Click on the colored letters which read ucla6. Click on the colored letters which read teach7. Click on the colored letters which read heads (you will need to scroll down a fewpages to find it, it's in the far left hand column of words) Later, we will alsodownload "dice" and "cards". You might want to do this as soon as you finishinstalling "heads".8. Click on the colored letters which read (click here to install)9. When Stata is finished installing, it will read something like "click here to returnto the previous page", at this point, close the help window and return to your Statacommands.10. DO NOT TRY THE PREVIOUS 8 INSTRUCTIONS IN THE CLICC LABS ITWILL NOT WORK.If you did have the heads program installed, you're ready to proceed.Useful Stata Commandsgenerate newvar expression -> the generate command creates a new variable with thename newvar based on the values of any expression.display expression -> allows you to use Stata as a calculator by displaying the result ofany expression. For example, display 3+5 will show 8.Binomial(n,k,p) -> when used with the display command, will calculate the probabilityof getting exactly k heads in n tosses of a coin that comes up heads with probability p.tabulate variable -> shows values, frequencies, and cumulative frequencies of variable.Activity 1: Expected ValuesAlthough individual experiments vary and seldom come out exactly as expected, there isstill long-term regularity to random phenomenon. This means that "in the long run" ourexpectations tend to be met. (Of course, it's important to expect the right outcome!)1. Issue the command:heads, saveIt may not feel like it, but you have just tossed a fair coin (probability of heads =1/2) 100 times. A dialog box has appeared and four variables have been created.Simulation v2.0The dialog box lets you change the number of trials for your experiment, theprobability of getting heads on each flip, and the number of coins you want to flipat each trial.To interact with the data, you must first click on "quit" in the dialog box. Dothat now.The graph that appears "pretends" that after each toss of the coin, you recordedthe percent of the tosses that were heads. (a) Question: If I toss a coin 100 times, how many heads do I expect or whatpercentage do I expect to be heads?Hopefully you wrote 50 or 50%. Now issue the command:tabulate headsFor the variable heads, 1=heads 0=tails. Note how many heads you got (you willnot get the same as your classmates). This value will be displayed on the graphwhere "Number of Trials" is 100.(b) Question: How many heads did you get after 50 tosses? 75 tosses?(c) After 100 tosses, how far off were you from what you expected (50)?2. Toss the coin 100 times again. Repeat this 10 times. After each, record thenumber of heads, and how far off you were from the expected value of 50.3. Toss the coin 10 times. Repeat 10 times. After each, record how far off you werefrom the expected value.Hint: There's a faster way of repeating this experiment 10 times. Tossing a coin 10 timesis the same thing as tossing 10 coins once. So to toss a coin 10 times, you could also set"number of coins" to 10 and "number of trials" to 1.This means that if you want to toss a coin 10 times and then repeat this experiment 15times, then you could set "number of coins" to 10 and "number of trials" to 15.After you try this, type list trials heads to get a sense of how this works.4.Simulation v2.0a) Which experiment had the biggest errors, the 100-tosses or the 10-tosses? (The"errors" are the differences between what you saw and what you expected to see.)b) Now which experiment had the biggest percent-errors? The percent error is the errordivided by the number of tosses. For example, if I toss a coin 10 times, and get 7 heads,the error is 7-5 = 2. The percent error is 2/10 = .2 -- an error of 20%.5. Next we'll toss the coin 1000 times. You should expect 500 heads. BEFORE you dothis, answer these questions:a) Will the error generally be more or less than when you did 100 tosses? Why?b) Will the percent error generally be more or less than when you did 100 tosses?Why?Now toss 1000 coins, and repeat 10 times. Each time, record the number of heads, theerror, and the percent error.You'll see that at each "trial", 1000 fair coins were tossed, and you'll see (in the "heads"column) the number of heads that resulted. This was repeated 10 times.At each trial we expected 500 heads. The


View Full Document

UCLA STATS 13 - LabSimulation

Documents in this Course
lab8

lab8

3 pages

lecture2

lecture2

78 pages

Lecture 3

Lecture 3

117 pages

lecture14

lecture14

113 pages

Lab 3

Lab 3

3 pages

Boost

Boost

101 pages

Noise

Noise

97 pages

lecture10

lecture10

10 pages

teach

teach

100 pages

ch11

ch11

8 pages

ch07

ch07

12 pages

ch04

ch04

10 pages

ch07

ch07

12 pages

ch03

ch03

5 pages

ch01

ch01

7 pages

ch10

ch10

7 pages

Lecture

Lecture

2 pages

ch06

ch06

11 pages

ch08

ch08

5 pages

ch11

ch11

9 pages

lecture16

lecture16

101 pages

lab4

lab4

4 pages

ch01

ch01

7 pages

ch08

ch08

5 pages

lecture05

lecture05

13 pages

Load more
Download LabSimulation
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view LabSimulation and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view LabSimulation 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?