Aproximació de la Binomial per la Normal
Author: Pep Bujosa

X

Diagrama barres

Histograma

Normal

Probabilitats

Càlculs

p = 0.4 (slider from 0 to 1, step 0.01)
n = 10 (slider from 1 to 12, step 1)
np: n * p
sig: sqrt(np * (1 - p))
t = 6 (slider from 0 to 12, step 1)
r = 3 (slider from 0 to 12, step 1)
tt = Min(t, n)
f(x) = 1 / (sig * sqrt(2 * π)) * ℯ^(-0.5 * ((x - np) / sig)^(2))
rr = Min(r, n)
A2 = 0
A3 = 1
A4 = 2
A5 = 3
A6 = 4
A7 = 5
A8 = 6
A9 = 7
A10 = 8
A11 = 9
A12 = 10
A13 = 11
A14 = 12
B2 = If(n ≥ A2, p^(A2) * (1 - p)^(n - A2), 0)
B3 = If(n ≥ A3, Binomial[n, A3] * p^(A3) * (1 - p)^(n - A3), 0)
B4 = If(n ≥ A4, Binomial[n, A4] * p^(A4) * (1 - p)^(n - A4), 0)
B5 = If(n ≥ A5, Binomial[n, A5] * p^(A5) * (1 - p)^(n - A5), 0)
B6 = If(n ≥ A6, Binomial[n, A6] * p^(A6) * (1 - p)^(n - A6), 0)
B7 = If(n ≥ A7, Binomial[n, A7] * p^(A7) * (1 - p)^(n - A7), 0)
B8 = If(n ≥ A8, Binomial[n, A8] * p^(A8) * (1 - p)^(n - A8), 0)
B9 = If(n ≥ A9, Binomial[n, A9] * p^(A9) * (1 - p)^(n - A9), 0)
B10 = If(n ≥ A10, Binomial[n, A10] * p^(A10) * (1 - p)^(n - A10), 0)
B11 = If(n ≥ A11, Binomial[n, A11] * p^(A11) * (1 - p)^(n - A11), 0)
B12 = If(n ≥ A12, Binomial[n, A12] * p^(A12) * (1 - p)^(n - A12), 0)
B13 = If(n ≥ A13, Binomial[n, A13] * p^(A13) * (1 - p)^(n - A13), 0)
B14 = If(n ≥ A14, p^(A14) * (1 - p)^(n - A14), 0)
c = false
d = true
e = true
A: (r, 0)
B: (t, 0)
ma = Max(rr, tt)
mi = Min(rr, tt)
g = Integral(f, mi - 0.5, ma + 0.5)
L_1: {A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14}
L_2: {B2, B3, B4, B5, B6, B7, B8, B9, B10, B11, B12, B13, B14}
LS = Take(L_2, mi + 1, ma + 1)
s = Sum(LS)
text3: "P(" + mi + "≤X_b≤" + ma + ") = " + s
text5: "Diferència = " + (abs(s - g))
h = true
text4: "P(" + (mi - 0.5) + "≤X_n≤" + (ma + 0.5) + ") = " + g
text6: "t = " + tt
text7: "r = " + rr
b = BarChart(L_1, L_2, 0.2)
a = BarChart(-0.5, n + 0.5, Sequence[n! / (k! * (n - k)!) * p^(k) * (1 - p)^(n - k), k, 0, n])
text1: "Aproximació d'una Binomial B(" + n + "," + p + ") 
per una Normal  N(" + np + "," + sig + ")"