Codes Probability

Cesar Ramos
2020

First Slide

For more details on authoring R presentations please visit https://support.rstudio.com/hc/en-us/articles/200486468.

  • Bullet 1
  • Bullet 2
  • Bullet 3

Slide With Code

summary(cars)
     speed           dist       
 Min.   : 4.0   Min.   :  2.00  
 1st Qu.:12.0   1st Qu.: 26.00  
 Median :15.0   Median : 36.00  
 Mean   :15.4   Mean   : 42.98  
 3rd Qu.:19.0   3rd Qu.: 56.00  
 Max.   :25.0   Max.   :120.00  

Slide With Plot

plot of chunk unnamed-chunk-2

Independence

To see an extreme case of non-independent events, consider our example of drawing five beads at random without replacement:

beads = rep(c("red", "blue"), times = c(2,3))
x = sample(beads, 5)

If you have to guess the color of the first bead, you will predict blue since blue has a 60% chance. But if I show you the result of the last four outcomes:

# Donde x es la muestra tomada de la urna donde se extrayeron 5 bolos en ese orden. 
x
[1] "blue" "red"  "blue" "red"  "blue"
x[2:5]
[1] "red"  "blue" "red"  "blue"

Conditional probabilities - Addition and multiplication rules

  • Para eventos dependientes
  • \( Prob(A|B)=Pr(A)*Pr(B|A) \)
  • Para eventos independientes
  • \( Prob(A|B)=Pr(A)*Pr(B) \)
  • Para mas de dos eventos dependientes
  • \( Pr(A y B y C)=Pr(A)*Pr(B|A)*Pr(C|A y C) \)
  • Probabilidad condicional
  • \( Pr(B|A) = Pr(A y B) / Pr(A) \)
  • Regla de adicion
  • \( Pr(A o B)=Pr(A)+Pr(B)-Pr(A y B) \)