```
# Input the data and the pdf
stock <- tibble(x = c(5, 0, -5),
p_x = c(0.11, 0.8, 0.09),
y = c(4, 0, -4),
p_y = c(.18, .67, .15))
Sharpe_ratio <- # name this the Sharpe ratio
stock %>% # use the data from above
mutate(part_mean_x = x*p_x, # find mean for each part of x
part_mean_y = y*p_y, # now for y
mean_x = sum(part_mean_x), # find mean x
mean_y = sum(part_mean_y),# now for y
part_var_x = p_x * (mean_x - x)^2, # find var for each part of x
part_var_y = p_y * (mean_y - y)^2,# now for y
var_x = sum(part_var_x), # find var of x
var_y = sum(part_var_y),# now for y
sd_x = sqrt(var_x), # find sd of x
sd_y = sqrt(var_y)) %>% # now for y
summarise(S_x = (mean_x - 0.015)/sd_x, # find Sharpe ratio of x with rf = 0.015
S_y = (mean_y - 0.015)/sd_y) %>% # now for y
slice(1)
```