Displaying 1 result from an estimated 1 matches for "xmedian".
Did you mean:
median
2006 Apr 10
1
Generic code for simulating from a distribution.
...e code below to simulate samples of certain size from a
particular distribution (here,beta distribution) and compute some
statistics for the samples.
betasim2<-function(nsim,n,alpha,beta)
{
sim<-matrix(rbeta(nsim*n,alpha,beta),ncol=n)
xmean<-apply(sim,1,mean)
xvar<-apply(sim,1,var)
xmedian<-apply(sim,1,median)
simset<-data.frame(sampleno=seq1:nsim),means=xmean,vars=xvar,medians=xmedian)
return(simset)
}
I can write a similar coding for any distribution individually.
Now, I would like to have a generic code, say if I specify the
distribution with the parameters and simulation...