# Packages List
library("psych")
The law of large numbers simply states that if you repeat an independent event a large number of times, the average of all the results are close to the expected value. It describes the mean of a random variable as the sample size increases.
Strong Law of Large Numbers (SLLN): It states that as the sample size increases, the sample mean converges to the expected value of the random variable.
Weak Law of Large Numbers (WLLN): states that as the sample size increases, the sample mean of those observations will converge in probability to the expected value of the random variable.
The central limit theorem established that in many situations for independent and identically distributed random variables, the sampling distribution of the sample mean tends towards the standard normal distribution, even if the original variables are not normally distributed.
Both the law of large numbers and central limit theorem are about many independent samples from same distribution.
The CLT states that when sample size tends to infinity, the sample mean will be normally distributed but the law of large numbers states that when sample size tends to infinity, the sample mean equals to population mean.
CLT talks about the shape of the distribution and LLN talks about the mean.
The gamma distribution is a two-parameter family of continuous probability distributions. The exponential distribution, Erlang distribution, and chi-squared distribution are special cases of the gamma distribution. This distribution has two equivalent ways of parameters
set.seed(42)
gam <- rgamma(n = 10000,
1,
1)
mu <- mean(gam)
mu
## [1] 1.002173
sigma <- sd(gam)
sigma
## [1] 0.9972717
describe(gam)
## vars n mean sd median trimmed mad min max range skew kurtosis se
## X1 1 10000 1 1 0.7 0.83 0.72 0 10.84 10.84 1.97 5.74 0.01
hist(x = gam,
xlab = "")
z <- matrix(data = rep(x = 0,
times = 10000),
nrow = 10000,
ncol = 1)
z[1:16]
## [1] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
for (i in 1:10000){
z[i,] <- mean(sample( x = gam,
size = 100,
replace = TRUE))}
hist(z, xlab = "")
quantile(gam, .10)
## 10%
## 0.1027352
z2 <- matrix(data = rep(x = 0,
times = 10000),
nrow = 10000,
ncol = 1)
for (i in 1:10000){
z2[i,] <- quantile(sample(x = gam,
size = 100,
replace = TRUE), .10)}
z2[1:8]
## [1] 0.15111065 0.10923818 0.09218033 0.13892926 0.13542205 0.08505860 0.13307067
## [8] 0.14424089
describe(z2)
## vars n mean sd median trimmed mad min max range skew kurtosis se
## X1 1 10000 0.11 0.04 0.11 0.11 0.03 0.02 0.29 0.27 0.69 0.6 0
hist(z2, xlab = "")