Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Implementación de una función que cálcula la distribución binomial.
# Programa auxiliar
aciertos = 1..10
suma = 0.0
class Integer
def !
(1..self).inject(:*)
end
end
def combinaciones(n,m)
if n == m
return 1
end
return !n/( !(n-m) * !m )
end
def binomial(n,x,p)
return combinaciones(n,x)*(p**(x))*((1-p)**(n-x))
end
for i in aciertos
puts binomial(10,i,0.66)
end
puts suma
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.