This is the course website for **MATH 350 - Introduction to Probability and Statistics** course taught by Dr. Robin Donatello in Fall 2021 at California State University, Chico. This landing page is used for posting of regular announcements and information for students of the class.

We’re going to close out the semester by practicing estimating probabilities from known distributions using simulation. Technically no new conceptual material will be presented, we will be looking at new applications of prior material.

- Student Office hours on Wednesday 12/2 is moved to 2pm
- Exam 2 Take home credit recovery:
- request regrade through gradescope
- Full credit back for the “choosing the correct distribution” rubric item

- Blackboard Gradedbook fully up to date and represents grade earned to date.
- Yes you can still turn in late homework
- Yes you can still come to office hours or community coding.

- Hw for Chapter 5 is ready. It’s a long assignment, spanning 2 weeks of material that we will be spending time in class on, and is worth 30 pts.

- The
`table`

function creates a frequency table for a vector. A frequency table is a table of possible values in the sample space, and the number of times those occur. - The
`prop.table`

function takes a`table`

object as it’s argument, and converts the frequencies to relative percentages. This is how we get probability estimates, and an estimate of the pmf.

```
<- sample(1:4, 10, replace=TRUE)
x table(x)
```

```
## x
## 1 2 3 4
## 4 2 1 3
```

`prop.table(table(x)) `

```
## x
## 1 2 3 4
## 0.4 0.2 0.1 0.3
```

- The course packet notes for Ch 4.4 are a bit crammed, and slightly out of order. Please refer to the posted notes on this page for more clarity and information.

- We didn’t have as many quizzes as expected, and I’ve combined some of the chapter homeworks into a single submission. This is unintentionally increasing the weight of the exams on your final grade, so I am adjusting the points of the combined homework starting with 4.2 & 4.3.
**I have also combined 4.4 & 4.5 so if you started this already please redownload the template to get the questions from 4.5**- The number of items graded per assignment will increase to reflect the increase in assignment length.

- The Blackboard Learn Gradebook is complete with columns for every remaining graded item. You can now do any of the potential “what if” grade calculations you are interested in. Be sure to cross reference the syllabus to account for dropped quizzes and homework assignments.

We’re going to draw a lot of pictures, so let’s create a function to draw and shade the standard normal distribution

```
<- function(mu, sigma, from, to){
shade.norm = seq(mu-3*sigma, mu+3*sigma, by = 0.1) # set range for x as mu - 3*sigma to mu + 3*sigma
x = dnorm(x, mu, sigma) # calculate p(x) in that range
p.x
<- seq(from, to, by=.01) # set range for shaded region
want.x <- dnorm(want.x, mu, sigma) # calculate p(x) for that region
want.px
# create the density plot
## bty="n" turns off outer box, axes=F turns off axes labels, ylab="" turns off y axis label
plot(x = x, y = p.x, type="l", bty="n", axes=F, ylab="")
# Specify axis ticks at mu +/- 3 sigma
axis(1, at=c(c(mu-1:3*sigma, mu, mu+1:3*sigma)))
polygon(c(from, want.x, to), # set range of x to shade
c(0, want.px, 0), # set range of y to shade (always start and end at 0)
col="lightgreen") # add a color to the shade
}
```

We’re revisiting topics such as expected value and variance, but on continuous distributions. Keep in mind all the same properties of expectation, independence and variance apply!

- Practice for Ch 4.2 and 4.3 have been combined
- Quiz on 4.1 - 4.3 material on Thu/Fri.

- Symbol for infinity in \(\LaTeX\):
`\infty`

and`-\infty`

. - Infinity in R:
`Inf`

- \(e^{1}\) in R:
`exp(1)`

- The results from the
`integrate`

function is complex. To access the numeric answer use`$value`

after the saved object.- Example:
`result <- integrate(f(x), lower=0, upper=1)`

. The numeric answer can be accessed using`result$value`

- Example:

