Roulette - In American roulette, there are 38 spaces on the wheel: 0, 00, and 1-36.
Simulate the playing of 1000 games betting either red or black (which pay even money, 1:1). - Bet $1 on each game and keep track of your earnings. - What are the earnings per game betting red/black according to your simulation? - What was your longest winning streak? Your - Longest losing streak? Simulate 1000 games betting green (pays 17:1, so if you win, you add $17 to your kitty, and if you lose, you lose $1).
probabilities <- c(18/38,18/38,2/38)
(sum(probabilities))
## [1] 1
raceSamples <- function(noOfSamples)
{
sample(x = c("black","red","green"),
noOfSamples,
replace = T,
prob = probabilities)
}
#nrow the desired number of rows.
samples<-raceSamples(1000)
#df <- data.frame(matrix(unlist(samples), nrow=4, byrow=T))
#Converting to dataframe
df <- data.frame(matrix(unlist(samples), byrow=T),stringsAsFactors=FALSE)
#renaming column name
names(df)[1] <- "color"
#getting sequence of continuation (to get longest winning streak)
df$count<-sequence(rle(as.character(samples))$lengths)
#Assuming we did bet on black, so getting blackEarning from black
black<-subset(df, color=='black')
#max means total how many times there was black
blackColorWining<-length(black$count)
#getting lost count
red<-subset(df, color=='red' )
redColorWinning<-length(red$count)
green<-subset(df, color=='green' )
greenColorWinning<-length(green$count)
lost_timesBlack<-redColorWinning + greenColorWinning
lost_timesRed<-blackColorWining + greenColorWinning
lost_timesGreen<-blackColorWining + redColorWinning
blackColorWining
## [1] 444
redColorWinning
## [1] 501
greenColorWinning
## [1] 55
blackEarning<-blackColorWining -(lost_timesBlack)
blackEarning
## [1] -112
redEarning<-redColorWinning -(lost_timesRed)
redEarning
## [1] 2
greenColorEarning<-(greenColorWinning*17) - lost_timesGreen
greenColorEarning
## [1] -10
max(subset(df, color=='black')$count)
## [1] 9
#getting sequence of continuation (to get longest winning streak)
df$count<-sequence(rle(as.character(samples))$lengths)
df$color[df$color=='red'|df$color=='green']<-"lost"
max(subset(df, color=='lost')$count)
## [1] 21
The NBC TV network earns an average of $400,000 from a hit showand loses an average of $100,000 on a flop (a show that cannot hold its rating and must be canceled). If the network airs a show without a market review, 25% turn out to be hits, and 75% are flop.
For $40,000, a market research firm can be hired to help determine whether the show will be a hit or a flop.
If the show is actually going to be a hit, there is a 90% chance that the market research firm will predict a hit.
If the show is going to be a flop, there is an 80% chance that the market research will predict the show to be a flop.
Determine how the network can maximize its profits over the long haul.
This is Conditional Probabilities problem.
There are four outcomes. Two with research and Two without research (Decision Trees)
Air show a hit with research
Air show a flop with research
Air show a hit without research
Air show a flop without research
With the market research firm …
NBC TV network will pay $40,000 to the market research firm.
Expected Value if the show is hit is 0.25 * 0.9 * 400,000 + 0.75 * 0.2 * 400,000 = $150,000
Expected Value if the show is Flop 0.25 * 0.1 * 100000 + 0.75 * 0.8 * 100000 = $62,500
So the total profit is 150000 - 62500 - 40,000 = $47,500
Without the market research firm
Expected Value if the show is hit is 0.25 * 400,000 = $100,000
Expected Value if the show is Flop 0.75 * 100000 = $75,000
So the total profit is 100000- 75000 = $25,000
Based on the above results : We would recommend NBC TV network to hire a market research firm before airing a show.