[R-lang] Power law / Zipf random number generator
David Reitter
dreitter at inf.ed.ac.uk
Thu Jul 19 09:19:57 PDT 2007
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2450 bytes
Desc: not available
Url : https://ling.ucsd.edu/pipermail/r-lang/attachments/20070719/1194d89c/attachment.bin
More information about the R-lang
mailing list