discrete  R Documentation 
A movie to illustrate how the probability mass function (p.m.f.) and cumulative distribution function (c.d.f.) of a discrete random variable depend on the values of its parameters.
discrete(
distn,
var_support = NULL,
params = list(),
param_step = list(),
param_range = list(),
p_vec = NULL,
smallest = 0.01,
plot_par = list(),
panel_plot = TRUE,
hscale = NA,
vscale = hscale,
observed_value = NA,
...
)
distn 
Either a character string or a function to choose the discrete random variable. Strings Valid functions are set up like a standard distributional function
If 
var_support 
A numeric vector. Can be used to set a fixed set of
values for which to plot the p.m.f. and c.d.f., in order better
to see the effects of changing the parameter values or to set a support
that isn't a subset of the integers.
If 
params 
A named list of initial parameter values with which to start
the movie. If If If parameter value is outside the corresponding range specified by

param_step 
A named list of the amounts by which the respective
parameters in 
param_range 
A named list of the ranges over which the respective
parameters in 
p_vec 
A numeric vector of length 2. The p.d.f. and c.d.f. are
plotted between the 100 
smallest 
A positive numeric scalar. The smallest value to be
used for any strictly positive parameters when 
plot_par 
A named list of graphical parameters
(see 
panel_plot 
A logical parameter that determines whether the plot
is placed inside the panel ( 
hscale , vscale 
Numeric scalars. Scaling parameters for the size
of the plot when 
observed_value 
A nonnegative integer. If 
... 
Additional arguments to be passed to

The movie starts with a plot of the p.m.f. of the distribution for the initial values of the parameters. Buttons increase (+) or decrease () each parameter. There are radio buttons to switch the plot from the p.m.f. to the c.d.f. and back.
If distn == "geometric"
then there are radio buttons to switch
between the version of the the geometric distribution based on the
number of trials up to including the first success and the number of
failures until the first success.
Owing to a conflict with the argument size
of the function
rp.control
the parameter size
of,
for example, the binomial and negative binomial distributions, is
labelled as n
.
Nothing is returned, only the animation is produced.
movies
: a userfriendly menu panel.
smovie
: general information about smovie.
# Binomial example
discrete()
# The same example, but using a usersupplied function and setting manually
# the initial parameters, parameter step size and range
discrete(distn = dbinom, params = list(size = 10, prob = 0.5),
param_step = list(size = 1),
param_range = list(size = c(1, NA), prob = c(0, 1)))
# Poisson distribution. Show the use of var_support
discrete(distn = "poisson", var_support = 0:20)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.