Skip to content

Commit a1a2c17

Browse files
committed
remove duplicate figures and add library command for UsingR
1 parent 84d1770 commit a1a2c17

1 file changed

Lines changed: 1 addition & 7 deletions

File tree

episodes/conditional-probabilities-expectations.Rmd

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ son, we would go with the average height:
6161

6262
```{r height_hist,message=FALSE,fig.cap="Histogram of son heights."}
6363
library(rafalib)
64+
library(UsingR)
6465
mypar(1, 1)
6566
data(father.son, package="UsingR")
6667
x=round(father.son$fheight) ## round to nearest inch
@@ -69,8 +70,6 @@ hist(y, breaks=seq(min(y), max(y)))
6970
abline(v=mean(y), col="red", lwd=2)
7071
```
7172

72-
![Histogram of son heights.](./fig/03-conditional-probabilities-expectations-height_hist-1.png)
73-
7473
In this case, we can also approximate the distribution of $Y$ as normal, which
7574
implies the mean maximizes the probability density.
7675

@@ -93,9 +92,6 @@ hist(y[x==71],
9392
main="",
9493
xlim=range(y))
9594
```
96-
97-
![Son versus father height (left) with the red lines denoting the stratum defined by conditioning on fathers being 71 inches tall. Conditional distribution: son height distribution of stratum defined by 71 inch fathers.](./fig/03-conditional-probabilities-expectations-conditional_distribution-1.png)
98-
9995
The best guess is still the expectation, but our strata has changed from all the
10096
data, to only the $Y$ with $X=71$. So we can stratify and take the average,
10197
which is the conditional expectation. Our prediction for any $x$ is therefore:
@@ -135,8 +131,6 @@ hist(y[x==71],
135131
abline(v = fit$coef[1] + fit$coef[2]*71, col=1)
136132
```
137133

138-
![Son versus father height showing predicted heights based on regression line (left). Conditional distribution with vertical line representing regression prediction.](./fig/03-conditional-probabilities-expectations-regression-1.png)
139-
140134
In this particular case, the regression line provides an optimal prediction
141135
function for $Y$. But this is not generally true because, in the typical machine
142136
learning problems, the optimal $f(x)$ is rarely a simple line.

0 commit comments

Comments
 (0)