# RV: Make a random variable consisting of possible outcome values... In discreteRV: Create and Manipulate Discrete Random Variables

## Description

Make a random variable consisting of possible outcome values and their probabilities or odds

## Usage

 ```1 2 3``` ```RV(outcomes, probs = NULL, odds = NULL, fractions = (class(probs) != "function"), range = any(is.infinite(outcomes)), verifyprobs = TRUE, id = rnorm(1), ...) ```

## Arguments

 `outcomes` Vector of possible outcomes `probs` Vector of probabilities or function defining probabilities `odds` Vector of odds `fractions` If TRUE, return the probabilities as fractions when printing `range` If TRUE, outcomes specify a range of values in the form c(lower, upper) `verifyprobs` If TRUE, verify that the probs sum to one `id` Set the id of the random variable `...` Additional parameters passed to the function defining outcome probabilities

## Value

random variable as RV object.

## Examples

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24``` ```# Make a 50:50 Bernoulli random variable: X.Bern <- RV(c(1,0), c(.5,.5)) # An equivalent method X.Bern <- RV("bernoulli") # Make a fair coin flip game with payoffs +\$1 and -\$1: X.fair.coin <- RV(c(1,-1), c(.5,.5)) # Make a biased coin flip game with odds 1:2 and with fair payoffs +\$2 and -\$1 X.biased.coin <- RV(c(2,-1), odds = c(1,2)) # Make a fair die X.fair.die <- RV(1:6, 1/6) # Make a loaded die, specifying odds 1:1:1:1:2:4 rather than probabilities: X.loaded.die <- RV(1:6, odds = c(1,1,1,1,2,4)) # Make a Poisson random variable pois.func <- function(x, lambda) { lambda^x * exp(-lambda) / factorial(x) } X.pois <- RV(c(0, Inf), pois.func, lambda = 5) # An equivalent method X.pois <- RV("poisson") ```

### Example output

```Attaching package: 'discreteRV'

The following object is masked from 'package:base':

%in%
```

discreteRV documentation built on May 2, 2019, 11:04 a.m.