On 19 Jul 2007, at 16:29, Stefan Evert wrote:
Does anyone on this list have some R code that implements a random number generator for power law / Zipfian distributions analogous to what the runif/rnorm/... family of functions provides?You could try our zipfR package, available from http://www.cogsci.uni-osnabrueck.de/~severt/zipfR/(it's also on CRAN, but not the latest version). Amongst other things, this package implements random samples from populations that follow the Zipf-Mandelbrot law (in the form of the "ZM" and "fZM" LNRE models).
Thank you, that's exactly what I was looking for (and now I also remember your demo at ACL).
I got it to work after checking the manual with a simple
library(zipfR)
Z <- lnre("zm", alpha=.8, B=1e-3)
hist( as.integer(rlnre(Z, 1000)))
Works!
For the benefit of the readers: As an alternative, the "rmutil"
package by Jim Lindsey provides Pareto distributions. (Installing on
OS X requires some tweaks and I haven't tried it.)
-- David Reitter ICCS/HCRC, Informatics, University of Edinburgh http://www.david-reitter.com
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________ R-lang mailing list [email protected] https://ling.ucsd.edu/mailman/listinfo.cgi/r-lang
