#install.packages("gtools")
#install.packages("dice")
library(dice)
## Loading required package: gtools
#install.packages("gtools")
#install.packages("MASS")
library(MASS)
un_seis<-getEventProb(nrolls=1,ndicePerRoll=1,nsidesPerDie=6,eventList=list(1))
un_seis
## [1] 0.1666667
fractions(un_seis)
## [1] 1/6
un_cinco<-getEventProb(nrolls=1,ndicePerRoll=1,nsidesPerDie=6,eventList=list(1))
un_cinco
## [1] 0.1666667
fractions(un_cinco)
## [1] 1/6
dos_cinco<-getEventProb(nrolls=2,ndicePerRoll=1,nsidesPerDie=6,eventList=list(5,5))
dos_cinco
## [1] 0.02777778
fractions(dos_cinco)
## [1] 1/36
sumar_dos<-getEventProb(nrolls=1,ndicePerRoll=2,nsidesPerDie=6,eventList=list(2))
sumar_tres<-getEventProb(nrolls=1,ndicePerRoll=2,nsidesPerDie=6,eventList=list(3))
sumar_cuatro<-getEventProb(nrolls=1,ndicePerRoll=2,nsidesPerDie=6,eventList=list(4))
sumar_cinco<-getEventProb(nrolls=1,ndicePerRoll=2,nsidesPerDie=6,eventList=list(5))
sumar_seis<-getEventProb(nrolls=1,ndicePerRoll=2,nsidesPerDie=6,eventList=list(6))
sumar_siete<-getEventProb(nrolls=1,ndicePerRoll=2,nsidesPerDie=6,eventList=list(7))
sumar_ocho<-getEventProb(nrolls=1,ndicePerRoll=2,nsidesPerDie=6,eventList=list(8))
sumar_nueve<-getEventProb(nrolls=1,ndicePerRoll=2,nsidesPerDie=6,eventList=list(9))
sumar_diez<-getEventProb(nrolls=1,ndicePerRoll=2,nsidesPerDie=6,eventList=list(10))
sumar_once<-getEventProb(nrolls=1,ndicePerRoll=2,nsidesPerDie=6,eventList=list(11))
sumar_doce<-getEventProb(nrolls=1,ndicePerRoll=2,nsidesPerDie=6,eventList=list(12))
suma<-c(2,3,4,5,6,7,8,9,10,11,12)
probabilidad<- c(sumar_dos,sumar_tres,sumar_cuatro,sumar_cinco,sumar_seis,sumar_siete,sumar_ocho,sumar_nueve,sumar_diez,sumar_once,sumar_doce)
tabla<-cbind(suma,probabilidad)
barplot(probabilidad,names.arg=suma,main="probabilidad",xlab="suma de 2 dados",col="tomato")
#install.packages("tidyverse")
library(purrr)
numero <-c(2,3,4,5,6,7,8,9,"T","J","Q","K","A")
numeros<-rep(numero,4)
palo<-c("T","C","P","D")
palos<-rep(palo,13)
baraja<-data.frame(numeros,palos)
#Crear la carta
mazo<-apply(format(baraja),1,paste,collapse="")
mazo
## 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
## "2T" "3C" "4P" "5D" "6T" "7C" "8P" "9D" "TT" "JC" "QP" "KD" "AT" "2C" "3P" "4D"
## 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
## "5T" "6C" "7P" "8D" "9T" "TC" "JP" "QD" "KT" "AC" "2P" "3D" "4T" "5C" "6P" "7D"
## 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
## "8T" "9C" "TP" "JD" "QT" "KC" "AP" "2D" "3T" "4C" "5P" "6D" "7T" "8C" "9P" "TD"
## 49 50 51 52
## "JT" "QC" "KP" "AD"
mano <-function(n) sample(mazo,n,rep=FALSE)
mi_mano<-mano(5)
mi_mano
## 29 46 47 2 10
## "4T" "8C" "9P" "3C" "JC"
El principal fin de esta actividad es el poder tener un analisis sobre variables que son a la suerte o azar, e incluso con dos sucesos que pueden o no suceder. Y para poder justificar lo mencionado realizamos dos ejemplos de diferentes sucesos que pueden pasar, enfocado a juegos de azar. En estos hicimos la probabilidad de obtener un numero del dado y en el otro fue con las cartas para obtener la probabilidad de que nos salga una mano para jugada de pokar o texas.