Description Usage Arguments Details Value Examples
meandr()
offers a calculus-driven approach to simulating random time-series behavior.
Inputs n_nodes
and wt
serve as tuning knobs for overall smoothness and direction, respectively.
For greater control over curve shape, see create_path()
1 2 3 4 5 6 7 8 |
n_nodes |
An integer. Defines number of distinct inflection points in function. |
wt |
A numeric vector of values. These will be sampled (with replacement) |
gain |
Tuning parameter. |
n_points |
An integer. Controls output "resolution". (Underlying calculus is unaffected). |
scale |
A number. Adjusts all y-values so that |
seed |
A number passed to |
For wt
, recommend using length 2
comprising of positive and negative element -
though any numeric vector will be accepted.
Default value, c(1, -1)
, will tend to produce curves with greatest directional variety.
As magnitude between wt[1]
and wt[2]
deviates, overall curve will veer to +/- Inf
.
Each call to meandr()
follows below execution flow:
(1) Build piecewise function, "f2", of "nodes" sampled (with replacement) from wt
.
(2) Integrate "f2" twice to obtain continuously differentiable function, "f".
(3) Interval (0, 1] is cut into n_points
- resulting values passed to "f".
(4) Output coordinates in tibble
A tibble
containing coordinates of resulting function.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | # See vignette("meandr")
# each call produces unique output
meandr()
# use meandr::mplot for quick plotting
mplot(meandr())
# n_nodes has the most impact on curve complexity
curve1 <- meandr(n_nodes = 5)
mplot(curve1) # simple piecewise quadratic
curve2 <- meandr(n_nodes = 200)
mplot(curve2) # more meandering!
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.