In: Statistics and Probability
1. Consider Beta pdf and plot it on the same paper for various
values of
alpha and beta: alpha = 1,2,3,4,5 and beta=1/2, 1, 3/2, 2, 5/2.
Consider
all combinations.
2. Consider gamma pdf and plot it on the same paper for various
values of
alpha and beta: alpha = 1/2, 1, 3/2, 2, 5/2 and beta = 1, 2, 3, 4,
5.
Consider all possible combinations.
3. Consider Normal pdf and plot it on the same paper for various
values of
mu and sigma: mu=0, -1, 1, -2, 2 and sigma = 1, 2, 3, 4, 5.
Consider all
possible combinations.
You can use R or Excel or Matlab!
Answer:
1)
R code:
alpha=1:5
beta=(1:5)*0.5
x=seq(0,0.99, by=0.01)
n=length(x)
D=array(0,dim=c(5,n,5))
for(i in 1:5)
{
for(j in 1:5)
{
D[i,,j]=dbeta(x, alpha[i], beta[j], ncp = 0, log = FALSE)
}
}
plot(x,D[1,,1],lwd=2,type="n",col=1,xlab="x",
ylab="f(x)",ylim=c(0,12),main=expression(beta(alpha,beta)))
for(i in 1:5)
{
for(j in 1:5)
{
lines(x,D[i,,j],lwd=2,type="l",lty=i)
}
}
2)
R code:
alpha=(1:5)*0.5
beta=1:5
x=seq(0,0.99, by=0.01)
n=length(x)
D=array(0,dim=c(5,n,5))
for(i in 1:5)
{
for(j in 1:5)
{
D[i,,j]=dgamma(x, beta[i], alpha[j])
}
}
plot(x,D[1,,1],lwd=2,type="n",col=1,xlab="x",
ylab="f(x)",ylim=c(0,2.7),main=expression(gamma(beta,alpha)))
for(i in 1:5)
{
for(j in 1:5)
{
lines(x,D[i,,j],lwd=2,type="l",lty=i)
}
}
3)
R code:
mu=c(-2,-1,0,1,2)
sigma=1:5
x=seq(-17,17, by=0.01)
n=length(x)
D=array(0,dim=c(5,n,5))
for(i in 1:5)
{
for(j in 1:5)
{
D[i,,j]=dnorm(x, mu[i], sigma[j])
}
}
plot(x,D[1,,1],lwd=2,type="n",col=1,xlab="x",
ylab="f(x)",ylim=c(0,0.45),main=expression(N(mu,sigma)))
for(i in 1:5)
{
for(j in 1:5)
{
lines(x,D[i,,j],lwd=2,type="l",lty=i)
}
}