Hi Phil,
Thank you for your response. The answer you provided gave me only half of
what I need. The other half is how to get this boolean value with a given
probability much the same as nextBonimial?
Thanks very much!
Ahmed
On Mon, Oct 24, 2011 at 12:19 AM, Phil Steitz <phil.steitz@gmail.com> wrote:
> On 10/22/11 8:40 PM, Ahmed Abdeen Hamed wrote:
> > Hi Phil,
> >
> > Thanks very much for your quick response. I am doing some simulations
> that
> > produce probailities which are in turn must be compared to certains
> rates.
> > Here is an example of what I am doing:
> >
> > if (randBinomial.nextBinomial(1, Simulation.MRATE)==1) {
> >
> > // the condition can be replaced by the following uncommented condition
> >
> > //randM.nextDouble() < Simulation.M_RATE;
> >
> > if (gt[i] == 0) {
> >
> > gt[i] = 1;
> >
> > } else {
> >
> > gt[i] = 0;
> >
> > }
> >
> > }
> >
> > Please let me know if I am using Binomial object and its method
> correctly.
>
> As Ted pointed out, you should not be generating values from the
> Binomial distribution here. That distribution is for the number of
> successes in a given number of Bernoulli trials. The degenerate
> case, where the number of trials is 1, can be much more efficiently
> handled just generating a random boolean, which can be generated by
> a RandomGenerator directly. As Luc pointed out, there are better
> PRNGs in [math] than the JDKsupplied generator. To use, for
> example, a Well generator, just do
>
> RandomGenerator gen = new Well19937c();
>
> and then
>
> gen.nextBoolean();
>
> to generate (pseudo)random boolean values.
>
> Phil
>
