prob (version 1.0-1)

prob: Probability and Conditional Probability

Description

Calculates probability and conditional probability of events.

Usage

Prob(x, …)

# S3 method for default Prob(x, event = NULL, given = NULL, …)

# S3 method for ps Prob(x, event = NULL, given = NULL, …)

Arguments

x

a probability space or a subset of one.

event

logical expression indicating elements or rows of space to keep: missing values are taken as false.

given

either a subset of a probability space or a logical expression indicating elements or rows of space to keep: missing values are taken as false.

further arguments to be passed to or from other methods.

Value

A number in the interval [0,1].

Details

This function calculates the probability of events or subsets of a given sample space. Conditional probability is also implemented. In essence, the Prob() function operates by summing the probs column of its argument. It will find subsets on the fly if desired.

The event argument is used to define a subset of x, that is, the only outcomes used in the probability calculation will be those that are elements of x and satisfy event simultaneously. In other words, Prob(x,event) calculates Prob(intersect(x, subset(x, event))). Consequently, x should be the entire probability space in the case that event is non-null.

There is some flexibility in the given argument in that it can be either a data frame or it can be a logical expression that defines the subset. However, that flexibility is limited. In particular, if given is a logical expression, then event must also be specified (also a logical expression). And in this case, the argument x should be the entire sample space, not a subset thereof.

See Also

probspace, iidspace

Examples

Run this code
# NOT RUN {
S <- rolldie(times = 3, makespace = TRUE )
Prob(S, X1+X2 > 9 )
Prob(S, X1+X2 > 9, given = X1+X2+X3 > 7 )
# }

Run the code above in your browser using DataCamp Workspace