Created
December 17, 2015 01:53
-
-
Save martinzh/7f8829caaf334b1480ae to your computer and use it in GitHub Desktop.
Arreglo de valores Bool con probabilidad p y 1-p
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define probabilidad | |
# p -> true | |
# 1-p -> false | |
p = 0.1 | |
#tamanio del arreglo | |
n = 100 | |
#declara arreglo | |
vals = Array{Bool}(n) | |
#llena arreglo | |
for i in 1:n | |
if rand() < p | |
vals[i] = true | |
else | |
vals[i] = false | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment