On Aug 26, 2011, at 4:58 PM, David Winsemius wrote:
On Aug 26, 2011, at 2:35 PM, Jim Silverton wrote:
H all,
I have a 6 x 3 matrix. The last column is simply the sum of of the
first two
rows.
x1 x2 x3
1 23
2 13
1 01
2 24
2 13
2 13
0
On Aug 26, 2011, at 2:35 PM, Jim Silverton wrote:
H all,
I have a 6 x 3 matrix. The last column is simply the sum of of the
first two
rows.
x1 x2 x3
1 23
2 13
1 01
2 24
2 13
2 13
0 00
I want to create a column of probabilities p,
H all,
I have a 6 x 3 matrix. The last column is simply the sum of of the first two
rows.
x1 x2 x3
1 23
2 13
1 01
2 24
2 13
2 13
0 00
I want to create a column of probabilities p, such that for each row, I want
to find the probability of
On Aug 24, 2011, at 3:31 PM, Jim Silverton wrote:
Hi all,
I have a vector xm say: xm = c(1,2,3,4,5,5,5,6,6)
I want to return a vector with the corresponding probabilities based
on the
amount of times the numbers occurred. For example, I should get the
following vector for xm:
prob.xm = c(1
If your numbers are all positive integers, this should work:
(tabulate(xm)[xm])/length(xm)
it can be put into a function for ease of use:
probVec <- function(x) {(tabulate(x)[x])/length(x)}
You'll have some trouble if you have non-positive integers or non-integers.
Let me know if you need to ha
Try this:
prob.xm <- (table(xm)/length(xm))[match(xm, sort(unique(xm)))]
Jean
Jim Silverton wrote on 08/24/2011 02:31:05 PM:
> Hi all,
> I have a vector xm say: xm = c(1,2,3,4,5,5,5,6,6)
>
> I want to return a vector with the corresponding probabilities based on
the
> amount of times the nu
Hi all,
I have a vector xm say: xm = c(1,2,3,4,5,5,5,6,6)
I want to return a vector with the corresponding probabilities based on the
amount of times the numbers occurred. For example, I should get the
following vector for xm:
prob.xm = c(1/9, 1/9, 1/9, 1/9, 3/9, 3/9, 3/9, 2/9, 2/9)
Any help grea
7 matches
Mail list logo