Make me two documents please :
results in word
&
Rmdfile.
Law of Large Numbers and Central Limit Theorem Law of Large Numbers and Central Limit Theorem Samia Challal 19/05/2021 1 Law of Large numbers. If X1, X2, ..., Xn, ... is a sequence of uncorrelated random variables, each with mu and variance σ2, then lim n→+∞ P (|Xn − µ| ⩾ δ) = 0 where Xn = X1 + ... + Xn n That is Xn approaches the population mean µ as the sample size n increases in the sense of the probability measure: (X1 + ... + Xn)/n −→ µ Central limit theorem. Let X1, X2, . . . be an infinite sequence of independent random variables; each with the same distribution f(x), and finite mean µ, and variance σ2. For any numbers a and b lim n→+∞ P ( a ⩽ X − µ σ/ √ n ⩽ b ) = 1√ 2π ∫ b a e−t 2/2dt where X = (X1 + X2 + . . . + Xn n . Application. If Z ⇝ N(0, 1), then lim n→+∞ P ( a ⩽ X − µ σ/ √ n ⩽ b ) = lim n→+∞ P ( a ⩽ Z ⩽ b ) ; X − µ σ/ √ n ≈⇝ N(0, 1). We would like to illustrate these two theorems for different distributions. 2 Case of Binomial distributions: Xi are (B(1,p)) Then X = X1 + ... + Xn has a B(n, p) distribution p= 0.2 # probability of success = mean of the population mu=p s0=sqrt(p*(1-p)) # standard deviation of the population n1=10 # Number of trials n2=20 n3=50 n4=200 s1 <- c()="" s2="">-><- c()="" s3="">-><- c()="" s4="">-><- c()="" rows="1000" #="" number="" of="" simulations="" for="" (="" i="" in="" 1:rows){="" #="" gerenates="" nk,="" k="1,2,3,4" numbers="" from="" b(1,p)="" and="" take="" their="" mean="" s1[i]="mean(rbinom(n" =="" n1,="" size="1," prob="p))" s2[i]="mean(rbinom(n" =="" n2,="" size="1," prob="p))" s3[i]="mean(rbinom(n" =="" n3,="" size="1," prob="p))" s4[i]="mean(rbinom(n" =="" n4,="" size="1," prob="p))" }="" #="" prepare="" like="" a="" matrix="" of="" 2="" rows="" and="" 2="" columns="" where="" the="" graphs="" will="" be="" inserted="" in="" each="" cell="" par(mfrow="c(2,2))" #="" plot="" the="" histogram="" of="" the="" relative="" frequency="" of="" the="" sample="" of="" means="" s1="" where="" each="" size="" sample="" is="" n1.="" hist(s1,="" col="lightblue" ,main="paste("Sample" size=", n1), xlab =" observed="" means",ylab="Probability" ,="" freq="FALSE," probability="TRUE)" #="" plot="" the="" vertical="" line="" x="p=mean" abline(v="mu," col="red" ,lwd="2" )="" #="" plot="" the="" normal="" density="" function="" n(mu,="" s0/sqrt(n1))="" curve(dnorm(x,="" mean="mu," sd="s0/sqrt(n1))," col="green" ,="" lwd="2" ,="" add="T)" 3="" hist(s2,="" col="lightblue" ,main="paste("Sample" size=", n2), xlab =" observed="" means",ylab="Probability" ,="" freq="FALSE" )="" abline(v="mu," col="red" ,lwd="2" )="" curve(dnorm(x,="" mean="mu," sd="s0/sqrt(n2))," col="green" ,="" lwd="2" ,="" add="T)" hist(s3,="" col="lightblue" ,main="paste("Sample" size=", n3), xlab =" observed="" means",ylab="Probability" ,="" freq="FALSE" )="" abline(v="mu," col="red" ,lwd="2" )="" curve(dnorm(x,="" mean="mu," sd="s0/sqrt(n3))," col="green" ,="" lwd="2" ,="" add="T)" hist(s4,="" col="lightblue" ,main="paste("Sample" size=", n4), xlab =" observed="" means",ylab="Probability" ,="" freq="FALSE" )="" abline(v="mu," col="red" ,lwd="2" )="" curve(dnorm(x,="" mean="mu," sd="s0/sqrt(n4))," col="green" ,="" lwd="2" ,="" add="T)" 4="" sample="" size="10" observed="" means="" p="" ro="" ba="" bi="" lit="" y="" 0.0="" 0.1="" 0.2="" 0.3="" 0.4="" 0.5="" 0.6="" 0="" 2="" 4="" 6="" sample="" size="20" observed="" means="" p="" ro="" ba="" bi="" lit="" y="" 0.0="" 0.1="" 0.2="" 0.3="" 0.4="" 0.5="" 0="" 2="" 4="" sample="" size="50" observed="" means="" p="" ro="" ba="" bi="" lit="" y="" 0.0="" 0.1="" 0.2="" 0.3="" 0.4="" 0="" 4="" 8="" sample="" size="200" observed="" means="" p="" ro="" ba="" bi="" lit="" y="" 0.15="" 0.20="" 0.25="" 0.30="" 0="" 4="" 8="" the="" vertical="" line="" is="" set="" at="" the="" position="" p="0.02," the="" mean="" of="" the="" population.="" as="" n="" increases,="" the="" data="" of="" means="" clusters="" around="" p="" which="" illustrates="" well="" the="" theorem.="" this="" shows="" also="" that="" (x1="" +="" ...="" +="" xn)/n="" is="" a="" good="" point="" estimate="" for="" µ="p." another,="" remark,="" is="" the="" mound="" shape="" of="" the="" distribution.="" 5="" case="" of="" normal="" distributions:="" xi="" are="" n(0,="" 1)="" then="" (x1="" +="" ...="" +="" xn)/n="" has="" a="" n(0,="" 1/="" √="" n)="" distribution="" mu="0" s="1" #="" standard="" deviation="" n1="10" #="" number="" of="" trials="" n2="20" n3="50" n4="100" s1="">-><- c()="" s2="">-><- c()="" s3="">-><- c()="" s4="">-><- c()="" rows="1000" #="" number="" of="" simulations="" for="" (="" i="" in="" 1:rows){="" s1[i]="mean(rnorm(n" =="" n1,="" mean="0," sd="s))" #="" gerenates="" n1="" numbers="" s2[i]="mean(rnorm(n" =="" n2,="" mean="0," sd="s))" s3[i]="mean(rnorm(n" =="" n3,="" mean="0," sd="s))" s4[i]="mean(rnorm(n" =="" n4,="" mean="0," sd="s))" }="" par(mfrow="c(2,2))" hist(s1,="" col="lightblue" ,main="paste("Sample" size=", n1), xlab =" observed="" means",ylab="Probability" ,="" freq="FALSE" )="" abline(v="mu," col="red" ,lwd="2" )="" curve(dnorm(x,="" mean="mu," sd="s/sqrt(n1))," col="green" ,="" lwd="2" ,="" add="T)" hist(s2,="" col="lightblue" ,main="paste("Sample" size=", n2), xlab =" observed="" means",ylab="Probability" ,="" freq="FALSE" )="" abline(v="mu," col="red" ,lwd="2" )="" curve(dnorm(x,="" mean="mu," sd="s/sqrt(n2))," col="green" ,="" lwd="2" ,="" add="T)" hist(s3,="" col="lightblue" ,main="paste("Sample" size=", n3), xlab =" observed="" means",ylab="Probability" ,="" freq="FALSE" )="" 6="" abline(v="mu," col="red" ,lwd="2" )="" curve(dnorm(x,="" mean="mu," sd="s/sqrt(n3))," col="green" ,="" lwd="2" ,="" add="T)" hist(s4,="" col="lightblue" ,main="paste("Sample" size=", n4), xlab =" observed="" means",ylab="Probability" ,="" freq="FALSE" )="" abline(v="mu," col="red" ,lwd="2" )="" curve(dnorm(x,="" mean="mu," sd="s/sqrt(n4))," col="green" ,="" lwd="2" ,="" add="T)" sample="" size="10" observed="" means="" p="" ro="" ba="" bi="" lit="" y="" −1.0="" −0.5="" 0.0="" 0.5="" 1.0="" 0.="" 0="" 0.="" 6="" 1.="" 2="" sample="" size="20" observed="" means="" p="" ro="" ba="" bi="" lit="" y="" −0.5="" 0.0="" 0.5="" 0.="" 0="" 1.="" 0="" sample="" size="50" observed="" means="" p="" ro="" ba="" bi="" lit="" y="" −0.4="" −0.2="" 0.0="" 0.2="" 0.4="" 0.="" 0="" 1.="" 5="" sample="" size="100" observed="" means="" p="" ro="" ba="" bi="" lit="" y="" −0.2="" 0.0="" 0.2="" 0.4="" 0="" 2="" 4="" 7="" case="" of="" poisson="" distributions:="" xi="" are="" p="" (λ)="" mu="0.2" #="" p="lambda=mean" s0="mu" #="" s0="standard" deviation="" n1="10" #="" number="" of="" trials="" n2="20" n3="50" n4="100" s1="">-><- c()="" s2="">-><- c()="" s3="">-><- c()="" s4="">-><- c()="" rows="1000" #="" number="" of="" simulations="" for="" (="" i="" in="" 1:rows){="" s1[i]="mean(rpois(n" =="" n1,="" lambda="mu))" #="" gerenates="" n1="" numbers="" s2[i]="mean(rpois(n" =="" n2,="" lambda="mu))" s3[i]="mean(rpois(n" =="" n3,="" lambda="mu))" s4[i]="mean(rpois(n" =="" n4,="" lambda="mu))" }="" par(mfrow="c(2,2))" hist(s1,="" col="greenyellow" ,main="paste("Sample" size=", n1), xlab =" observed="" means",ylab="Probability" ,="" freq="FALSE" ,="" xlim="c(0,1))" abline(v="mu," col="red" ,lwd="2" )="" curve(dnorm(x,="" mean="mu," sd="s0/sqrt(n1))," col="blue" ,="" lwd="2" ,="" add="T)" hist(s2,="" col="greenyellow" ,main="paste("Sample" size=", n2), xlab =" observed="" means",ylab="Probability" ,="" freq="FALSE" ,="" xlim="c(0,1))" abline(v="mu," col="red" ,lwd="2" )="" curve(dnorm(x,="" mean="mu," sd="s0/sqrt(n2))," col="blue" ,="" lwd="2" ,="" add="T)" hist(s3,="" col="greenyellow" ,main="paste("Sample" size=", n3), xlab =" observed="" means",ylab="Probability" ,="" freq="FALSE" ,="" xlim="c(0,1))" abline(v="mu," col="red" ,lwd="2" )="" curve(dnorm(x,="" mean="mu," sd="s0/sqrt(n3))," col="blue" ,="" lwd="2" ,="" add="T)" 8="" hist(s4,="" col="greenyellow" ,main="paste("Sample" size=", n4), xlab =" observed="" means",ylab="Probability" ,="" freq="FALSE" ,="" xlim="c(0,1))" abline(v="mu," col="red" ,lwd="2" )="" curve(dnorm(x,="" mean="mu," sd="s0/sqrt(n4))," col="blue" ,="" lwd="2" ,="" add="T)" sample="" size="10" observed="" means="" p="" ro="" ba="" bi="" lit="" y="" 0.0="" 0.2="" 0.4="" 0.6="" 0.8="" 1.0="" 0="" 2="" 4="" sample="" size="20" observed="" means="" p="" ro="" ba="" bi="" lit="" y="" 0.0="" 0.2="" 0.4="" 0.6="" 0.8="" 1.0="" 0="" 2="" 4="" sample="" size="50" observed="" means="" p="" ro="" ba="" bi="" lit="" y="" 0.0="" 0.2="" 0.4="" 0.6="" 0.8="" 1.0="" 0="" 4="" sample="" size="100" observed="" means="" p="" ro="" ba="" bi="" lit="" y="" 0.0="" 0.2="" 0.4="" 0.6="" 0.8="" 1.0="" 0="" 4="" 8="" 9="" case="" of="" discrete="" uniform="" distributions:="" xi="" are="" u(x1,="" x2,="" .="" .="" .="" ,="" xn)="" mu="mean(0:4)" #="" mu="mean" of="" the="" population="" s0="sd(0:4)" #="" s0="standard" deviatio="" of="" the="" population="" n1="10" #="" number="" of="" trials="" n2="20" n3="50" n4="100" s1="">-><- c()="" s2="">-><- c()="" s3="">-><- c()="" s4="">-><- c() rows =1000 # number of simulations for ( i in 1:rows){ s1[i] = mean(sample(0:4, n1, replace = true)) # gerenates n1 numbers s2[i] = mean(sample(0:4, n2, replace = true)) s3[i] = mean(sample(0:4, n3, replace = true)) s4[i] = mean(sample(0:4, n4, replace = true)) } par(mfrow=c(2,2)) hist(s1, col ="greenyellow",main=paste("sample size=", n1), xlab ="observed means",ylab="relative frequency", freq=false ) abline(v = mu, col = "red",lwd="2") curve(dnorm(x, mean = mu, sd=s0/sqrt(n1)), col="blue", lwd="2", add=t) hist(s2, col ="greenyellow",main=paste("sample size=", n2), xlab ="observed means",ylab="relative frequency", freq=false ) abline(v = mu, col = "red",lwd="2") curve(dnorm(x, mean = mu, sd=s0/sqrt(n2)), col="blue", lwd="2", add=t) hist(s3, col ="greenyellow",main=paste("sample size=", n3), xlab ="observed means",ylab="relative frequency", freq=false ) abline(v = mu, col = "red",lwd="2") curve(dnorm(x, mean = mu, sd=s0/sqrt(n3)), col="blue", lwd="2", add=t) 10 hist(s4, col ="greenyellow",main=paste("sample size=", n4), xlab ="observed means",ylab="relative frequency", freq=false ) abline(v = mu, col = "red",lwd="2") curve(dnorm(x, mean = mu, sd=s0/sqrt(n4)), col="blue", lwd="2", add=t) sample size= 10 observed means r el at iv e f re qu en cy 0.5 1.0 1.5 2.0 2.5 3.0 3.5 0. 0 0. 6 sample size= 20 observed means r el at iv e f re qu en cy 1.0 1.5 2.0 2.5 3.0 0. 0 0. 6 1. 2 sample size= 50 observed means r el at iv e f re qu en cy 1.4 1.8 2.2 2.6 0. 0 1. 0 2. 0 sample size= 100 observed means r el at iv e f re qu en cy 1.6 1.8 2.0 2.2 2.4 0. 0 1. 5 11 law of large numbers. central limit theorem. application. case of binomial distributions: x_i are (b(1,p)) case of normal distributions: x_i are n(0,1) case of poisson distributions: x_i are p(\lambda) case of discrete uniform distributions: x_i are u(x_1, x_2, \ldots, x_n) c()="" rows="1000" #="" number="" of="" simulations="" for="" (="" i="" in="" 1:rows){="" s1[i]="mean(sample(0:4," n1,="" replace="TRUE))" #="" gerenates="" n1="" numbers="" s2[i]="mean(sample(0:4," n2,="" replace="TRUE))" s3[i]="mean(sample(0:4," n3,="" replace="TRUE))" s4[i]="mean(sample(0:4," n4,="" replace="TRUE))" }="" par(mfrow="c(2,2))" hist(s1,="" col="greenyellow" ,main="paste("Sample" size=", n1), xlab =" observed="" means",ylab="Relative Frequency" ,="" freq="FALSE" )="" abline(v="mu," col="red" ,lwd="2" )="" curve(dnorm(x,="" mean="mu," sd="s0/sqrt(n1))," col="blue" ,="" lwd="2" ,="" add="T)" hist(s2,="" col="greenyellow" ,main="paste("Sample" size=", n2), xlab =" observed="" means",ylab="Relative Frequency" ,="" freq="FALSE" )="" abline(v="mu," col="red" ,lwd="2" )="" curve(dnorm(x,="" mean="mu," sd="s0/sqrt(n2))," col="blue" ,="" lwd="2" ,="" add="T)" hist(s3,="" col="greenyellow" ,main="paste("Sample" size=", n3), xlab =" observed="" means",ylab="Relative Frequency" ,="" freq="FALSE" )="" abline(v="mu," col="red" ,lwd="2" )="" curve(dnorm(x,="" mean="mu," sd="s0/sqrt(n3))," col="blue" ,="" lwd="2" ,="" add="T)" 10="" hist(s4,="" col="greenyellow" ,main="paste("Sample" size=", n4), xlab =" observed="" means",ylab="Relative Frequency" ,="" freq="FALSE" )="" abline(v="mu," col="red" ,lwd="2" )="" curve(dnorm(x,="" mean="mu," sd="s0/sqrt(n4))," col="blue" ,="" lwd="2" ,="" add="T)" sample="" size="10" observed="" means="" r="" el="" at="" iv="" e="" f="" re="" qu="" en="" cy="" 0.5="" 1.0="" 1.5="" 2.0="" 2.5="" 3.0="" 3.5="" 0.="" 0="" 0.="" 6="" sample="" size="20" observed="" means="" r="" el="" at="" iv="" e="" f="" re="" qu="" en="" cy="" 1.0="" 1.5="" 2.0="" 2.5="" 3.0="" 0.="" 0="" 0.="" 6="" 1.="" 2="" sample="" size="50" observed="" means="" r="" el="" at="" iv="" e="" f="" re="" qu="" en="" cy="" 1.4="" 1.8="" 2.2="" 2.6="" 0.="" 0="" 1.="" 0="" 2.="" 0="" sample="" size="100" observed="" means="" r="" el="" at="" iv="" e="" f="" re="" qu="" en="" cy="" 1.6="" 1.8="" 2.0="" 2.2="" 2.4="" 0.="" 0="" 1.="" 5="" 11="" law="" of="" large="" numbers.="" central="" limit="" theorem.="" application.="" case="" of="" binomial="" distributions:="" x_i="" are="" (b(1,p))="" case="" of="" normal="" distributions:="" x_i="" are="" n(0,1)="" case="" of="" poisson="" distributions:="" x_i="" are="" p(\lambda)="" case="" of="" discrete="" uniform="" distributions:="" x_i="" are="" u(x_1,="" x_2,="" \ldots,="">- c() rows =1000 # number of simulations for ( i in 1:rows){ s1[i] = mean(sample(0:4, n1, replace = true)) # gerenates n1 numbers s2[i] = mean(sample(0:4, n2, replace = true)) s3[i] = mean(sample(0:4, n3, replace = true)) s4[i] = mean(sample(0:4, n4, replace = true)) } par(mfrow=c(2,2)) hist(s1, col ="greenyellow",main=paste("sample size=", n1), xlab ="observed means",ylab="relative frequency", freq=false ) abline(v = mu, col = "red",lwd="2") curve(dnorm(x, mean = mu, sd=s0/sqrt(n1)), col="blue", lwd="2", add=t) hist(s2, col ="greenyellow",main=paste("sample size=", n2), xlab ="observed means",ylab="relative frequency", freq=false ) abline(v = mu, col = "red",lwd="2") curve(dnorm(x, mean = mu, sd=s0/sqrt(n2)), col="blue", lwd="2", add=t) hist(s3, col ="greenyellow",main=paste("sample size=", n3), xlab ="observed means",ylab="relative frequency", freq=false ) abline(v = mu, col = "red",lwd="2") curve(dnorm(x, mean = mu, sd=s0/sqrt(n3)), col="blue", lwd="2", add=t) 10 hist(s4, col ="greenyellow",main=paste("sample size=", n4), xlab ="observed means",ylab="relative frequency", freq=false ) abline(v = mu, col = "red",lwd="2") curve(dnorm(x, mean = mu, sd=s0/sqrt(n4)), col="blue", lwd="2", add=t) sample size= 10 observed means r el at iv e f re qu en cy 0.5 1.0 1.5 2.0 2.5 3.0 3.5 0. 0 0. 6 sample size= 20 observed means r el at iv e f re qu en cy 1.0 1.5 2.0 2.5 3.0 0. 0 0. 6 1. 2 sample size= 50 observed means r el at iv e f re qu en cy 1.4 1.8 2.2 2.6 0. 0 1. 0 2. 0 sample size= 100 observed means r el at iv e f re qu en cy 1.6 1.8 2.0 2.2 2.4 0. 0 1. 5 11 law of large numbers. central limit theorem. application. case of binomial distributions: x_i are (b(1,p)) case of normal distributions: x_i are n(0,1) case of poisson distributions: x_i are p(\lambda) case of discrete uniform distributions: x_i are u(x_1, x_2, \ldots, x_n)>