Re: [R] select a range od distributions for simulation experiment

From: maiya <>
Date: Mon, 26 May 2008 10:03:50 -0700 (PDT)

I admit, that was a very half-baked way to ask a question. Here instead is a version of code I have, to make it clearer:

oldpar<-par(mfrow=c(4,4), mar=c(2,2,1,1)) sds<- data.frame(sd.cells=numeric(0), sd.margins=numeric(0)) for (i in 1:2){

        for (j in 1:2) {
dist<-rbeta(100000, j*0.5,i*0.5)
plot(density(dist), main="", xlab="", ylab="") s<-sample(dist, 25)
hist(s, main="", xlab="", ylab="")
pop<-matrix(s, c(5,5))
mosaicplot(pop, main="", xlab="", ylab="") mars<-c(margin.table(pop,1), margin.table(pop,2)) hist(mars, main="", xlab="", ylab="", probability=TRUE) lines(density(mars))
rug(c(margin.table(pop,1), margin.table(pop,2)), col="red") sds<-rbind(sds,c(sd(s),sd(mars)))


This loops through four different beta distributions (1st. graph), and in each case samples 25 values (2.nd graph), to become "cell sizes" in a 5x5 crosstabulation of 100 (cells arranged randomly) (3rd graph) after which I am interested in the marginal distributions (both margins together in this case, but this is irrelevant to my question) (4th graph). I am only visualising this at this point, but i am actually interested in the table of standard deviations of cell sizes and marginal totals (sds).

What I would like is to loop this through a series of distributions, which would give me a whole range of cell size distributions, from all of them being aproximatley equaly sized, to extremes, where e.g. most cells would have values close to zero and only one or two would contain the majority - the sort of extremes that arise e.g. if you change the distribution code into this:
dist<-rbeta(100000, j*0.01,i*0.1)

the idea is to get a whole range of posible combinations of sds of cell and margin distributions

Hope this makes a little more sense!


View this message in context:
Sent from the R help mailing list archive at

______________________________________________ mailing list
PLEASE do read the posting guide
and provide commented, minimal, self-contained, reproducible code.
Received on Mon 26 May 2008 - 18:34:24 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 26 May 2008 - 20:31:29 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.

list of date sections of archive