[R] Efficient multinom probs
Ingmar Visser
I.Visser at uva.nl
Fri Jan 5 11:41:41 CET 2007
Dear R-helpers,
I need to compute probabilties of multinomial observations, eg by doing the
following:
y=sample(1:3,15,1)
prob=matrix(runif(45),15)
prob=prob/rowSums(prob)
diag(prob[,y])
However, my question is whether this is the most efficient way to do this.
In the call prob[,y] a whole matrix is computed which seems a bit of a
waste.
Is there maybe a vectorized version of dmultinom which does this?
Best, Ingmar
More information about the R-help
mailing list