- Last chance for Exam 1 error analysis. You
*must*have all three things below done before meeting with me. - Monday - Finish all Ch3 homework, create review sheet.
- Wednesday - in class exam. Take home distributed.
- Friday - Take home due EOD.
- Monday (11/8) Hw 4.1 due

Don’t forget that coming to community coding or office hours to get help or to check in on your learning progress is part of your grade!

- Update / clarification on late homework policy. Super late homework will still be accepted after the Gradescope window has closed and the solutions posted. This work will only be graded for completeness (max 3 pts), and only if your work is not a copy of the solutions.

- Exam 2 next week - Chapter 3
- Get your course packet checked off by Tuesday 11/2
- Reminder Exam Error Analysis -
**Due before Exam 2**:- Fill out this linked form
- Re-work every missed problem on a separate paper
- Make an appointment with me to go over your corrections.

- If you are meeting with me via Zoom, send me your error assessment form and digital copy of your written Exam 1 before we meet.

**Writing integrals in \(\LaTeX\).** Using the first example in Ch 4.1 as an example:

`$$ \int_{0}^{1} 4y^{3} dy = y^{4} \Biggr|_{0}^{1}$$`

resolves as

\[ \int_{0}^{1} 4y^{3} dy = y^{4} \Biggr|_{0}^{1}\]

**Calculating finite integrals in R**:

- Define a function:

`<- function(y){4*y^3} integrand `

- Use the
`integrate`

function on the integrand with`lower`

and`upper`

bounds specified.

`integrate(integrand,lower=0,upper=1)`

`## 1 with absolute error < 1.1e-14`

Thank you again for your patience with my excessive long time in getting your take home exams graded. I wanted to share some comments & feedback, along with my rubric and what comes next.

**Rubric Scores**

- There were 4 questions at 10 pts each for a total of 40 pts.
- This exam was entirely using simulation. That was part of the instructions. If you did not use simulation to answer a question you received 0 points for that question.
- I was assessing both your ability to code simulation problems, but also your ability to explain your code. I made this clear in the instructions. Half of the credit for each question was on your explanation. That’s 5 pts each per question.
- The remaining 5 points per question was graded on the correctness of your code and process.

**Credit Recovery**

- As with the in person exam, there is an opportunity for credit recovery. I believe in the growth model of learning, and that even if you don’t demonstrate proficiency in a particular topic by a certain date that does not mean you can’t demonstrate it eventually. Of course there are time limits due to the constraints of the semester.
- If you redo your take home exam and correct all mistakes, you can recover up to half of the credit you lost back.
- You can earn full pts back on all pts lost on code explanations if you clearly explain each step per instructions. (no, you don’t need to explain
`replicate`

each time. ) - If you lost most points due to conceptual/coding problems, come see me during OH or CC and lets talk you through these problems before you restart. You have until I finish grading the take home portion of Exam 2 to turn this in.

Wrapping up Chapter 3 this & next week. That means Exam 2 is likely the 1st week of November.

- Variable definitions and code “speak” to each other across code chunks. Consider writing your comments outside code chunks instead of inside them. That way they will word wrap and both you and I can see all of your explanation.
- RStudio has a nice visual editor to help you see what your compiled document will look like, and to help you with making your work more nicely formatted. See here for more information.
- Also has help for technical writing such as LaTeX

- Look back at week 3 for a nice way to align your formulas in LaTeX
- Write the binomial formula in LaTeX:

```
$$
\binom{n}{k}p^{k}(1-p)^{k}
$$
```

- The “is distributed as” tilde (\(\sim\)) in latex is written as
`\sim`

- Writing tables in Markdown can be tricky. Here are some advice:
- make sure there is a blank line before and after the table code
- Stack overflow post
- use a Table generator helper

This week is devoted to exploring two special types of discrete probability distributions.

