| Eddington | R Documentation |
The class will maintain the state of the algorithm, allowing for efficient updates as new rides come in.
The implementation uses an experimental base R feature utils::hashtab.
Cloning of Eddington objects is disabled. Additionally, Eddington objects
cannot be serialized; they cannot be carried between sessions using
base::saveRDS or base::save and then loaded later using base::readRDS
or base::load.
currentThe current Eddington number.
cumulativeA vector of cumulative Eddington numbers.
number_to_nextThe number of rides needed to get to the next Eddington number.
nThe number of rides in the data.
hashmapThe hash map of rides above the current Eddington number.
new()Create a new Eddington object.
Eddington$new(rides, store.cumulative = FALSE)
ridesA vector of rides
store.cumulativelogical, indicating whether to keep a vector of cumulative Eddington numbers
A new Eddington object
print()Print the current Eddington number.
Eddington$print()
update()Add new rides to the existing Eddington object.
Eddington$update(rides)
ridesA vector of rides
getNumberToTarget()Get the number of rides of a specified length to get to a target Eddington number.
Eddington$getNumberToTarget(target)
targetTarget Eddington number
An integer representing the number of rides of target length needed to achieve the target number.
isSatisfied()Test if an Eddington number is satisfied.
Eddington$isSatisfied(target)
targetTarget Eddington number
Logical
# Randomly generate a set of 15 rides
rides <- rgamma(15, shape = 2, scale = 10)
# View the rides sorted in decreasing order
stats::setNames(sort(rides, decreasing = TRUE), seq_along(rides))
# Create the Eddington object
e <- Eddington$new(rides, store.cumulative = TRUE)
# Get the Eddington number
e$current
# Update with new data
e$update(rep(25, 10))
# See the new data
e$cumulative
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.