
Tidy Randomly Generated Negative Binomial Distribution Tibble
Source:R/random-tidy-negative-binomial.R
tidy_negative_binomial.RdThis function will generate n random points from a negative binomial
distribution with a user provided, .size, .prob, and number of
random simulations to be produced. The function returns a tibble with the
simulation number column the x column which corresponds to the n randomly
generated points, the d_, p_ and q_ data points as well.
The data is returned un-grouped.
The columns that are output are:
sim_numberThe current simulation number.xThe current value ofnfor the current simulation.yThe randomly generated data point.dxThexvalue from thestats::density()function.dyTheyvalue from thestats::density()function.pThe values from the resulting p_ function of the distribution family.qThe values from the resulting q_ function of the distribution family.
Arguments
- .n
The number of randomly generated points you want.
- .size
target for number of successful trials, or dispersion parameter (the shape parameter of the gamma mixing distribution). Must be strictly positive, need not be integer.
- .prob
Probability of success on each trial where 0 < .prob <= 1.
- .num_sims
The number of randomly generated simulations you want.
Details
This function uses the underlying stats::rnbinom(), and its underlying
p, d, and q functions. For more information please see stats::rnbinom()
See also
https://openacttexts.github.io/Loss-Data-Analytics/ChapSummaryDistributions.html
Other Discrete Distribution:
tidy_bernoulli(),
tidy_binomial(),
tidy_hypergeometric(),
tidy_poisson(),
tidy_zero_truncated_binomial(),
tidy_zero_truncated_negative_binomial(),
tidy_zero_truncated_poisson()
Other Binomial:
tidy_binomial(),
tidy_zero_truncated_binomial(),
tidy_zero_truncated_negative_binomial(),
util_binomial_param_estimate(),
util_binomial_stats_tbl(),
util_negative_binomial_param_estimate()
Examples
tidy_negative_binomial()
#> # A tibble: 50 × 7
#> sim_number x y dx dy p q
#> <fct> <int> <int> <dbl> <dbl> <dbl> <dbl>
#> 1 1 1 8 -8.29 0.000125 0.613 8
#> 2 1 2 0 -6.95 0.000513 0.1 0
#> 3 1 3 2 -5.62 0.00171 0.271 2
#> 4 1 4 29 -4.28 0.00470 0.958 29
#> 5 1 5 4 -2.94 0.0108 0.410 4
#> 6 1 6 14 -1.60 0.0207 0.794 14
#> 7 1 7 1 -0.262 0.0340 0.190 1
#> 8 1 8 7 1.08 0.0481 0.570 7
#> 9 1 9 4 2.41 0.0590 0.410 4
#> 10 1 10 2 3.75 0.0636 0.271 2
#> # ℹ 40 more rows