---
title: "lab2_practice"
author: "Inhwan Ko"
date: "Oct 8, 2021"
output: pdf_document
editor_options:
chunk_output_type: console
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
## Prerequisite
```{r}
# Good practice to remove all objects from the workspace
rm(list = ls())
# Use library() for packages you need, or source() for other R files.
library(tidyverse)
# Setting the seed ensures that we get the same random draw over and over again.
set.seed(20211008)
rnorm(5) # Check
```
## 0. Calculate the following operations by hand (... meaning by R)
a)
$$ \sum\limits_{i=1}^{5} i = $$
```{R}
```
b)
$$ \prod\limits_{i=1}^{5} i = $$
```{r}
```
c)
$$ 5! \times 10^{3!} \times e^{4} = $$
```{r}
# c)
```
## 1. Build a Bernoulli distribution using the sample() function, where the probability of "success" is 0.7. Run "?sample" if you are unsure how the function works.
```{r}
```
## 2. How do you know if it is working properly? Conduct simulation to check if the assigned probabilities are matached with the empirics
```{r}
```
## 3. Plot the above Bernoulli distribution
```{r}
```
## 4. Based on the above, generate a binomial distribution, with number of trials equal to 10, without using rbinom()
```{r}
```
## 5. Plot the above binomial distribution
```{r}
```
## 6. Explore the rbinom, dbinom, pbinom functions. What do they do? Answer the following questions:
a) The probability of a coin landing on head is 0.7. If you were to flip the coin 10 times, what is the probability of getting exactly 7 heads?
b) What is the probability of getting 7 heads or less?
c) How do you know (b) is true?
```{r}
```
### How to plot?