lundi 8 février 2021

Is there a way to simulate rbinom using if statements on R?

I am working on the following prompt:

Using if statements, generate a sample of 100 observations from the binomial distribution with p = 0.35.

Would I do this using the binomial equation, where I believe that n=100, p = 0.35, q = 0.65? I have been working on this for hours and am unable to figure out how to use if statements to achieve the same function as rbinom (or even if my rbinom is correct).

obs.binom <- rbinom(100,100,.35)

Any help is much appreciated.

Aucun commentaire:

Enregistrer un commentaire