Re: [R] probability from different values

From: Matthias Kohl <Matthias.Kohl_at_stamats.de>
Date: Thu, 27 Dec 2007 15:22:11 +0100

Matthias Kohl wrote:

> one addition ...
>   

>> Hello Ricardo,
>>
>> another solution could be using package distr:
>>
>> library(distr)
>> A <- c(18,18,18,19,20,21,22,23,24,25,26,27,28)
>> DA <- DiscreteDistribution(A)
>> # maybe
>> # support(DA)
>> # plot (DA)
>>
>> B <- c(82,83,84,85,85,86,87,88,89,90,91,91,92)
>> DB <- DiscreteDistribution(B)
>> # support(DB)
>> # plot(DB)
>>
>> DC <- DB - DA# convolution with of DB with (-DA)
>> # support(DC)
>> # plot(DC)
>>
>>
> to get the probabilities for the C-values:
> p(DC)(support(DC))
>   

sorry, I meant
d(DC)(support(DC))
>   

>> hth,
>> Matthias
>>
>> Richard.Cotton_at_hsl.gov.uk wrote:
>>
>>
>>>> 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}}
>>>
>>> ______________________________________________
>>> R-help_at_r-project.org mailing list
>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>>> and provide commented, minimal, self-contained, reproducible code.
>>>
>>>
>>>
>> ______________________________________________
>> R-help_at_r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>>
>
> ______________________________________________
> R-help_at_r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

______________________________________________
R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Thu 27 Dec 2007 - 14:26:45 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 27 Dec 2007 - 14:30:20 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.