rv: Make a discrete random variable.

Description Usage Arguments Value Examples

Description

Make a discrete random variable.

Usage

1
rv(x, probs = NULL)

Arguments

x

a numeric vector giving the values of the random variable.

probs

optional, a numeric vector giving the probabilities corresponding to each x value. If not specific, assumes all outcomes are equally likely

Value

An S3 object of class rv.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
dice <- rv(1:6)
P(dice > 3)
E(dice)
P(dice > dice + 1)

coin <- rv(c("H", "T"))
# Event that you flip a head:
coin == "H"
# Game where you win $1 if you get a head, lose $1 if you get a tail
rif(coin == "H", 1, -1)

almartin82/rv2alm documentation built on May 10, 2019, 10:25 a.m.