- I am out of town Monday. Dr. Kathy Gray is covering my 9am class, Dr. Jane Guo covering my 1pm.
- Two HW’s due this week, and a quiz.
- ⚠️
**HOMEWORK POLICY UPDATE**- Starting with HW 3.1 if you do not assign questions to a page number in gradescope then your assignment will not be graded. - Extended Student Hours: - Monday 2-3pm Community Coding [LINK] - Tuesday 8-9pm Community Coding - Wednesday 3-4pm Holt 202 - Thursday 10-11am, Zoom only. Link in Blackboard. - Friday 2-3pm Community Coding

If you have a vector of integer or discrete values, you can create a frequency table using the `table()`

function, and convert that into a table of proportions using `prop.table()`

.

```
<- c(.1, .2, .5, .3)
pX <- sample(1:4, size=100, replace=TRUE)
X table(X)
```

```
## X
## 1 2 3 4
## 28 22 24 26
```

`prop.table(table(X))`

```
## X
## 1 2 3 4
## 0.28 0.22 0.24 0.26
```

- The function
`mean()`

calculates the mean of a vector. - The function
`var()`

calculates the variance of a vector.

Update 10/6: Due dates for Hw 2.4, 3.1 and 3.2 have been adjusted.

We’ve hinted before about the idea that we’re not typically interested in the probability of an event occurring in a single experiment, but more of what’s the expected probability of the event “in the long run”.

Think about each simulation you’ve run for this class. Each time you run it, you get a different result. If you ran your simulation many many times, you would end up with many different results - all similar but they do vary. You’ll be creating a **distribution** of values.

And so that’s what were looking at next. What are random variables, what is the distribution of some random variables, what characteristics of that distribution make them special, and where do we see these distributions occur in real life.

- I will be out of town Friday and Monday. Kathy Gray will be guest lecturing for me.
- Extra student hours this week
- Monday 10-11 Holt 202 (or via zoom if needed)
- Tuesday 4-5pm Zoom - Use link in Blackboard Learn
- Thursday 11-12am Zoom - Use link in Blackboard Learn.

- Exam 1 grading status
- In person exam 3/4 done. Will hand back by Wednesday
- Take home exam compiled. If you have a 0 in BBL you need to submit the RMD to me.
- Exam Error Analysis - Due before Exam 2: This is a chance for you to analyze the types of errors you made on exam 1 (both take home and in person) and see where you have room for improvement. You can then re-work every missed problem on a separate paper, make an appointment with me to go over your corrections and earn back
*all*of the points missed. You must fill out this linked form and try to rework your exam before you meet with me.

- Homework info
- Ch 2.4 assignment has 8 questions. At least 6 is required to be considered “full credit” in the grading rubric.
- Ch 3 has short sections - homework is posted for 3.1 and 3.2 and is due within a few days after we complete that section. Assignments will start moving fast, do your best not to fall behind and don’t wait to ask questions when you get stuck.

Multiplication using a single `*`

in R is done element wise.

`c(2,4,6) * c(1,3,5)`

`## [1] 2 12 30`

If we wanted to then add those elements of the resulting vector together, we could use the `sum()`

function:

`sum(c(2,4,6) * c(1,3,5))`

`## [1] 44`

This process is known as **Vector multiplication** (also known as the product of two vectors, or the dot product) can be done using the `%*%`

operator. This is used in the formula for the expectation of a random variable.

`c(2,4,6) %*% c(1,3,5)`

```
## [,1]
## [1,] 44
```

Here is the overview for the week.

**Monday**: Exam review day. Bring your questions, be prepared to make a summary/review sheet.- Course packet check off times for Monday:
- In class
- During student hours 2-3pm, Holt 111 or via zoom.

- Course packet check off times for Monday:
**Tuesday**: Last day to have your course packet checked off. Times to get this done include:- 8-11am via zoom. 5 minute only, PM me in Slack for link
- 8-9pm via Zoom community coding hours
- (pending) 9-10pm via Zoom. 5 minute only, PM me in Slack for link.

**Wednesday**: In class Exam 1. Typical paper & pencil exam, calculator and course notes only.- Take home exam distributed via email.

