Riddler: Simulating a Circular Random Walk

Simulation

Published

November 22, 2020

Notable topics: Simulation

Recorded on: 2020-11-22

Timestamps by: Alex Cookson

View code

Screencast

Timestamps

samplecumsum

Using sample() and cumsum() to simulate a random walk

%%

Using %% (modulo operator) to "close" the circle (set the number of people in the circle)

crossing

Using crossing function to set up "tidy" simulation (gives you all possible combinations of values you provide it)

distinct

Using distinct function and its .keep_all argument to get only the first unique set of the variables you give it

Visualizing the number of steps it takes for the sauce to reach people at differents seats

Visualizing the distribution of number of steps it takes to reach each seat

Investigating the parabolic shape of average number of steps to reach a given seat

lmI

Using lm and I functions to calculate formula of the parabola describing average number of steps

Starting to vary the size of the table

Summary of screencast