Dylan Arena wrote:
I'm writing a function that calculates the probability of different
outcomes of dice rolls (e.g., the sum of the highest three rolls of
five six-sided dice).
You know there are simpler ways to do this, don't you?
Alberto Monteiro
El lun, 05-03-2007 a las 22:16 -0800, Dylan Arena escribió:
So here is my question in a nutshell:
Does anyone have ideas for how I might efficiently process a matrix
like that returned by a call to combinations(n, r, rep=TRUE) to
determine the number of repetitions of each element in each row
Hi there,
I'm writing a function that calculates the probability of different
outcomes of dice rolls (e.g., the sum of the highest three rolls of
five six-sided dice). I'm using the combinations function from the
gtools package, which is great: it gives me a matrix with all of the
possible
is this what you mean?
tmp - combinations(3, 3, rep=TRUE)
colSums(apply(tmp, 1, duplicated))+1
b
On Mar 6, 2007, at 1:16 AM, Dylan Arena wrote:
Hi there,
I'm writing a function that calculates the probability of different
outcomes of dice rolls (e.g., the sum of the highest three rolls of
sorry, i forgot to mention that you will need an extra test |-)
tmp - combinations(3, 3, rep=TRUE)
out - colSums(apply(tmp, 1, duplicated))+1
out[out == 1] - 0
but now, re-reading your message, you say
(..) want to count the number of times each element appears in each
arrangement (...)