die 1 | die 2
(4/6) * (1/6)= 4/36 = 1/9
library(reshape)
dice_game <- c()
dice_1 <- c(1,2,3,4,5,6)
dice_2 <- c(1,2,3,4,5,6)
for (x in dice_1){
sum <- dice_2+x
dice_game <- append(dice_game,sum)
}
Z = matrix(rep(1,36),ncol=6)
dice_game <- cbind(Z*dice_game)
dice_game## [,1] [,2] [,3] [,4] [,5] [,6]
## [1,] 2 3 4 5 6 7
## [2,] 3 4 5 6 7 8
## [3,] 4 5 6 7 8 9
## [4,] 5 6 7 8 9 10
## [5,] 6 7 8 9 10 11
## [6,] 7 8 9 10 11 12
#sum_5 <- length(subset(dice_game, dice_game==5)| name | variable_name |
|---|---|
| live_below_poverty | P(bel_pov) |
| live_above_poverty | P(above_pov) |
| speak_foreign_language | P(2nd_lang) |
| speak_english_only | P(eng_only) |
## (polygon[GRID.polygon.1], polygon[GRID.polygon.2], polygon[GRID.polygon.3], polygon[GRID.polygon.4], text[GRID.text.5], text[GRID.text.6], text[GRID.text.7], text[GRID.text.8], text[GRID.text.9])
| live_below_poverty | speak_another_language.below_poverty |
|---|---|
| 14.6% | 4.2% |
| speak_english_only_.below_poverty_line |
|---|
| 10.4 |
total_probability= (114+108-78)/204
print(paste("Answer:",total_probability*100,"%"))## [1] "Answer: 70.5882352941177 %"
19/204 / (54/204)## [1] 0.3518519
11/204 / (36/204)## [1] 0.3055556
P_female_blue <- 108/204hard_book_1st <- 28/95
paper_back_fiction <- 59/94
total_prob <- hard_book_1st* paper_back_fiction
#paste("the Answer is ",total_prob *100, "%" )fiction_1st <- 72/95
chance_hard_cover <- 13/59
chance_not_hard_cover <- 46/59
expected_value_hard_cover_was_fiction <-(27/94*(13/59)) +( 28/94*(46/59))
drawing_hard_cover_given_fiction <- fiction_1st * expected_value_hard_cover_was_fiction
#paste("the Answer is ",drawing_hard_cover_given_fiction*100,"%" )first_fiction <- 72/95
second_hard <- 28/95
#paste("the Answer is ",first_fiction*second_hard*100,"%" )##small difference
28/95-28/94## [1] -0.003135498
bag_costs <- c(0,25,60)
freq <- c(.54,.34,.12)
average_revenue <- sum(bag_costs*freq)
## lets get variance
variance <- (bag_costs-average_revenue)^2*freq
total_variance <- sum(variance)
std_dev_bag <- total_variance**(1/2)
cbind(bag_costs,freq,average_revenue,variance,std_dev_bag )## bag_costs freq average_revenue variance std_dev_bag
## [1,] 0 0.54 15.7 133.1046 19.95019
## [2,] 25 0.34 15.7 29.4066 19.95019
## [3,] 60 0.12 15.7 235.4988 19.95019
#paste("expected revenue per customer is",average_revenue, "$")
#paste("standard deviation is",std_dev_bag_revenue, "$")expected_revenue <- 120*average_revenue
freq_given_120 <- (120*freq)
variance <- (bag_costs-average_revenue)^2*freq_given_120
total_variance <- sum(variance)
std_dev_bag_revenue <- total_variance**(1/2)
range_of_outcomes <- c(expected_revenue-std_dev_bag_revenue,expected_revenue+std_dev_bag_revenue)
#paste("expected total revenue is",expected_revenue, "$")
#paste("our expected range of total revenue 95% of the time is(",round(range_of_outcomes[1],2), #"$","-",round(range_of_outcomes[2],2),"$ )")library(dplyr)##
## Attaching package: 'dplyr'
## The following object is masked from 'package:reshape':
##
## rename
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
library(ggplot2)
income_ranges <- c("$1 to $9,999","$10,000 to $14,999","$15,000 to $24,999","$25,000 to $34,999","$35,000 to $49,999","$50,000 to $64,999","$65,000 to $74,999","$75,000 to $99,999","More than 100,000")
Total_hist <- c(2.2,4.7,15.8,18.3,21.2,13.9,5.8,8.4,9.7)
#income_table <- as_data_frame(income_ranges,Total_hist)
table_5 <-data.frame(income_ranges,Total_hist)
table_5$income_ranges <- as.factor(table_5$income_ranges)
#income_table$income_ranges
#str(income_table)
#income_table
ggplot(table_5, aes(income_ranges,Total_hist))+
geom_bar(stat = "identity")+
theme(axis.text.x=element_text(angle=60, hjust=1))chance <- 21.2+18.3+15.8+4.7+2.2
chance## [1] 62.2
paste("the probability is",chance *.41)## [1] "the probability is 25.502"
D. The same data source indicates that 71.8% of females make less than $50,000 per year. Use this value to determine whether or not the assumption you made in part (c) is valid.
71.8*.41## [1] 29.438