mardi 24 novembre 2015

R generate clustered pseudo-random numbers

In R: I am trying to figure out a way to generate vectors with values 0 or 1. Rather than drawing each 0 and 1 independtly from a uniform distribution I would like the 1s to come clustered e.g. (1,0,0,0,0,0,1,0,1,1,1,1,0,1,0,0,0,0,1,0,0,0,...). In its most simple form something like: "if the previous number was 1 then increase the likelihood of drawing 1". Or make the change of drawing 1 is dependent of the sum of the last say 5 numbers drawn. Is there an efficient way of doing this, maybe even a package.




Aucun commentaire:

Enregistrer un commentaire