Presentation is loading. Please wait.

Presentation is loading. Please wait.

Some (Pseudo-) Random Number Stuff in R

Similar presentations


Presentation on theme: "Some (Pseudo-) Random Number Stuff in R"— Presentation transcript:

1 Some (Pseudo-) Random Number Stuff in R

2 Use runif to make a “vector” of Random numbers with a uniform distribution
Uniform means the number is as likely to fall between 0.1 and 0.2 as between 0.5 and 0.6, and so on. As opposed to a normal distribution around of mean of 0.5, then it is more likely to be close to the mean.

3 Result a vector with 100 “elements” or “components”

4 Apply some of the statistical methods to the vector.

5 Using the ifelse() method to turn the uniform numbers into a coin-toss simulation

6 Another way of simulating a coin toss in R using sample

7 The table method gets us the frequencies

8 The replace=TRUE part puts a value back into the set after it is picked. It allows duplications

9 The replace=FALSE part does not put a value back into the set after it is picked. It prevents duplications

10 If the range is 1 to 6 and replace=TRUE we have simulated 100 die rolls. Then the table method yields the frequencies

11 You can make a fast histogram of the die roll simulation by entering hist(dice)

12 Adding a breaks “argument” a sequence from 0. 5 to 6
Adding a breaks “argument” a sequence from 0.5 to 6.5 made the histogram a little nicer


Download ppt "Some (Pseudo-) Random Number Stuff in R"

Similar presentations


Ads by Google