Skip to content

Commit

Permalink
Reformat
Browse files Browse the repository at this point in the history
  • Loading branch information
mine-cetinkaya-rundel committed Dec 24, 2021
1 parent 424ac6c commit 9825468
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 1,374 deletions.
12 changes: 6 additions & 6 deletions 04_normal_distribution/normal_distribution.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ You'll be focusing on calories from fat from Dairy Queen products, so let's stor

```{r female-hgt-mean-sd}
dqmean <- mean(dairy_queen$cal_fat)
dqsd <- sd(dairy_queen$cal_fat)
dqsd <- sd(dairy_queen$cal_fat)
```

Next, you make a density histogram to use as the backdrop and use the `lines` function to overlay a normal probability curve.
Expand All @@ -86,9 +86,9 @@ You can verify this by comparing the frequency histogram you constructed earlier

```{r hist-height}
ggplot(data = dairy_queen, aes(x = cal_fat)) +
geom_blank() +
geom_histogram(aes(y = ..density..)) +
stat_function(fun = dnorm, args = c(mean = dqmean, sd = dqsd), col = "tomato")
geom_blank() +
geom_histogram(aes(y = ..density..)) +
stat_function(fun = dnorm, args = c(mean = dqmean, sd = dqsd), col = "tomato")
```

After initializing a blank plot with `geom_blank()`, the `ggplot2` package (within the `tidyverse`) allows us to add additional layers.
Expand All @@ -106,7 +106,7 @@ Eyeballing the shape of the histogram is one way to determine if the data appear
An alternative approach involves constructing a normal probability plot, also called a normal Q-Q plot for "quantile-quantile".

```{r qq}
ggplot(data = dairy_queen, aes(sample = cal_fat)) +
ggplot(data = dairy_queen, aes(sample = cal_fat)) +
geom_line(stat = "qq")
```

Expand Down Expand Up @@ -171,7 +171,7 @@ Assuming a normal distribution has allowed us to calculate a theoretical probabi
If we want to calculate the probability empirically, we simply need to determine how many observations fall above 600 then divide this number by the total sample size.

```{r probability}
dairy_queen %>%
dairy_queen %>%
filter(cal_fat > 600) %>%
summarise(percent = n() / nrow(dairy_queen))
```
Expand Down
1,409 changes: 41 additions & 1,368 deletions 04_normal_distribution/normal_distribution.html

Large diffs are not rendered by default.

0 comments on commit 9825468

Please sign in to comment.