Skip to content

Instantly share code, notes, and snippets.

@martinzh
Created December 17, 2015 01:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save martinzh/7f8829caaf334b1480ae to your computer and use it in GitHub Desktop.
Save martinzh/7f8829caaf334b1480ae to your computer and use it in GitHub Desktop.
Arreglo de valores Bool con probabilidad p y 1-p
#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