From 338a4bb344ff1de363c7d1674f9aa5a22aecc0df Mon Sep 17 00:00:00 2001
From: Walmes Zeviani <walmes@ufpr.br>
Date: Mon, 5 Nov 2018 00:14:43 -0200
Subject: [PATCH] =?UTF-8?q?Adiciona=20contas=20para=20acur=C3=A1cia=20do?=
 =?UTF-8?q?=20ensemble.?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 scripts/ce089-09.R | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/scripts/ce089-09.R b/scripts/ce089-09.R
index e4d11ef..fb6c6e4 100644
--- a/scripts/ce089-09.R
+++ b/scripts/ce089-09.R
@@ -128,6 +128,12 @@ simul <- function(n_class = 3, tx_acer = 0.55, N = 1000) {
     mean(u)
 }
 
+# Comparando teÃģrico com simulado.
+k <- 13
+alpha <- 0.7
+sum(dbinom(ceiling(k/2):k, size = k, prob = alpha))
+simul(n_class = k, tx_acer = alpha, N = 10000)
+
 # Grid de valores nos parÃĒmetros da simulaçÃĢo.
 grid <- expand.grid(n_class = c(3, 5, 9, 13, 19, 25),
                     tx_acer = seq(0.35, 0.95, by = 0.025))
@@ -150,9 +156,19 @@ xyplot(acc ~ tx_acer,
                        title = "#Classif.",
                        cex.title = 1),
        grid = TRUE,
-       type = "o") +
+       type = "p") +
     layer({
         panel.abline(v = 0.5, h = 0.5, lty = 2)
+    }) +
+    glayer({
+        k <- group.value
+        p <- sapply(x,
+                    FUN = function(alpha) {
+                        sum(dbinom(ceiling(k/2):k,
+                                   size = k,
+                                   prob = alpha))
+                    })
+        panel.lines(x, p, col = col.line)
     })
 
 #-----------------------------------------------------------------------
-- 
GitLab