So looking at this question here
"Let A = {0.1, 0.5, 1, 2, 5, 10, 100} L = {0.1, 0.5, 1, 2, 5, 10, 100}
Im trying for Q2 and would like to know what Im doing wrong here and even is my Q 1 right
#Question 1
set.seed(10000)
v <- c(0.1,0.5,1,2,5,10,100)
u <- c()
for(i in v)
{
for(j in v)
{
u <- c(u,paste0(i,"-",j))
}
}
#Question 2
lyst <- list()
q <- 1
for (i in v)
{
m <- matrix(nrow=10000)
for (j in v)
{
m <- cbind(m,rgamma(10000,i,j))
}
m <- m[,-1]
colnames(m) <- paste0(rep(as.character(i),7),"-",as.character(j))
lyst[[q]] <- m
q <- q + 1
}
pdf("Hist8.pdf",width = 20,height = 10)
for(x in 1:7)
{
for(y in 1:7)
{
hist(lyst[[x]][,y],
xlab = "Value",
main = paste("Alpha-Lambda:",
colnames(lis[[x]])[y]))
}
}
dev.off()
I'd appreciate any advice or any sources which can help me with this
Here is a quick modifications from your approach. Instead of trying to store everything in a matrix, I just created a list of the 49 desired distributions and then plotted them 1 by 1.
#Question 2
lyst <- list()
#create a list of the 49 distributions
for (i in v)
{
for (j in v)
{
elementname<-paste0(as.character(i),"-",as.character(j))
print(elementname)
lyst[[elementname]] <- rgamma(10000,i,j)
}
}
#plot the 49 lists
#pdf("Hist8.pdf",width = 20,height = 10)
#define the number of rows and columns (7x7 is probably to many)
par(mfcol=c(7,7))
for(x in names(lyst))
{
hist(lyst[[x]],
xlab = "Value",
main = paste("Alpha-Lambda:", x) )
}
#dev.off()