Displaying 2 results from an estimated 2 matches for "rmultz2".
Did you mean:
rmulti
2003 Jan 27
1
rmultinom() -- how \\ via own C code?
...in one step'' ?
Martin Maechler <maechler@stat.math.ethz.ch> http://stat.ethz.ch/~maechler/
Seminar fuer Statistik, ETH-Zentrum LEO C16 Leonhardstr. 27
ETH (Federal Inst. Technology) 8092 Zurich SWITZERLAND
phone: x-41-1-632-3408 fax: ...-1228 <><
## This is based on rmultz2() from S-news by Alan Zaslavsky & Scott Chasalow;
## in R available from library(combinat) -- but it has
## Arg.names like rbinom(); returns n x p matrix
rmultinom <- function(n, size, prob) {
K <- length(prob) # #{classes}
matrix(tabulate(sample(K, n * size, repl = TRUE, prob...
2002 Aug 05
0
Re: [S] Multinomial
...> fixed n and given probability vector p.
Jacob> How can I do this?
I've recently written the following {for the R package "normix"}.
The above is really a FAQ.
I think I'd propose to adopt this (or an improvement of it) both
for R and S-plus :
## This is based on rmultz2() from S-news by Alan Zaslavsky & Scott Chasalow
## {and adapted from the R package "combinat"}.
## Arg.names like rbinom(); returns n x p matrix
rmultinom <- function(n, size, prob) {
K <- length(prob) # #{classes}
matrix(tabulate(sample(K, n * size, repl...