Closed gvwilson closed 6 years ago
@gvwilson Do you still want this? There are examples for each step of the speccing process, so do you need to have a complete example as well?
I don't think so, especially now that we have an example of a complete R spec.
From Dave Robinson's Stochastic Processes in R:
Stochastic Processes in R
Step 1: Brainstorming
sample
,cumsum
,replicate
, andaccumulate
functionsStep 2: Who is this course for?
Link to student profiles. If these don't match exactly, feel free to modify as needed in discussion:
Step 3: How far will this course get its students?
This could be similar to the last exercise of the course or a last exercise in a chapter.
Last exercise in Chapter 2: Write a function that simulates 100 steps from a Markov chain of words, given a
transition_matrix
with row and column names.Skills:
sample
withprob
to find the next state in a transition matrixaccumulate
to save up many steps in a chainSolution:
Last exercise in the course: Write a function that, given a number of points, the width of a region, and the height of a region, generate that many points in a Poisson point process.
Use it to plot 50 points in the space of 10 x 10.
Skills required:
rpois
runif
, twiceplot
to compare andx
andy
(we'd give scaffolding).Solution
Step 4: What will the student do along the way?
Middle of chapter 2: Generate three steps in a Markov chain given a transition matrix and starting state.
Solution:
Middle of chapter 4: Randomly generate 100 events in a one-dimensional Poisson process with a rate of 3 per second by simulating exponential waiting times. Find the distribution of how many events happen in the first 2 seconds.
Solution:
Step 5: How are the concepts connected? (Course outline)
Chapter 1: Random walks
Lesson 1.1 - Random walks: Imagine you were gambling with a friend, and betting on a coin. Each time you either lose one dollar or gain one dollar. This is a random walk: at any moment, it could go up or down one step.
sample()
, and find the cumulative position withcumsum()
.plot()
, which looks a bit like a stock price graph.Lesson 1.2 - Biased random walk: So far the random walk has been symmetrical, with an equal probability of gaining or losing.
Lesson 1.3 - Properties of a random walk: Where will a random walk end up after 10 steps? 100 steps?
replicate()
for simulating it.Chapter 2: Markov chains
Lesson 2.1 - Transition matrices
Lesson 2.2 - One step in a Markov chain
sample(2, 1, prob = transition_matrix[state, ])
lets you randomly stepLesson 2.3 - Accumulating steps in a chain
purrr
accumulate function to add up states into a chain.Lesson 2.4 - Example: Markov chain of words
Chapter 3: The exponential distribution
rexp
to simulateexp_greater_5 <- exp_sample[exp_sample >= 5]
, then examine the properties and distribution ofexp_greater_5
.sum(rexp(3, 5))
Chapter 4: Poisson processes
cumsum
ruinf
.Step 6: Course overview
Course Description
Whether it's prices in the stock market, the number of visitors to a website, or the population of rabbits in a forest, many phenomena that we'd like to model with statistics involved numbers tracked over time. In this course, you'll be introduced to the field of stochastic processes, an area of probability studying systems that change over time. You'll learn about common statistical models such as random walks, Poisson processes, and Markov chains, as well as being introduced to the exponential and gamma distributions. These provide the fundamentals for many statistical methods common in finance, biology, and many other fields.
Learning Objectives
Prerequisites