Hi
Firstly , happy Christmas to R-Help! Secondly, I wonder if anyone can help
me with the following query: I am trying to reproduce some explicit
probability calculations performed in APPL (a Maple extension for
computational probability). For instance, in APPL, to compute the
probability that the sum of 10 iid uniform variables [0,1] will be between 4
and 6, (i..e Pr( 4 < \sum_{i=1}^{10}X_i < 6)), I can type:
X := UniformRV(0, 1);
Y := ConvolutionIID(X, 10);
CDF(Y,6) - CDF(Y,4);
which gives the required probability .7222. Is there any way to perform
these type of calcuations in R in a general way? I realise that a lot of the
machinery behind these computations comes from Maple's symbolic engine, but
are there any R extensions for these kind of calculation?
Cheers
Rory
[[alternative HTML version deleted]]
Try a simulation approach. vignette("rv") for more info.
> set.seed(1)
> library(rv)
> x <- rvunif(10)
> s <- simapply(x, sum)
> mean(s > 4 & s < 6)
mean sd 1% 2.5% 25% 50% 75% 97.5% 99% sims
[1] 0.72 0.45 0 0 0 1 1 1 1 2500
On Fri, Dec 26, 2008 at 7:42 AM, Rory Winston <rory.winston at gmail.com>
wrote:> Hi
>
> Firstly , happy Christmas to R-Help! Secondly, I wonder if anyone can help
> me with the following query: I am trying to reproduce some explicit
> probability calculations performed in APPL (a Maple extension for
> computational probability). For instance, in APPL, to compute the
> probability that the sum of 10 iid uniform variables [0,1] will be between
4
> and 6, (i..e Pr( 4 < \sum_{i=1}^{10}X_i < 6)), I can type:
>
> X := UniformRV(0, 1);
> Y := ConvolutionIID(X, 10);
> CDF(Y,6) - CDF(Y,4);
>
> which gives the required probability .7222. Is there any way to perform
> these type of calcuations in R in a general way? I realise that a lot of
the
> machinery behind these computations comes from Maple's symbolic engine,
but
> are there any R extensions for these kind of calculation?
>
> Cheers
> Rory
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> 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.
>
Look at packages distr* : they can do your example and might do what your real applications. On Fri, 26 Dec 2008, Rory Winston wrote:> Hi > > Firstly , happy Christmas to R-Help! Secondly, I wonder if anyone can help > me with the following query: I am trying to reproduce some explicit > probability calculations performed in APPL (a Maple extension for > computational probability). For instance, in APPL, to compute the > probability that the sum of 10 iid uniform variables [0,1] will be between 4 > and 6, (i..e Pr( 4 < \sum_{i=1}^{10}X_i < 6)), I can type: > > X := UniformRV(0, 1); > Y := ConvolutionIID(X, 10); > CDF(Y,6) - CDF(Y,4); > > which gives the required probability .7222. Is there any way to perform > these type of calcuations in R in a general way? I realise that a lot of the > machinery behind these computations comes from Maple's symbolic engine, but > are there any R extensions for these kind of calculation? > > Cheers > Rory > > [[alternative HTML version deleted]] > > ______________________________________________ > 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. >-- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595