**Friday**: Continue Chapter 2.4, counting arguments. - Take home exam due by EoD. Submission instructions will be in the exam.

- R and R Studio cheatsheets are available here:
- Some useful functions:
`max(a, b)`

takes the max value between objects`a`

and`b`

. If`a`

is a vector,`max(a)`

will find the max value within that vector.`length()`

returns the number of elements in a vector. Like`nrow`

for a matrix (which doesn’t work on 1 dimensional vectors)`unique()`

removes duplicate values in a vector. For example if`x <- c(1,2,2,3,3,3)`

, then`distinct(x)`

returns the vector`1,2,3`

.

- Homework 2.3 has been cut down significantly. If you downloaded the template before Saturday, redownload. If you did some of the problems that ended up being cut, don’t worry about it! Leave them in. Just make sure you correctly identify which pages the questions are on when uploading to gradescope.
- Dates for Quiz 3, HW 2.3 and the exam (both in person and take home) have been posted on the schedule and class calendar.
- More information about the exam will be posted here by Friday 9/24.

- The first course packet check off will be Monday 9/29. Anytime during this week, with Monday 9/27 being the absolute last time you need to let me flip through your physical course packet to make sure you have been using this learning resource.

You can request regrades in Gradescope? Learn how to request one here.

I will honor regrade requests up until the first exam for any/all homework questions that have a rubric applied. If you did not get the grade you wanted,

- review your score to see where you missed points.
- Adjust your code (make sure it works)
- In the regrade request paragraph, paste your updated code.

I will run your code on my computer, and if your revision addresses the points that you missed, I will update your score.

Watch the video on independent events before Friday. Fill out your course packet page 24. We will skip lecture and work through examples on page 25 and 26 on friday.

Turn in your homework! I would rather have you turn in your homework late than not at all. I will accept late homework (for a 1 pt penalty) up until the grading is finalized & entered into BBL. Homework 2.1 has been graded, but I will hold off until Tuesday to enter it into BBL. So get your homework turned in! I’ve modified the late date in Gradescope to show Monday midnight.

Now may be a good time to remind everyone of the class policy on collaboration vs cheating.

- I for sure want you working together on the HW, but turning in near carbon copies of your homework files crosses the boundary into cheating. This harms your individual learning and starts to create distrust when independent work is mandated such as exams and quizzes.

ESTIMATED dates for HW2.3 and Exam 1 are on the calendar & schedule. (Not sure yet if we’re going to put Ch2.4 on the first exam)

After we wrap up simulation on Monday by seeing how repeating experiments many times gives you a better approximation of the theoretical probability, we return to thinking about probability and introduce the concept of

**conditional**probability and the meaning of mathematical**independence**Homework solutions for HW1 have been posted on the schedule page. Solutions for 2.1 will be posted shortly, after grading for 2.1 is finalized.

Heads up, if you are not using the Speegle textbook as another learning reference, you are missing out big time. I am here to help guide your learning and direct you from one topic to the next in a sensible manner, but we don’t have enough face to face time (nor do you want to listen to me drone on for that long) to cover everything. Always use the textbook for more/additional examples, to fill in the gaps in your course packet.

**HW 2.2 #7 & #8 will be dropped**

- Here is a good page on the logical operators available in R: https://www.tutorialgateway.org/logical-operators-in-r/
- You can control the size of your images included in your file by putting a
`height`

argument at the end:`![](link to image.png){height="50%"}`

. Note the quotes.

Thank you all for extending grace while I was sick on Friday. Here are the schedule adjustments:

- Group quiz 2 will be done Wed in class.
- Ch 2.1 homework due by EOD Wednesday. You can do most of it already, but we will finish Ch 2.1 on Wednesday in class.
- EOD means end of day, or midnight. On our schedule grid and google calendar, this will be displayed on the day it’s due. E.g. 9/8. However, Gradescope puts the date for midnight on the day
*after*. So the deadline for Hw 2.1 in Gradescope looks like 9/9 at 12:00am.

