knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "100%",
  dpi = 300,
  type = 'cairo'
)

library(ggplot2)
library(dplyr)
set.seed(17)
theme_set(theme_minimal())

plot_f <- function(df) {
  ggplot(df, aes(t, f)) +
    geom_point(color = "#175C4A") +
    geom_line(color = "#175C4A")
}

meandr

R build status Travis build status

meandr allows for easy generation of coordinates that are random, yet continuously differentiable. This is particularly useful for simulating time-series measurements of physical phenomena that maintain a clear local trajectory.

Installation

``` {r install, eval = FALSE} devtools::install_github("sccmckenzie/meandr")

## Why meandr?

Suppose we want to simulate behavior of a "somewhat random" time-series phenomenon.

* Outdoor temperature
* Train station crowd density
* Stock price

Although we can't predict the exact values of these examples, we know how they will behave to a certain extent. For instance, outdoor temperature is not going to drop by 100 degrees in 1 second.

We could use method #1 below:

```r
method_1 <- data.frame(t = 1:100,
                       f = rnorm(100))
plot_f(method_1) +
  labs(title = "Random coordinates using rnorm()")

The above data doesn't exhibit any prolonged directional consistency. This may not adequately emulate the character of the above examples.

meandr offers a solution to this problem. Each call to meandr() generates a unique tibble of t and f coordinates. For reproducibility, a seed argument is provided.

library(meandr)

df1 <- meandr(n_points = 100,
              n_nodes = 20,
              seed = 2)

df1
plot_f(df1) +
  labs(title = "meandr()", subtitle = "Example Output")

Observe df1 curve trajectory never radically changes between two points. This is a key feature of meandr: all curves are continuously differentiable.



sccmckenzie/meandr documentation built on May 5, 2021, 4:23 a.m.