How to do it...

Generating a simulated dataset to represent a background can be done using the following steps:

  1. Make a random dataset with the same characteristics as a given set:
library(fakeR)
fake_iris <- simulate_dataset(iris)
  1. Make a vector of normal random numbers with the mean and standard deviation of a given vector:
sample_mean <- mean(iris$Sepal.Length)
sample_sd <- sd(iris$Sepal.Length)
random_sepal_lengths <- rnorm(iris$Sepal.Length, mean = sample_mean, sd = sample_sd)
hist( random_sepal_lengths)
  1. Make a vector of uniform random integers in a range:
low_num <- 1
high_num <- 6
hist(runif(1500, low_num, high_num))

  1. Make a vector of the number of binomial successes:
number_of_coins <- 1
p_heads <- 0.5
hist(rbinom(1500, number_of_coins, p_heads ))
number_of_coins <- 5
hist(rbinom(1500, number_of_coins, p_heads ))
  1. Make a vector of random selections from a list, with a different probability for each:
random_from_list <- sample(c("Low", "Medium", "High"), 100, replace = TRUE, prob = c(0.2, 0.6, 0.2))
table(random_from_list)
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.138.123.238