Getting familiar with the basic properties of the beta distribution
library(dplyr)
##
## Attaching package: 'dplyr'
##
## The following objects are masked from 'package:stats':
##
## filter, lag
##
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
library(ggplot2)
library(e1071)
alpha <- 600
beta <- 400
s1 <- rbeta(1000, alpha, beta)
ggplot(data.frame(s1), aes(x=s1)) + geom_freqpoly()
## stat_bin: binwidth defaulted to range/30. Use 'binwidth = x' to adjust this.
sum(s1)/length(s1)
## [1] 0.6002
mean(s1) # this is computed in cov.c, hence different rounding than above
## [1] 0.6002
alpha/(alpha+beta)
## [1] 0.6
sum((s1 - mean(s1))^2)/length(s1)
## [1] 0.000249
var(s1)
## [1] 0.0002493
(alpha*beta)/((alpha+beta)**2*(alpha + beta + 1))
## [1] 0.0002398
skewness(s1)
## [1] -0.1312