beta_arm: A beta distribution sampler using R

Description Usage Arguments Value Examples

View source: R/beta_arm.R

Description

a function to generate a random sample of size n from the Beta(a, b) distribution by the acceptance-rejection method

Usage

1
beta_arm(n, a, b)

Arguments

n

the number of samples

a

the first parameter of function 'beta'

b

the second parameter of function 'beta'

Value

a random sample of size n

Examples

1
2
3
4
5
sample_beta <- beta_arm(1000,3,2)
head(sample_beta,20)
sample_beta_theo <- rbeta(1000,3,2)
data_beta <- data.frame(sample = c(sample_beta,sample_beta_theo),class = rep(c('empirical','theoretical'),each = 1000))
ggplot(data_beta,aes(x = sample,fill = class))+geom_histogram(position="identity", alpha=0.5)

pikachuuu108/StatComp18018 documentation built on May 19, 2019, 9:38 p.m.