- EOD means end of day, or midnight. On our schedule grid and google calendar, this will be displayed on the day it’s due. E.g. 9/8. However, Gradescope puts the date for midnight on the day

Other updates/thoughts

- Hw1 has been graded and entered into BBL. It’s your responsibility to check your score both in BBL and gradescope (to make sure they match).
- After the individual quiz has been submitted and responses turned off, you are welcome to talk with each other on the answers.
- You all are doing so very well helping each other out in Slack, and asking questions in the #clarifying-questions and the #general channels. Keep it up! And huge shout out to Sage for finding all my typos. If something isn’t clear, be sure to check Slack first!

- I have recorded my solution to the “You Try It” problem on page 11 of the course notes. Dr. Gray’s version was already up, but I wanted to also use it to show off the two markdown tips I mention below.
- This recording is now in the list of optional videos on the course schedule page.
- Highly recommend watching this in 1.5x speed. The visual editor was being a bit finicky with copy/paste :/

- HW 2.2 has been posted, but I don’t know what the due date will be yet. It will be a day or two after we finish with that section. I will try to release the problem sets earlier (thanks for the suggestion Jon)

- Not digging writing markdown, or want to see what your file will look like without knitting? There is a visual editor available Rmarkdown. Follow the link to read more on how it can help you.
- Since Markdown is a “lightweight” markup editor, you can’t do a lot of things with LaTeX that you could do in a full LaTeX (or Sweave) document, but you can use the
`\align{}`

environment to create aligned multi-line equations. For example:

```
$$
\begin{align}
P(A \cap B) & = P(A) + P(B) - P(A \cup B) \\
& = 1 - P(A^{c}) + 1 - P(B^{c}) - P(A \cup B) \\
& = [1 - P(A^{c})- P(B^{c})] + [1 - P(A \cup B)]
\end{align}
$$
```

Rules:

- Use display math (
`$$`

) - Start the environment using
`\begin{align}`

and end the environment using`\end{align}`

- Each line ends with two backslashes
`\\`

- Each line is aligned at the
`&`

symbol.

**Student Hours set:**

- Wednesday 2pm Holt 202
- Community Coding
- Monday 2pm (Holt 202 until I find a different room)
- Tuesday 8-9pm (Zoom)

- Read Speegle Chapter 2.1 through Example 2.4
- Download the Blank RMD file from the Notes column on the schedule. This is a blank copy of what you have in your course packet. Use this to run code as we discuss it in class.

You can adding Images to your markdown file using the following code.

`![](link to image.png)`

This is not R code, so it does not go in a code chunk.

Example use: This week you’ll be hand drawing some venn diagrams. To add these images to your homework do the following:

- Generate the image by either
- Draw on pencil and paper, then snap a pic with your phone & transfer it to your computer.
- Use a drawing app on your computer to draw a picture, then take a screenshot of your artistry.

- Put that image in the same folder as your homework. Let’s call it
`venn1.png`

- Add it to your homework submission using the following code:
`![](venn1.png)`

This is an orientation & onboarding week. The goal is to get you up and running with R, R Studio and the rest of our course tools. This course website contains all materials except the textbook and course packet for this class.

- Take a look around, click all the things. You will be here a lot. Bookmark this page.
- There is a brief intro video posted in Blackboard for you to watch.
- Review the items listed under the
**read**and**practice**columns on the schedule.**Before Wednesday 8/25**- Get R and R Studio installed. We’ll be working in those on Wednesday.

- Intro quiz due Thursday 8/26.
- My YouTube video on how to download, fill out, and submit your homework

We *all* want this semester to be fully in person for the whole semester and so it is **YOUR** responsibility to help make that a reality. To do that

- Get vaccinated if you are able to.
- Wear a mask (including over your nose) the entire time you are in class.
- If you are not feeling well DO NOT COME TO CLASS. Ping me on Slack to let me know and we’ll figure out a plan.
- Read the syllabus to fully understand campus policy.