mardi 29 septembre 2015

How to reject randomly generated numbers in R that don't meet a criteria

Basically I'm generating random numbers in r from a uniform distribution then using Marsaglia and Bray's method to transform these to random normal deviates, a step in this process is to transform u[1]^2 + u[2]^2 to a value w, w can only be accepted if it is less than 1, in R what can I write to reject the number if it is larger than 1 and as I'm doing this inside a while loop I don't want to add a count to the index for rejected values? Thanks




Aucun commentaire:

Enregistrer un commentaire