#Part 1
#Interesting question about population proportion
#What proportion of pokemons are considered Fire type?
#This is an interesting question because when I was a kid and used to watch Pokemon, I've always favored the water type pokemons.When Fighting a fire type, it was always an easy win for a water type pokemon. With the anwser to this question I would know the chance of a random fight to be an easy win for a water type.
POKEMON = read.csv("Pokemon.csv")
# Prepare
n = 800;
CF = 0.95
# H_0 : p = 0.25 assuming that the probability is .25
# H_A : p < 0.25
set.seed(400)
Pokemon_Fire_1 <- as.integer(sample(POKEMON$Type.1 == "Fire", 800))
set.seed(400)
Pokemon_Fire_2 <- as.integer(sample(POKEMON$Type.2 == "Fire", 800))
set.seed(400)
Pokemon_Fire <- Pokemon_Fire_1 + Pokemon_Fire_2
p_hat <- mean(Pokemon_Fire)
mean(p_hat)
## [1] 0.08
p <- 0.25
alpha <- 1 - (CF)
# Check
# This data will be independent because it was sampled randomly, and the source is relaible.
n*p # must be =>10
## [1] 200
n*(1-p) # must be>10
## [1] 600
# conditions are met and the process can thus continue.
# Calculate
set.seed(400)
Pokemon_Fire <- Pokemon_Fire_1 + Pokemon_Fire_2;
table(Pokemon_Fire)
## Pokemon_Fire
## 0 1
## 736 64
#inference(y=as.factor(Pokemon_Fire), est = "proportion", success = "1", type = "ht", alternative = "less", method = "theoretical", null=0.25)
#Now we repeat the process but with n=40
#Prepare
n = 40;
CF = 0.95;
# H_0 : p = 0.25
# H_A : p < 0.25
set.seed(400)
Pokemon_Fire_1 <- as.integer(sample(POKEMON$Type.1 == "Fire", 40));
set.seed(400)
Pokemon_Fire_2 <- as.integer(sample(POKEMON$Type.2 == "Fire", 40));
set.seed(400)
Pokemon_Fire <- Pokemon_Fire_1 + Pokemon_Fire_2;
p_hat <- mean(Pokemon_Fire)
mean(p_hat)
## [1] 0.025
p <- 0.25
alpha <- 1 - (CF)
alpha
## [1] 0.05
# Check
#independent because of the same reasons as before
n*p #must be=>10
## [1] 10
n*(1-p)#must be.10
## [1] 30
# conditions are met and the process can thus continue.
# Calculate
set.seed(400)
Pokemon_Fire <- Pokemon_Fire_1 + Pokemon_Fire_2;
table(Pokemon_Fire)
## Pokemon_Fire
## 0 1
## 39 1
#inference(y=as.factor(Pokemon_Fire), est = "proportion", success = "1", type = "ht", alternative = "less", method = "theoretical", null=0.25)
#Explanation
#The results show that we will reject the null hypothesis because in both cases pvalue is less than alpha. This means that the chance of getting in a fight with a Fire type pokemon are less than 25%. I was not suprised by this because there many types of pokemons and from what I remember from watching not every fight was won by the water type pokemons the easy way. There is only 64 fire pokemons therefore the probability of ending up in a fight with one were less than 25%(8% exactly).