
Last chance! 50% off unlimited learning
Sale ends in
To begin, define a two dimensional function that outputs
a two-dimensional list. For instance:
fun <- function(x,y) list(x,y)
. Then
dsmodel(fun)
will initialize the model.
Make sure that the function defining your model indeed outputs a list
.
The model is used to hold the data for graphics.
To display a desired graphic, add the corresponding
feature of type "dsproto" to your model.
dsmodel(fun, title = "", display = TRUE)
Function with two inputs and two outputs which defines the dynamical system. The output should be a list, preferably with field names x and y.
A string title for the graph. Text can be input in the form of pseudo-LaTeX code within quotes.
See TeX
for more details.
If set to FALSE
, the model will be drawn only when the user calls `MODELNAME`$display()
. Otherwise,
the model will be drawn with every dsmodels
object added after the dsrange
is added.
dsmodel
objects support the following methods, which may be helpful for advanced users.
dsmodel$points(format="list", filter="all")
returns a list of the points in the model.
filter
Valid values are "all"
, "fixed"
, "attractor"
, and "sim"
.
"sim"
returns only points generated by simattractors
.
format
If "list"
, return a list with x
, y
, col
, and ind
fields holding
the coordinates, color, and index. Other formats are "objects"
, returning a vector of dspoint
objects,
and "pairs"
, returning a list of pairs of coordinates.
dsmodel$display()
forces the model to re-render the plot from scratch. Primarily useful if display=TRUE
was set.
dsmodel$basins()
returns a list of which fixed points have a basin. This requires simbasins()
to have been composed
with the model, and is primarily useful when testing if a dynamical system is globally stable. In that case, the method
will return a list of length 1. The list will contain the indices of the fixed points, as given in
dsmodel$points(format="list", filter="attractor")
. An index of 0 means that some points never moved within
epsilon of an attractor.
dsmodel$sim.is.stable()
attempts to determine if the system is stable by simulation. If no attractors have
been composed with the model, simattractors()
is composed with defaults. If simbasins
has not
been composed with the model, it is be composed with defaults. If every point is drawn to a single attractor, the
system has been deemed stable. Note that boundary points on the range will not be tested.
Models are constructed
incrementally using the + operator to add features
to the existing dsmodel object. A dsrange
must be one of the objects added to a model.
# NOT RUN {
library(dsmodels)
fun <- function(X,Y) {
list(
x = X/exp(Y),
y = Y/exp(X)
)
}
# Add dsRange to see the actual range.
model <- dsmodel(fun)
dsmodel(function(x,y) {
list(
x = x^2,
y = x/(y+1)
)
}, title = "Another function showing $f(x)=x^{\\alpha}$!")
# }
Run the code above in your browser using DataLab