probs: Generate a Random Vector of Probabilities.

Description Usage Arguments Value Examples

View source: R/probs.R

Description

Generate a random vector of probabilities that sum to 1.

Usage

1
probs(j, upper = 1e+06)

Arguments

j

An integer of number of probability elements (typically performs best at j < 4000).

upper

probs works by sampling from 1:upper j times and then dividing each sample by the sum of all samples.

Value

Returns a vector of probabilities summing to 1.

Examples

1
2
3
probs(10)
sum(probs(100))
pie(table(month(10000, prob = probs(12))))

Example output

 [1] 0.08146402 0.03100816 0.18286120 0.13811748 0.19214272 0.10787875
 [7] 0.03805287 0.17992465 0.03442538 0.01412477
[1] 1

wakefield documentation built on Sept. 14, 2020, 1:07 a.m.