print(round(1/540,4))
## [1] 0.0019
Toppings<-c('A','C')
Meats<-c('E','T')
Dressings<-c('F','V')
sample_space <-c ('')
for (t in Toppings){
for (m in Meats){
for (d in Dressings){
# print(paste0(t,m,d),sep=",")
if (sample_space==''){
sample_space = paste0(t,m,d)
}
else{
sample_space = paste(sample_space,paste0(t,m,d),sep=",")
}
}
}
}
print(sample_space)
## [1] "AEF,AEV,ATF,ATV,CEF,CEV,CTF,CTV"
# Total# of cards =52 (sample space)
card_deck <- 52
# Total# of hearts =13
hearts <- 13
# Total# of noc-face hearts =10
non_face_hearts <- 10
round(non_face_hearts/card_deck,4)
## [1] 0.1923
4 .A standard pair of six-sided dice is rolled. What is the probability of rolling a sum less than 6? Write your answer as a fraction or a decimal number rounded to four decimal places.
library(mosaic)
## Loading required package: dplyr
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
## Loading required package: lattice
## Loading required package: ggformula
## Loading required package: ggplot2
##
## New to ggformula? Try the tutorials:
## learnr::run_tutorial("introduction", package = "ggformula")
## learnr::run_tutorial("refining", package = "ggformula")
## Loading required package: mosaicData
## Loading required package: Matrix
##
## The 'mosaic' package masks several functions from core packages in order to add
## additional features. The original behavior of these functions should not be affected by this.
##
## Note: If you use the Matrix package, be sure to load it BEFORE loading mosaic.
##
## Attaching package: 'mosaic'
## The following object is masked from 'package:Matrix':
##
## mean
## The following objects are masked from 'package:dplyr':
##
## count, do, tally
## The following objects are masked from 'package:stats':
##
## binom.test, cor, cor.test, cov, fivenum, IQR, median,
## prop.test, quantile, sd, t.test, var
## The following objects are masked from 'package:base':
##
## max, mean, min, prod, range, sample, sum
dice <- expand.grid(1:6, 1:6)
dice$total = dice$Var1 + dice$Var2
sum_less_than_6 <- filter(dice, dice$total < 6)
round(count(sum_less_than_6)/count(dice), 4)
## n
## 1 0.2778
Gender and Residence of Customers
Residence(types) | Males | Females |
---|---|---|
Apartment | 233 | 208 |
Dorm | 159 | 138 |
With Parent(s) | 102 | 280 |
Sorority/Fraternity House | 220 | 265 |
Other | 250 | 146 |
What is the probability that a customer is male? Write your answer as a fraction or a decimal number rounded to four decimal places.
male_customers <- c(233, 159, 102, 220, 250)
female_customers <- c(208, 138, 280, 265, 146)
round(sum(male_customers)/sum(male_customers+female_customers), 4)
## [1] 0.4818
club_card <- round(13/52,4)
black_card <- round(26/52,4)
face_card <- round(12/52,4)
print(paste("probability of 1st card is club : ",club_card))
## [1] "probability of 1st card is club : 0.25"
print(paste("probability of 2nd card is balck card : ",black_card))
## [1] "probability of 2nd card is balck card : 0.5"
print(paste("probability of 3rd card is face card : ",face_card))
## [1] "probability of 3rd card is face card : 0.2308"
round(club_card * black_card * face_card, 4)
## [1] 0.0288
heart_card <- round(13/52,4)
club_card <- round(13/51,4)
round((heart_card*club_card)/ heart_card, 4)
## [1] 0.2549
heart_card_09 <- 13/52
red_card_09 <- 25/51
round(heart_card_09 * red_card_09, 4)
## [1] 0.1225
Students in a Basic Math Class
Student(types) | Males | Females |
---|---|---|
Freshmen | 12 | 12 |
Sophomores | 19 | 15 |
Juniors | 12 | 4 |
Seniors | 7 | 4 |
total_juniors_female <-4
total_freshmen_female <-12
total_students <- (12+12+19+15+12+4+7+4)
juniors_female_odds = round(total_juniors_female/total_students,4)
freshmen_female_odds = round(total_freshmen_female/total_students,4)
print(paste(round(juniors_female_odds*freshmen_female_odds,4)))
## [1] "0.0067"
Step 1 What is the probability that a randomly chosen applicant has a graduate degree, given that they are male? Enter your answer as a fraction or a decimal rounded to four decimal places.
round(52/141, 4)
## [1] 0.3688
Step 2 If 102 of the applicants have graduate degrees, what is the probability that a randomly chosen applicant is male, given that the applicant has a graduate degree? Enter your answer as a fraction or a decimal rounded to four decimal places.
round(52/102, 4)
## [1] 0.5098
subs_drinks <- c('D1','D2','D3','D4','D5','D6')
subs_sandwiches <- c('S1','S2','S3','S4','S5')
subs_chips <- c('C1','C2','C3')
TotalMealCounter <- 0
for (d in subs_drinks){
for (s in subs_sandwiches){
for (c in subs_chips){
TotalMealCounter <- TotalMealCounter +1
}
}
}
print(TotalMealCounter)
## [1] 90
factorial(5)
## [1] 120
Permutation <- function(n,r){
return(factorial(n)/(factorial(n-r)))
}
print(Permutation(8,5))
## [1] 6720
totaldie_roll <- 9
fours <- 3
sixes <- 5
twos <- 1
print(paste0("The number of ways to get 3 fours, 5 sixes and 1 two with six sided die being rolled 9 times is ",factorial(totaldie_roll)/(factorial(fours)*factorial(sixes)*factorial(twos))))
## [1] "The number of ways to get 3 fours, 5 sixes and 1 two with six sided die being rolled 9 times is 504"
pizzaToppingCombination <- function(n,r){
factorial(n)/(factorial(n-r)*factorial(r))
}
print(pizzaToppingCombination(14,6))
## [1] 3003
cardCombination <- function(n,r){
factorial(n)/(factorial(n-r)*factorial(r))
}
print(cardCombination(52,3))
## [1] 22100
TV <- 12
Sound <-9
DVD <- 5
prod(c(TV, Sound, DVD))
## [1] 540
pwdCmbn <- function(n,r){
factorial(n)/factorial(n - r)
}
print((pwdCmbn(26,5)*pwdCmbn(5,3)))
## [1] 473616000
PermutationFn <- function(n,r){
return(factorial(n)/(factorial(n-r)))
}
print(PermutationFn(9,4))
## [1] 3024
CombinationFn <- function(n,r){
factorial(n)/(factorial(n-r)*factorial(r))
}
print(CombinationFn(11,8))
## [1] 165
print(PermutationFn(12,8)/CombinationFn(12,4))
## [1] 40320
PermutationFn(13,7)
## [1] 8648640
# letters occurenrces (p-2, o-2), p and o occuring 2 times
print(factorial(10)/(factorial(2)*factorial(2)))
## [1] 907200
x | 5 | 6 | 7 | 8 | 9 |
---|---|---|---|---|---|
p(x) | 0.1 | 0.2 | 0.3 | 0.2 | 0.2 |
Step 1. Find the expected value E( X ). Round your answer to one decimal place.
x <- c(5,6,7,8,9)
p_of_x <- c(0.1, 0.2, 0.3, 0.2, 0.2)
df_data <- data.frame(x,p_of_x)
print(df_data)
## x p_of_x
## 1 5 0.1
## 2 6 0.2
## 3 7 0.3
## 4 8 0.2
## 5 9 0.2
Exp_Val<- sum(df_data$x * df_data$p_of_x)
print(Exp_Val)
## [1] 7.2
Step 2. Find the variance. Round your answer to one decimal place.
var_x <- sum((df_data$x - Exp_Val)^2 * df_data$p_of_x)
print(paste0("The variance is ",round(var_x,1),"."))
## [1] "The variance is 1.6."
Step 3. Find the standard deviation. Round your answer to one decimal place.
sd_x <- round(sqrt(var_x),1)
print(paste0("The standard deviatio is: ",sd_x))
## [1] "The standard deviatio is: 1.2"
Step 4. Find the value of P(X>=9) Round your answer to one decimal place.
x_9_plus <- round(sum((x>=9) * p_of_x),1)
print(x_9_plus)
## [1] 0.2
Step 5. Find the value of P(X<=7). Round your answer to one decimal place.
x_7_less <- round(sum((x<=7) * p_of_x),1)
print(x_7_less)
## [1] 0.6
Step 1. Find the expected value of the proposition. Round your answer to two decimal places.
total <- 188
attempt <- 376
val_prop <- dbinom(3,size = 3,total/attempt) *23 + (1-dbinom(3,size = 3,total/attempt))*-4
print(round((val_prop),2))
## [1] -0.62
Step 2. If you played this game 994 times how much would you expect to win or lose? (Losses must be entered as negative.)
print(round((val_prop),2)*994)
## [1] -616.28
Step 1. Find the expected value of the proposition. Round your answer to two decimal places.
val_prop_coin <- pbinom(8, size = 11, prob = .5) * 1 + pbinom(8, size = 11, prob = .5, lower.tail = F) * -7
print(round(val_prop_coin, 2))
## [1] 0.74
Step 2. If you played this game 615 times how much would you expect to win or lose? (Losses must be entered as negative.)
print(round(val_prop_coin*615),2)
## [1] 454
first_club <- 13/52
second_club <- 12/51
both_club <- first_club * second_club
no_club <- 1 - both_club
print(paste0("The value is ", round(both_club * 583 + no_club * -35,2),"."))
## [1] "The value is 1.35."
Step 2. If you played this game 632 times how much would you expect to win or lose? (Losses must be entered as negative.)
print(round(both_club * 583 + no_club * -35,2)*632)
## [1] 853.2
pass_inspection<- pbinom(2, size = 10, prob = .3)
print(round(pass_inspection,3))
## [1] 0.383
#sample bulb 5
# 30 percentile 0.3
print(5*.3)
## [1] 1.5
auto_ppois <- (round(ppois(5, 5.5, lower.tail = FALSE),4))
print(auto_ppois)
## [1] 0.4711
credit_ppois <-(round(ppois(4, 5.7, lower.tail = FALSE),4))
print(credit_ppois)
## [1] 0.6728
comp_ppois <-round(ppois(1, 0.4*7, lower.tail = TRUE),4)
print(comp_ppois)
## [1] 0.2311
town_phyper <- round(phyper(1, 6, 19, 8, lower.tail = FALSE),3)
print(town_phyper)
## [1] 0.651
med_rsrch_phyper <- round(phyper(6, 10, 15, 8),3)
print(med_rsrch_phyper)
## [1] 0.998