geyser: A Simple Geyser simulation

Description Usage Arguments Details Value Functions Examples

Description

This function simulates the geyser scenario described in FiveThirtyEight's Riddler. The simulation is built from several support functions. They are all documented together.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
geyser(...)

## S3 method for class 'geyser'
simulate(object, n, timeframe = NULL, seed = NULL)

eruptions(rate, timeframe)

geysers(rates, timeframe)

first_eruption(geysers, arrival)

count_v(level, vector)

count_seq(vector, levels)

## S3 method for class 'simulate.geyser'
summary(object, nwindows = 11)

## S3 method for class 'summary.geyser'
print(object)

## S3 method for class 'geyser'
autoplot(object)

Arguments

n

The number of iterations in a simulation

timeframe

The time window for the eruptions; default is maximum rate

rates

A named list of eruption rates. The names identify the geysers, and the values identify the number of hours between eruptions

Details

The problem states that you arrive at a national park, knowing that three geysers erupt at fixed intervals. You do not know when these intervals begin. What are the probabilites that each geyser erupts first? The blog post for this function solved the problem analytically. This code simulates the scenario to arrive at a solution.

Value

A geyser objection containing the following:

counts

a data frame tracking which geyser erupts first each simulation

frequencies

a data frame that counts relative rates: count / n simulations

first_eruption

a data frame of the time until each geyser's first eruption

n

the number of simulations

rates

the list of rates passed as an argument

Functions

Examples

1
2
my_geysers <- geyser(a = 2, b = 4, c = 6)
simulate(my_geysers, 10)

michaelquinn32/adventureR documentation built on May 22, 2019, 9:52 p.m.