Message-ID: <XFMail.060223091855.Ted.Harding@nessie.mcc.ac.uk>
Date: 2006-02-23T09:18:55Z
From: (Ted Harding)
Subject: discrete probability distribution
In-Reply-To: <1BDB3E41-0FC6-4B26-A610-080CCB8E0E5F@soc.soton.ac.uk>
On 23-Feb-06 Robin Hankin wrote:
> Hi
>
> I want to sample from a discrete random variable X, defined on
> the non-negative integers, with
>
> prob(X=0) = (1-p)
> prob(X=1) = (1-p)*p
> ...
> prob(X=i)=(1-p)*p^i
> ...
>
>
>
> Before reinventing the wheel,
> is there a ready-made R function to give me such a thing?
Use rgeom(n,(1-p))
Note (from ?rgeom) that these functions use the definition
P(n) = p*(1-p)^n
i.e. the complementary value of p to the one in your description.
Best wishes,
Ted.
--------------------------------------------------------------------
E-Mail: (Ted Harding) <Ted.Harding at nessie.mcc.ac.uk>
Fax-to-email: +44 (0)870 094 0861
Date: 23-Feb-06 Time: 09:18:50
------------------------------ XFMail ------------------------------