Hi Chuck and all, Thanks for your response. It is really helpful for me.
David 2018-07-07 7:30 GMT+08:00 Berry, Charles <ccbe...@ucsd.edu>: > Sorry about the last incomplete post. Accidentally hit send. > > Meant to say that I was hoping that a correct, but obscure response from > me would motivate David to step back and think about his problem long > enough to see that it has an easy solution. > > Sorry if that was out-of-line. > > Chuck > > > On Jul 6, 2018, at 4:27 PM, Charles Berry <ccbe...@ucsd.edu> wrote: > > > >> On Jul 6, 2018, at 3:31 PM, Duncan Murdoch <murdoch.dun...@gmail.com> > wrote: > >> > >> On 06/07/2018 1:18 PM, Berry, Charles wrote: > >>> A liitle math goes along way. See below. > >>>> On Jul 5, 2018, at 10:35 PM, Marino David <davidmarino...@gmail.com> > wrote: > >>>> > >>>> Dear Bert, > >>>> > >>>> I know it is a simple question. But for me, at current, I fail to > implement > >>>> it. So, I ask for help here. > >>>> > >>>> It is not homework. > >>>> > >>>> Best, > >>>> > >>>> David > >>>> > >>>> 2018-07-06 13:32 GMT+08:00 Bert Gunter <bgunter.4...@gmail.com>: > >>>> > >>>>> Is this homework? > >>>>> > >>>>> (There is an informal no-homework policy on this list). > >>>>> > >>>>> Cheers, > >>>>> Bert > >>>>> > >>>>> > >>>>> > >>>>> Bert Gunter > >>>>> > >>>>> "The trouble with having an open mind is that people keep coming > along and > >>>>> sticking things into it." > >>>>> -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) > >>>>> > >>>>> On Thu, Jul 5, 2018 at 10:23 PM, Marino David < > davidmarino...@gmail.com> > >>>>> wrote: > >>>>> > >>>>>> Dear All, > >>>>>> > >>>>>> I would like to generate N random Bernoulli draws given a > probability > >>>>>> function F(x)=1-exp(-2.5*x) in which x follows uniform > distribution, say > >>>>>> x~U(0,2). > >>> If each Bernoulli draw is based on its own draw of x, then > >>> rbinom( N, 1, 0.8013476 ) > >>> is what you want. > >>> It is left as an exercise for the reader to verify that the constant > 0.8013476 is correct up to approximation error, and to prove that such a > Bernoulli mixture is also Bernoulli. Perhaps, > >>> ?integrate > >>> will help. > >>> But if the x's are shared you need to use runif, expm1, and (possibly) > rep to produce a vector to be used in place of the prob argument. > > > > > [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.