Learn R Programming

DNAprofiles (version 0.3.1)

dists.product: Distribution of product of several discrete random variables

Description

Distribution of product of several discrete random variables

Usage

dists.product(dists, n.max = 1e+08, return.cumdist = FALSE)

Arguments

dists
a list of distributions
n.max
memory limit, distribution will not be obtained when number of mass points exceeds n.max
return.cumdist
when TRUE, returns the cumulative distribution

Value

list with named numeric vectors x and fx (or Fx when return.cumdist==TRUE), denoting respectively the events and probabilities of the discrete distribution.

Examples

Run this code
# x is a fair die, i.e. has probability distribution:
die <- list(x=1:6,fx=rep(1/6,6))

# we have 5 of them
dists <- replicate(5,die,simplify=FALSE)

# what is the distribution of x1*x2*x3*x4*x5?
prod.dist <- dists.product(dists)

plot(prod.dist$x,prod.dist$fx,xlab="x1*x2*x3*x4*x5",ylab="fx",type="h")

Run the code above in your browser using DataLab