Unit 4: Topics covered in videos

  • randi. (randi. Choosing random integers and putting them into a vector or matrix.)
  • Dice. (A first example of using repeated experiments to estimate a probability and to estimate an expected value. The probability we estimate is, if we roll 3 6-sided dice, what's the probability that one of them is a 5? The expected value we estimate is, if we roll 3 6-sided dice, what's the expected value of the biggest roll?)
  • Probability that a vector is sorted. (sort, all. Simulating the following experiment many times: make a length 5 vector of random integers from 1 to 3. What's the probability that the vector is sorted? Uses the estimate (number of successes)/(number of experiments).)
  • Expected length. (Estimating the expected outcome of the following experiment. Make a vector of 10 random integers from 1 to 30, then delete all the numbers which appear more than once. How long is the remaining vector? Our strategy was to go through each integer 1 to 30 and see if it appeared in the vector; can you think of a faster way?)
  • More random numbers. (How to randomly choose either -1 or 1? We can't use randi([-1,1]) because that can also choose 0. Using rand, as opposed to randi, to help choose random numbers with different weights. Using sum(v==0) to count how many entries in a v are equal to 0.)
  • Random walks with for loops. (A random walk starts at 0, and then repeatedly adds a random choice of 1 or -1. For this first sort of random walk, we use a for loop to make random walks of a fixed length.)
  • Random walks with while loops. (For this sort of random walk, we use a while loop to make a random walk where the walk continues until we are a certain distance from the origin. How to make the condition "not a distance of n from the origin"? One way using &&, another way using absolute value.)
  • Expected distance. (Writing a function to estimate the expected distance from the origin of a length n random walk.)
  • Formula for expected distance. (Making a script to plot the values produced by our expected distance estimate in comparison to a crazy looking formula involving the square root of pi.)