Skip to content

Generate Samples with a Variety of Probability Distributions

License

Unknown, MIT licenses found

Licenses found

Unknown
LICENSE
MIT
LICENSE.md
Notifications You must be signed in to change notification settings

nvietto/samplezoo

Repository files navigation

samplezoo

R-CMD-check CRAN status

The {samplezoo} package simplifies the generation of samples from various probability distributions, enabling users to quickly create datasets for demonstrations, troubleshooting, or teaching. By prioritizing simplicity and speed over the customization of sample parameters, {samplezoo} is ideal for beginners or anyone looking to save time when working with data.

Installation

{samplezoo} is available on CRAN. Install using:

install.packages("samplezoo")

You can install the development version of samplezoo from GitHub with:

# install.packages("pak")
pak::pak("nvietto/samplezoo")

Example

Generating a dataset with various probability distributions typically looks like this:

numeric_data <- data.frame(
      norm = rnorm(n = 100, mean = 50, sd = 15),
      norm_2 = rnorm(n = 100, mean = 60, sd = 10),
      norm_3 = rnorm(n = 100, mean = 40, sd = 20),
      binom = rbinom(n = 100, size = 1, prob = 0.50),
      neg = rnbinom(n = 100, size = 1, prob = 0.50),
      pois = rpois(n = 100, lambda = 3),
      exp = rexp(n = 100, rate = 0.10),
      unif = runif(n = 100, min = 0, max = 1),
      beta = rbeta(n = 100, shape1 = 2, shape2 = 5),
      gamma = rgamma(n = 100, shape = 2, scale = 2),
      chi_sq = rchisq(n = 100, df = 2),
      t_dist = rt(n = 100, df = 10),
      f_dist =rf(n = 100, df1 = 10, df2 = 10)
)

numeric_data <- round(numeric_data, 2)

head(numeric_data)
   norm norm_2 norm_3 binom neg pois   exp unif beta gamma chi_sq t_dist f_dist
1 66.79  63.18  66.08     0   0    1 28.54 0.39 0.20  4.80   1.61  -1.10   3.82
2 80.03  65.25   8.39     1   2    3 24.53 0.67 0.11  1.10   0.31  -0.64   4.31
3 48.30  47.15  21.83     1   0    0 11.26 0.58 0.24  1.84   3.93  -0.39   1.10
4 21.60  73.66  42.65     0   3    3 19.43 0.97 0.48  3.34   0.35   2.07   1.56
5 35.90  66.99  47.41     1   1    2  2.19 0.88 0.52  2.79   0.89   0.86   1.10
6 74.36  52.17   6.67     0   2    2 14.61 0.26 0.19  2.39   7.33   0.35   0.87

With {samplezoo}, you can use one line of code:

library(samplezoo)

small_data <- samplezoo("small")

small_data <- round(small_data, 2)

head(small_data)
   norm norm_2 norm_3 binom neg pois   exp unif beta gamma chi_sq t_dist f_dist
1 75.33  50.06  43.18     1   0    3 31.23 0.05 0.17  5.96   1.01   0.02   1.28
2 43.76  52.50   9.47     1   0    4  9.96 0.23 0.36  3.39   1.49  -0.70   1.15
3 44.48  61.26  22.44     0   1    3  1.18 0.17 0.41  4.99   0.47   0.42   0.78
4 47.62  56.66  22.36     1   0    6  6.27 0.43 0.22  0.66   3.54   0.99   0.72
5 55.92  46.84  59.63     0   1    3  0.54 0.94 0.33  5.86   4.26  -1.05   2.06
6 39.56  76.65  43.02     0   1    1 18.88 0.55 0.40  9.11   0.37   1.82   1.78

About

Generate Samples with a Variety of Probability Distributions

Resources

License

Unknown, MIT licenses found

Licenses found

Unknown
LICENSE
MIT
LICENSE.md

Stars

Watchers

Forks

Packages

No packages published

Languages