Setting
We will once again visualize the act of ordering food at In-n-Out.
- \(X\): number of fries orders
- \(Y\): number of beef patties ordered
Correlation
- Compute the correlation in the In-n-Out setting
Interpretation of Correlation
Examples of Correlation
= function(x, r = 0.9){
correlatedValues = r**2
r2 = 1-r2
ve = sqrt(ve)
SD = rnorm(length(x), mean=0, sd=SD)
e = r*x + e
y return(y)
}
= rnorm(100, mean = 0, sd = 1)
x1 = correlatedValues(x1, r = -0.9)
y1 = rnorm(100, mean = 0, sd = 1)
x2 = correlatedValues(x2, r = -0.4)
y2 = rnorm(100, mean = 0, sd = 1)
x3 = correlatedValues(x3, r = 0.0)
y3 = rnorm(100, mean = 0, sd = 1)
x4 = correlatedValues(x4, r = 0.4)
y4 = rnorm(100, mean = 0, sd = 1)
x5 = correlatedValues(x5, r = 0.9)
y5
<- data.frame(x1, y1, "group 1")
df1 <- data.frame(x2, y2, "group 2")
df2 <- data.frame(x3, y3, "group 3")
df3 <- data.frame(x4, y4, "group 4")
df4 <- data.frame(x5, y5, "group 5")
df5 names(df1) <- c("xdata", "ydata", "group")
names(df2) <- c("xdata", "ydata", "group")
names(df3) <- c("xdata", "ydata", "group")
names(df4) <- c("xdata", "ydata", "group")
names(df5) <- c("xdata", "ydata", "group")
<- rbind(df1, df2, df3, df4, df5) main_df
Continuous Joint Probability Distribution Functions
We will once again visualize the act of ordering food at In-n-Out.
- \(X\): number of fries orders
- \(Y\): number of beef patties ordered
with joint PDF
\[f(x,y) = \frac{1}{30}(x + y)e^{-x}e^{-y/5}\]
- Compute the correlation in the In-n-Out setting
Looking Ahead
due Fri., Mar. 17:
- WHW8
- LHW7
Exam 2 will be on Mon., Apr. 10
no lecture on Mar. 24, Apr. 3