[R] probability from different values

Richard.Cotton at hsl.gov.uk Richard.Cotton at hsl.gov.uk
Thu Dec 27 14:58:53 CET 2007


> i have two vectors (A and B) and i need create another vector (C) 
> from the subtraction of A's values with the B's values. How can i 
> estimate the probability of C's values if i have differents values 
> combinations of A and B that can result in the same value? like 90 
> -20 = 70 and 91 - 21 = 70.
> 
> example:
> B = {18      18    18     19      20      21      22      23      24
> 25      26      27   28....} 
> A = {82     83     84     85      85     86       87     88       89
> 90      91     91    92 ....}

Try this:
A = c(18,18,18,19,20,21,22,23,24,25,26,27,28)
B = c(82,83,84,85,85,86,87,88,89,90,91,91,92)
lenA = length(A)
lenB = length(B)
AA = rep(A, lenB)
BB = rep(B, each=lenA)
table(AA-BB)/(lenA*lenB)

Regards,
Richie.

Mathematical Sciences Unit
HSL


------------------------------------------------------------------------
ATTENTION:

This message contains privileged and confidential inform...{{dropped:20}}



More information about the R-help mailing list